Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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"}}')
Ejemplo n.º 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')
Ejemplo n.º 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"
         }
     }])
Ejemplo n.º 8
0
 def test_InitEmpty(self):
     icomp = InteractionComponent()
     self.assertIsNone(icomp.id)
     self.assertNotIn('description', vars(icomp))
Ejemplo n.º 9
0
 def test_InitId(self):
     icomp = InteractionComponent(id='test')
     self.assertEqual(icomp.id, 'test')
     self.assertNotIn('description', vars(icomp))
Ejemplo n.º 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))
Ejemplo n.º 11
0
 def test_ToJSONIgnoreNoneId(self):
     icomp = InteractionComponent(description={"en-US": "test"})
     self.assertEqual(icomp.to_json(), '{"description": {"en-US": "test"}}')
Ejemplo n.º 12
0
 def test_FromJSONExceptionFlatDescription(self):
     with self.assertRaises(ValueError):
         InteractionComponent.from_json(
             '{"id": "test", "description": "flatdescription"}')
Ejemplo n.º 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)
Ejemplo n.º 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"}'
         )
Ejemplo n.º 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)
Ejemplo n.º 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"}')
Ejemplo n.º 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))
Ejemplo n.º 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("")
Ejemplo n.º 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))
Ejemplo n.º 33
0
 def test_ToJSONEmpty(self):
     icomp = InteractionComponent()
     self.assertEqual(icomp.to_json(), '{}')
Ejemplo n.º 34
0
 def test_InitExceptionUnpackEmptyId(self):
     obj = {"id": ""}
     with self.assertRaises(ValueError):
         InteractionComponent(**obj)
Ejemplo n.º 35
0
 def test_InitExceptionEmptyId(self):
     with self.assertRaises(ValueError):
         InteractionComponent(id='')
Ejemplo n.º 36
0
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         InteractionComponent.from_json('{"bad JSON"}')
Ejemplo n.º 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"}')
Ejemplo n.º 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)
Ejemplo n.º 40
0
 def test_FromJSONExceptionEmpty(self):
     with self.assertRaises(ValueError):
         InteractionComponent.from_json('')
Ejemplo n.º 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, {})
Ejemplo n.º 43
0
 def test_InitExceptionUnpackFlatDescription(self):
     obj = {"id": "test", "description": "test"}
     with self.assertRaises(ValueError):
         InteractionComponent(**obj)
Ejemplo n.º 44
0
 def test_FromJSONEmptyObject(self):
     icomp = InteractionComponent.from_json('{}')
     self.assertIsNone(icomp.id)
     self.assertNotIn('description', vars(icomp))
Ejemplo n.º 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'})