-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_parser.py
More file actions
37 lines (28 loc) · 1.14 KB
/
Copy pathtest_parser.py
File metadata and controls
37 lines (28 loc) · 1.14 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
37
import json
import os
import queue
import unittest
from parser import Parser
class TestAddChildrenToQueue(unittest.TestCase):
def test_add_children_to_queue_simple_types(self):
parser = Parser()
q = queue.Queue()
with open(os.path.join(os.getcwd(), "TestData", "AddChildrenToQueue", "SimpleJson.json")) as f:
test_data = f.read()
test_data = json.loads(test_data)
parser.add_children_to_queue(q, tuple(), "userDetail", test_data)
self.assertTrue(q.empty())
def test_add_children_to_queue_dict_types(self):
parser = Parser()
q = queue.Queue()
expected_values = [
(("playerInfo",), "playerInfo", {}),
(("numbers",), "numbers", {}),
]
with open(os.path.join(os.getcwd(), "TestData", "AddChildrenToQueue", "DictJson.json")) as f:
test_data = f.read()
test_data = json.loads(test_data)
parser.add_children_to_queue(q, tuple(), "userDetail", test_data)
self.assertTupleEqual(expected_values[0], q.get())
self.assertTupleEqual(expected_values[1], q.get())
self.assertTrue(q.empty())