Skip to content
Permalink
Browse files
Unit tests for Marks calucation in header
  • Loading branch information
aa9863 committed Jul 26, 2020
1 parent 1111b63 commit 3457ecf8d5463580c4d9f71dbadf1c59f1fb21f3
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
@@ -0,0 +1,10 @@
---
name: "foo"
marks:
secOne: 5
secTwo: 10
---

# Some Fake input

Bleh
@@ -0,0 +1,11 @@
---
name: "foo"
marks:
secOne: 50
secTwo: 10
total: 60
---

# Some Fake input

Bleh
@@ -0,0 +1,11 @@
---
name: "foo"
marks:
secOne: 20
secTwo: 30
total: 60
---

# Some Fake input

Bleh
@@ -218,7 +218,52 @@ And More Spacing to be dealt with"""

self.assertEqual("\n".join(body), bodyStr)

def testHeaderTemplate(self):
"""
Test if the header has a Template attached
"""
theParser = parser.MarkdownParser("test/inputs/inputController.md")
hasParsed = theParser.parseFile()
#theParser.parseFile()
#header, body = theParser._splitHeader()
self.assertEqual(theParser.header["template"], "controller.jinja2")

def testHeaderMarks(self):
"""
If marks are given in the header, do we summarise them correctly
"""
theParser = parser.MarkdownParser("test/inputs/inputHeaderMarks.md")
theParser.parseFile()
#First do we have the marks we expected
self.assertEqual(theParser.header["marks"]["secOne"], 5)
self.assertEqual(theParser.header["marks"]["secTwo"], 10)
self.assertEqual(theParser.header["marks"]["total"], 15)

def testHeaderTotalMarks(self):
"""
If marks are given in the header, do we summarise them correctly
"""
theParser = parser.MarkdownParser("test/inputs/inputHeaderMarksTotal.md")
hasParsed = theParser.parseFile()

#First do we have the marks we expected
self.assertEqual(theParser.header["marks"]["secOne"], 50)
self.assertEqual(theParser.header["marks"]["secTwo"], 10)
self.assertEqual(theParser.header["marks"]["total"], 60)

def testHeaderTotalMismatch(self):
"""
If marks are given in the header, do we summarise them correctly
"""
theParser = parser.MarkdownParser("test/inputs/inputHeaderMarksTotalMismatch.md")
with self.assertLogs(level="WARNING") as cm:
hasParsed = theParser.parseFile()
#First do we have the marks we expected
self.assertEqual(theParser.header["marks"]["secOne"], 20)
self.assertEqual(theParser.header["marks"]["secTwo"], 30)
self.assertEqual(theParser.header["marks"]["total"], 50)
self.assertEqual(cm.records[0].msg, "Marks Mismatch. Provided 60 Calculated 50")

def testHeaderVals(self):
"""
Are the values in our header correct
@@ -305,3 +350,6 @@ sid: 14242
self.assertIsInstance(theSection, section.Section)

self.assertEqual(expectedExp, theSection.text)



0 comments on commit 3457ecf

Please sign in to comment.