Beispiel #1
0
 def test_setItemException(self):
     ic1 = InteractionComponent(id='test1', description={"en-US": "test1"})
     ic2 = InteractionComponent(id='test2', description={"en-US": "test2"})
     iclist = InteractionComponentList([ic1, ic2])
     with self.assertRaises(TypeError):
         iclist[0] = 'not InteractionComponent'
     self.listVerificationHelper(iclist)
Beispiel #2
0
 def test_appendItem(self):
     ic1 = InteractionComponent(id='test1', description={"en-US": "test1"})
     ic2 = InteractionComponent(id='test2', description={"en-US": "test2"})
     iclist = InteractionComponentList()
     iclist.append(ic1)
     iclist.append(ic2)
     self.listVerificationHelper(iclist)
Beispiel #3
0
 def test_setItem(self):
     iclist = InteractionComponentList(
         [InteractionComponent(),
          InteractionComponent()])
     iclist[0] = {"id": "test1", "description": {"en-US": "test1"}}
     iclist[1] = InteractionComponent(id="test2",
                                      description={"en-US": "test2"})
     self.listVerificationHelper(iclist)
Beispiel #4
0
 def test_insert(self):
     ic1 = InteractionComponent(id='test1')
     ic2 = InteractionComponent(id='test3')
     iclist = InteractionComponentList([ic1, ic2])
     iclist.insert(1, InteractionComponent(id='test2'))
     self.assertEqual(len(iclist), 3)
     self.assertEqual(iclist[0].id, 'test1')
     self.assertEqual(iclist[1].id, 'test2')
     self.assertEqual(iclist[2].id, 'test3')
 def test_ToJSON(self):
     icomp = InteractionComponent(**{
         "id": "test",
         "description": {
             "en-US": "test"
         }
     })
     self.assertEqual(icomp.to_json(),
                      '{"id": "test", "description": {"en-US": "test"}}')
Beispiel #6
0
 def test_extend(self):
     ic1 = InteractionComponent(id='test1')
     ic2 = InteractionComponent(id='test2')
     arglist = InteractionComponentList([ic1, ic2])
     iclist = InteractionComponentList([InteractionComponent(id='test3')])
     iclist.extend(arglist)
     self.assertEqual(len(iclist), 3)
     self.assertEqual(iclist[0].id, 'test3')
     self.assertEqual(iclist[1].id, 'test1')
     self.assertEqual(iclist[2].id, 'test2')
Beispiel #7
0
 def test_AsVersionNotEmpty(self):
     ic1 = InteractionComponent(id='test1', description={"en-US": "test1"})
     ic2 = InteractionComponent(id='test2', description={"en-US": "test2"})
     iclist = InteractionComponentList([ic1, ic2])
     check = iclist.as_version()
     self.assertEqual(check, [{
         "id": "test1",
         "description": {
             "en-US": "test1"
         }
     }, {
         "id": "test2",
         "description": {
             "en-US": "test2"
         }
     }])
Beispiel #8
0
 def test_InitEmpty(self):
     icomp = InteractionComponent()
     self.assertIsNone(icomp.id)
     self.assertNotIn('description', vars(icomp))
Beispiel #9
0
 def test_InitId(self):
     icomp = InteractionComponent(id='test')
     self.assertEqual(icomp.id, 'test')
     self.assertNotIn('description', vars(icomp))
Beispiel #10
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 #11
0
 def test_ToJSONIgnoreNoneId(self):
     icomp = InteractionComponent(description={"en-US": "test"})
     self.assertEqual(icomp.to_json(), '{"description": {"en-US": "test"}}')
Beispiel #12
0
 def test_FromJSONExceptionFlatDescription(self):
     with self.assertRaises(ValueError):
         InteractionComponent.from_json(
             '{"id": "test", "description": "flatdescription"}')
Beispiel #13
0
 def test_AsVersionEmpty(self):
     icomp = InteractionComponent()
     icomp2 = icomp.as_version("1.0.0")
     self.assertEqual(icomp2, {})
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         icomp = InteractionComponent.from_json('{"bad JSON"}')
 def test_AsVersionNotEmpty(self):
     icomp = InteractionComponent(**{"id": "test"})
     icomp2 = icomp.as_version()
     self.assertEqual(icomp2, {"id": "test"})
 def test_ToJSONIgnoreNoneId(self):
     icomp = InteractionComponent(description={"en-US": "test"})
     self.assertEqual(icomp.to_json(), '{"description": {"en-US": "test"}}')
 def test_ToJSONEmpty(self):
     icomp = InteractionComponent()
     self.assertEqual(icomp.to_json(), "{}")
 def test_ToJSONIgnoreNoneDescription(self):
     icomp = InteractionComponent(id="test")
     self.assertEqual(icomp.to_json(), '{"id": "test"}')
 def test_ToJSON(self):
     icomp = InteractionComponent(**{"id": "test", "description": {"en-US": "test"}})
     self.assertEqual(icomp.to_json(), '{"id": "test", "description": {"en-US": "test"}}')
 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)
Beispiel #21
0
 def test_InitLanguageMapDescription(self):
     icomp = InteractionComponent(id='test',
                                  description=LanguageMap({"en-US":
                                                           "test"}))
     self.assertEqual(icomp.id, 'test')
     self.descriptionVerificationHelper(icomp.description)
 def test_FromJSONExceptionPartiallyMalformedJSON(self):
     with self.assertRaises(AttributeError):
         icomp = InteractionComponent.from_json(
             '{"test": "invalid property", "id": \
         "valid property"}'
         )
Beispiel #23
0
 def test_InitUnpackDescription(self):
     obj = {"description": {"en-US": "test"}}
     icomp = InteractionComponent(**obj)
     self.descriptionVerificationHelper(icomp.description)
 def test_FromJSON(self):
     icomp = InteractionComponent.from_json('{"id": "test", "description": {"en-US": "test"}}')
     self.assertEqual(icomp.id, "test")
     self.descriptionVerificationHelper(icomp.description)
Beispiel #25
0
 def test_FromJSONId(self):
     icomp = InteractionComponent.from_json('{"id": "test"}')
     self.assertEqual(icomp.id, 'test')
     self.assertNotIn('description', vars(icomp))
 def test_FromJSONExceptionFlatDescription(self):
     with self.assertRaises(ValueError):
         icomp = InteractionComponent.from_json('{"id": "test", "description": "flatdescription"}')
Beispiel #27
0
 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_FromJSONId(self):
     icomp = InteractionComponent.from_json('{"id": "test"}')
     self.assertEqual(icomp.id, "test")
     self.assertNotIn("description", vars(icomp))
Beispiel #29
0
 def test_AsVersionNotEmpty(self):
     icomp = InteractionComponent(**{'id': 'test'})
     icomp2 = icomp.as_version()
     self.assertEqual(icomp2, {'id': 'test'})
 def test_FromJSONExceptionEmpty(self):
     with self.assertRaises(ValueError):
         icomp = InteractionComponent.from_json("")
Beispiel #31
0
 def test_ToJSONIgnoreNoneDescription(self):
     icomp = InteractionComponent(id='test')
     self.assertEqual(icomp.to_json(), '{"id": "test"}')
 def test_FromJSONEmptyObject(self):
     icomp = InteractionComponent.from_json("{}")
     self.assertIsNone(icomp.id)
     self.assertNotIn("description", vars(icomp))
Beispiel #33
0
 def test_ToJSONEmpty(self):
     icomp = InteractionComponent()
     self.assertEqual(icomp.to_json(), '{}')
Beispiel #34
0
 def test_InitExceptionUnpackEmptyId(self):
     obj = {"id": ""}
     with self.assertRaises(ValueError):
         InteractionComponent(**obj)
Beispiel #35
0
 def test_InitExceptionEmptyId(self):
     with self.assertRaises(ValueError):
         InteractionComponent(id='')
Beispiel #36
0
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         InteractionComponent.from_json('{"bad JSON"}')
Beispiel #37
0
 def test_InitDescription(self):
     icomp = InteractionComponent(description={"en-US": "test"})
     self.assertIsNone(icomp.id)
     self.descriptionVerificationHelper(icomp.description)
 def test_FromJSONExceptionMalformedJSON(self):
     with self.assertRaises(AttributeError):
         InteractionComponent.from_json('{"test": "invalid property"}')
Beispiel #39
0
 def test_InitEmptyLanguageMapDescription(self):
     icomp = InteractionComponent(id='test', description=LanguageMap({}))
     self.assertEqual(icomp.id, 'test')
     self.assertIsInstance(icomp.description, LanguageMap)
     self.assertEqual(len(vars(icomp.description)), 0)
Beispiel #40
0
 def test_FromJSONExceptionEmpty(self):
     with self.assertRaises(ValueError):
         InteractionComponent.from_json('')
Beispiel #41
0
 def test_InitUnpack(self):
     obj = {"id": "test", "description": {"en-US": "test"}}
     icomp = InteractionComponent(**obj)
     self.assertEqual(icomp.id, 'test')
     self.descriptionVerificationHelper(icomp.description)
 def test_AsVersionEmpty(self):
     icomp = InteractionComponent()
     icomp2 = icomp.as_version("1.0.0")
     self.assertEqual(icomp2, {})
Beispiel #43
0
 def test_InitExceptionUnpackFlatDescription(self):
     obj = {"id": "test", "description": "test"}
     with self.assertRaises(ValueError):
         InteractionComponent(**obj)
Beispiel #44
0
 def test_FromJSONEmptyObject(self):
     icomp = InteractionComponent.from_json('{}')
     self.assertIsNone(icomp.id)
     self.assertNotIn('description', vars(icomp))
Beispiel #45
0
 def test_FromJSONExceptionPartiallyMalformedJSON(self):
     with self.assertRaises(AttributeError):
         InteractionComponent.from_json(
             '{"test": "invalid property", "id": \
         "valid property"}')
 def test_AsVersionNotEmpty(self):
     icomp = InteractionComponent(**{'id': 'test'})
     icomp2 = icomp.as_version()
     self.assertEqual(icomp2, {'id': 'test'})