Completed
Push — master ( 3de2d7...fcfe03 )
by Gus
01:06
created

test_doc_load_from_json()   A

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
import unittest
5
from processors import *
6
import os
7
8
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
9
10
class DocumentSerializationTests(unittest.TestCase):
11
12
    def test_doc_load_from_json(self):
13
        "Document.load_from_JSON should produce a Document from serialized_doc.json"
14
        json_file = os.path.join(__location__, "serialized_doc.json")
15
        print(json_file)
16
        with open(json_file, "r") as jf:
17
            doc = Document.load_from_JSON(json.load(jf))
18
        self.assertTrue(isinstance(doc, Document), "Document.load_from_JSON did not produce a Document from {}".format(json_file))
19
20
    def test_sentence_load_from_json(self):
21
        "Sentence.load_from_JSON should produce a Sentence from serialized_sentence.json"
22
        json_file = os.path.join(__location__, "serialized_sentence.json")
23
        print(json_file)
24
        with open(json_file, "r") as jf:
25
            s = Sentence.load_from_JSON(json.load(jf))
26
        self.assertTrue(isinstance(s, Sentence), "Sentence.load_from_JSON did not produce a Sentence from {}".format(json_file))
27
        
28
if __name__ == "__main__":
29
    unittest.main()
30