-
Notifications
You must be signed in to change notification settings - Fork 3
/
tests.py
35 lines (29 loc) · 1.24 KB
/
tests.py
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
import unittest
import questionnode
import database
nodes = {i: database.__dict__[i] for i in database.__dict__ if
isinstance(database.__dict__[i], questionnode.GameNode)}
class TestAnswers(unittest.TestCase):
def test_all_answers_mapped(self):
global nodes
for node in nodes:
try:
self.assertLessEqual(len(nodes[node].options),
len(nodes[node].answer_map),
"node %s has %s options and %s map points" %
(str(nodes[node].idnum), str(len(nodes[node].options)),
str(len(nodes[node].answer_map))))
except AttributeError:
self.assertEqual(len(nodes[node].answer_map), 1,
"node %s has no options and %s map points" %
(str(nodes[node].idnum), str(len(nodes[node].answer_map))))
def test_all_maps_valid(self):
global nodes
node_ids = [nodes[node].idnum for node in nodes]
node_ids.append("")
for node in nodes:
for map_point in nodes[node].answer_map:
self.assertIn(nodes[node].answer_map[map_point], node_ids,
"node %s has an invalid map point")
if __name__ == '__main__':
unittest.main()