Beispiel #1
0
 def test_FromJSON(self):
     icomp = InteractionComponent.from_json(
         '{"id": "test", "description": {"en-US": "test"}}')
     self.assertEqual(icomp.id, 'test')
     self.descriptionVerificationHelper(icomp.description)
Beispiel #2
0
 def test_ToJSONFromJSON(self):
     json_str = '{"id": "test", "description": {"en-US": "test"}}'
     icomp = InteractionComponent.from_json(json_str)
     self.assertEqual(icomp.id, 'test')
     self.descriptionVerificationHelper(icomp.description)
     self.assertEqual(json.loads(icomp.to_json()), json.loads(json_str))
Beispiel #3
0
 def test_FromJSONId(self):
     icomp = InteractionComponent.from_json('{"id": "test"}')
     self.assertEqual(icomp.id, 'test')
     self.assertNotIn('description', vars(icomp))
Beispiel #4
0
 def test_FromJSONExceptionFlatDescription(self):
     with self.assertRaises(ValueError):
         InteractionComponent.from_json(
             '{"id": "test", "description": "flatdescription"}')
Beispiel #5
0
 def test_FromJSONEmptyObject(self):
     icomp = InteractionComponent.from_json('{}')
     self.assertIsNone(icomp.id)
     self.assertNotIn('description', vars(icomp))
Beispiel #6
0
 def test_FromJSONExceptionEmpty(self):
     with self.assertRaises(ValueError):
         InteractionComponent.from_json('')
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         icomp = InteractionComponent.from_json('{"bad JSON"}')
 def test_FromJSONEmptyObject(self):
     icomp = InteractionComponent.from_json("{}")
     self.assertIsNone(icomp.id)
     self.assertNotIn("description", vars(icomp))
 def test_FromJSON(self):
     icomp = InteractionComponent.from_json('{"id": "test", "description": {"en-US": "test"}}')
     self.assertEqual(icomp.id, "test")
     self.descriptionVerificationHelper(icomp.description)
 def test_ToJSONFromJSON(self):
     json_str = '{"id": "test", "description": {"en-US": "test"}}'
     icomp = InteractionComponent.from_json(json_str)
     self.assertEqual(icomp.id, "test")
     self.descriptionVerificationHelper(icomp.description)
     self.assertEqual(icomp.to_json(), json_str)
 def test_FromJSONExceptionFlatDescription(self):
     with self.assertRaises(ValueError):
         icomp = InteractionComponent.from_json('{"id": "test", "description": "flatdescription"}')
 def test_FromJSONId(self):
     icomp = InteractionComponent.from_json('{"id": "test"}')
     self.assertEqual(icomp.id, "test")
     self.assertNotIn("description", vars(icomp))
 def test_FromJSONExceptionEmpty(self):
     with self.assertRaises(ValueError):
         icomp = InteractionComponent.from_json("")
Beispiel #14
0
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         InteractionComponent.from_json('{"bad JSON"}')
 def test_FromJSONExceptionPartiallyMalformedJSON(self):
     with self.assertRaises(AttributeError):
         icomp = InteractionComponent.from_json(
             '{"test": "invalid property", "id": \
         "valid property"}'
         )
Beispiel #16
0
 def test_FromJSONExceptionPartiallyMalformedJSON(self):
     with self.assertRaises(AttributeError):
         InteractionComponent.from_json(
             '{"test": "invalid property", "id": \
         "valid property"}')
 def test_FromJSONExceptionMalformedJSON(self):
     with self.assertRaises(AttributeError):
         InteractionComponent.from_json('{"test": "invalid property"}')