Skip to content

Commit

Permalink
Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos-Descalzi committed Aug 27, 2020
1 parent f1379a7 commit 0532ef4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/TestJsonObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def _after_deserialize(self):
self._deserialized = True


class TestObject2(JsonObject):
property1 = Property()


class TestJsonObject(unittest.TestCase):
def test_properties(self):
self.assertEqual(set(Entity.property_names()), set(["oid", "created"]))
Expand Down Expand Up @@ -404,6 +408,19 @@ class TestObject(JsonObject):
deserialized = TestObject.from_dict(serialized, processor=UpperCaseProcessor())
self.assertEqual("hello!!", deserialized.property1)

def test_nested(self):

test_obj = TestObject2()
test_obj.property1 = "hello"

data = {"obj": test_obj.to_dict()}

parsed = JsonObject.parse(data)

self.assertIsInstance(parsed, dict)
self.assertIn("obj", parsed)
self.assertIsInstance(parsed["obj"], TestObject2)


if __name__ == "__main__":
unittest.main()

0 comments on commit 0532ef4

Please sign in to comment.