def test_FromJSONEmptyObject(self): ctx_act = ContextActivities.from_json('{}') self.assertIsInstance(ctx_act, ContextActivities) self.assertEqual(vars(ctx_act), { '_category': None, '_grouping': None, '_other': None, '_parent': None })
def test_FromJSONEmptyObject(self): ctx_act = ContextActivities.from_json('{}') self.assertIsInstance(ctx_act, ContextActivities) self.assertEqual(vars(ctx_act), {})
def test_FromJSONExceptionPartiallyMalformedJSON(self): with self.assertRaises(AttributeError): ctx_act = ContextActivities.from_json('{"category": {"id": "test"}, "test": "invalid property"}')
def test_FromJSONExceptionMalformedJSON(self): with self.assertRaises(AttributeError): ctx_act = ContextActivities.from_json('{"test": "invalid property"}')
def test_FromJSONActivity(self): ctx_act = ContextActivities.from_json('{"category": {"id": "categoryActivity"}, "parent": {"id": "parentActivity"}, "grouping": {"id": "groupingActivity"}, "other": {"id": "otherActivity"}}') self.activityVerificationHelper(ctx_act)
def test_FromJSONList(self): ctx_act = ContextActivities.from_json('{"category": [{"id": "categoryList"}], "parent": [{"id": "parentList"}], "grouping": [{"id": "groupingList"}], "other": [{"id": "otherList"}]}') self.listVerificationHelper(ctx_act)
def test_FromJSONActivity(self): ctx_act = ContextActivities.from_json( '{"category": {"id": "categoryActivity"}, "parent": {"id": "parentActivity"}, ' '"grouping": {"id": "groupingActivity"}, "other": {"id": "otherActivity"}}' ) self.activityVerificationHelper(ctx_act)
def test_FromJSONList(self): ctx_act = ContextActivities.from_json( '{"category": [{"id": "categoryList"}], "parent": [{"id": "parentList"}], ' '"grouping": [{"id": "groupingList"}], "other": [{"id": "otherList"}]}' ) self.listVerificationHelper(ctx_act)
def test_FromJSONExceptionPartiallyMalformedJSON(self): with self.assertRaises(AttributeError): ContextActivities.from_json( '{"category": {"id": "test"}, "test": "invalid property"}')
def test_FromJSONExceptionMalformedJSON(self): with self.assertRaises(AttributeError): ContextActivities.from_json('{"test": "invalid property"}')
def test_FromJSONEmptyObject(self): ctx_act = ContextActivities.from_json('{}') self.assertIsInstance(ctx_act, ContextActivities) self.assertEqual(vars(ctx_act), {'_category': None, '_grouping': None, '_other': None, '_parent': None})