-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_test.py
More file actions
43 lines (31 loc) · 1.21 KB
/
process_test.py
File metadata and controls
43 lines (31 loc) · 1.21 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
38
39
40
41
42
43
import json
import tempfile
import unittest
import process
from web.services.verb_definition import SenseData
from web.services import directory_service
class process_tests(unittest.TestCase):
def test_jsonEncodesVerbDefinition(self):
test_list = set([1,2,3])
definition = SenseData()
definition.hypernyms = test_list
result = process._encode_for_json(definition)
self.assertIsInstance(result['hypernyms'], list)
def test_integration(self):
tempFileWrapepr = tempfile.NamedTemporaryFile(suffix='.json')
test_list = set([1,2,3])
definition = dict()
definition['random_key'] = test_list
new_dict = {'run':SenseData()}
synsets_list = {
'blah.l.01':test_list
}
file_data = {
'directory': new_dict,
'synsets': synsets_list
}
with open(tempFileWrapepr.name, "w") as tempFile:
json.dump(file_data, tempFile, default=process._encode_for_json)
with open(tempFileWrapepr.name, "r") as tempFile:
loaded = json.load(tempFile, object_hook=directory_service._decode_complex)
self.assertEqual(len(loaded['synsets']['blah.l.01']), 3)