def test_ToJSONFromJSON(self):
     json_str = '[{"id": "test1", "description": {"en-US": "test1"}}, {"id": "test2", "description": {"en-US": "test2"}}]'
     iclist = InteractionComponentList.from_json(json_str)
     self.listVerificationHelper(iclist)
     self.assertEqual(iclist.to_json(), json_str)
 def test_FromJSONExceptionNestedObject(self):
     with self.assertRaises(TypeError):
         iclist = InteractionComponentList.from_json(
             '[{"id": "test1", "description": {"en-US": "test1"}}, [{"id": "nested!"}]]'
         )
 def test_FromJSONEmptyList(self):
     iclist = InteractionComponentList.from_json('[]')
     self.assertIsInstance(iclist, InteractionComponentList)
     self.assertEqual(iclist, [])
 def test_FromJSON(self):
     iclist = InteractionComponentList.from_json(
         '[{"id": "test1", "description": {"en-US": "test1"}}, {"id": "test2", "description": {"en-US": "test2"}}]'
     )
     self.listVerificationHelper(iclist)
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         iclist = InteractionComponentList.from_json('{"bad JSON"}')
Esempio n. 6
0
 def test_FromJSONEmptyList(self):
     iclist = InteractionComponentList.from_json('[]')
     self.assertIsInstance(iclist, InteractionComponentList)
     self.assertEqual(iclist, [])
Esempio n. 7
0
 def test_FromJSONExceptionNestedObject(self):
     with self.assertRaises(TypeError):
         InteractionComponentList.from_json(
             '[{"id": "test1", "description": {"en-US": "test1"}}, [{"id": "nested!"}]]'
         )
Esempio n. 8
0
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         InteractionComponentList.from_json('{"bad JSON"}')
Esempio n. 9
0
 def test_FromJSON(self):
     iclist = InteractionComponentList.from_json(
         '[{"id": "test1", "description": {"en-US": "test1"}}, {"id": "test2", "description": {"en-US": "test2"}}]'
     )
     self.listVerificationHelper(iclist)
Esempio n. 10
0
 def test_ToJSONFromJSON(self):
     json_str = '[{"id": "test1", "description": {"en-US": "test1"}}, ' \
                '{"id": "test2", "description": {"en-US": "test2"}}]'
     iclist = InteractionComponentList.from_json(json_str)
     self.listVerificationHelper(iclist)
     self.assertEqual(json.loads(iclist.to_json()), json.loads(json_str))