forked from datacamp/pythonwhat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_test_mc.py
More file actions
36 lines (28 loc) · 1.04 KB
/
test_test_mc.py
File metadata and controls
36 lines (28 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest
import helper
class TestMcRight(unittest.TestCase):
def setUp(self):
self.data = {
"DC_PEC": '# pec comes here',
"DC_CODE": 'selected_option = 2',
"DC_SOLUTION": ''
}
def test_mcSuccess(self):
self.data["DC_SCT"] = 'test_mc(2, ["This is wrong", "This is right"])'
sct_payload = helper.run(self.data)
self.assertTrue(sct_payload['correct'])
self.assertEqual(sct_payload['message'], "This is right")
class TestMcWrong(unittest.TestCase):
def setUp(self):
self.data = {
"DC_PEC": '# pec comes here',
"DC_CODE": 'selected_option = 3',
"DC_SOLUTION": ''
}
def test_mcFail(self):
self.data["DC_SCT"] = 'test_mc(2, ["This is wrong", "This is right", "Oh no, not correct"])'
sct_payload = helper.run(self.data)
self.assertFalse(sct_payload['correct'])
self.assertEqual(sct_payload['message'], "Oh no, not correct")
if __name__ == "__main__":
unittest.main()