def test_ToJSON(self):
     iclist = InteractionComponentList(
         [{"id": "test1", "description": {"en-US": "test1"}}, {"id": "test2", "description": {"en-US": "test2"}}])
     # since the map is unordered, it is ok that to_json() changes ordering
     self.assertEqual(iclist.to_json(),
                      '[{"id": "test1", "description": {"en-US": "test1"}}, '
                      '{"id": "test2", "description": {"en-US": "test2"}}]')
示例#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)
 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)
示例#4
0
 def test_AsVersion(self):
     adef = ActivityDefinition({
         'description': {'en-US': 'test'},
         'name': {'en-US': 'test'},
         'type': 'test',
         'more_info': 'test',
         'interaction_type': 'choice',
         'correct_responses_pattern': ['test'],
         'choices': InteractionComponentList(),
         'scale': InteractionComponentList(),
         'source': InteractionComponentList(),
         'target': InteractionComponentList(),
         'steps': InteractionComponentList(),
         'extensions': {'test': 'test'}
     })
     adef2 = adef.as_version()
     self.assertEqual(adef2, {
         "name": {"en-US": "test"},
         "correctResponsesPattern": ["test"],
         "scale": [],
         "description": {"en-US": "test"},
         "choices": [],
         "source": [],
         "steps": [],
         "moreInfo": "test",
         "extensions": {"test": "test"},
         "interactionType": "choice",
         "target": [],
         "type": "test",
     })
 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"}}]
     )
 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')
示例#7
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')
示例#8
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')
 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')
示例#10
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"
         }
     }])
示例#11
0
 def test_InitAll(self):
     adef = ActivityDefinition({
         'name': {'en-US': 'test'},
         'description': {'en-US': 'test'},
         'type': 'test',
         'more_info': 'test',
         'interaction_type': 'choice',
         'correct_responses_pattern': ['test'],
         'choices': InteractionComponentList(),
         'scale': InteractionComponentList(),
         'source': InteractionComponentList(),
         'target': InteractionComponentList(),
         'steps': InteractionComponentList(),
         'extensions': {'test': 'test'}
     })
     self.definitionVerificationHelper(adef)
示例#12
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)
示例#13
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)
示例#14
0
 def test_ToJSON(self):
     iclist = InteractionComponentList([{
         "id": "test1",
         "description": {
             "en-US": "test1"
         }
     }, {
         "id": "test2",
         "description": {
             "en-US": "test2"
         }
     }])
     # since the map is unordered, it is ok that to_json() changes ordering
     self.assertEqual(
         json.loads(iclist.to_json()),
         json.loads('[{"id": "test1", "description": {"en-US": "test1"}}, '
                    '{"id": "test2", "description": {"en-US": "test2"}}]'))
示例#15
0
 def test_Init(self):
     iclist = InteractionComponentList([{
         "id": "test1",
         "description": {
             "en-US": "test1"
         }
     }, {
         "id": "test2",
         "description": {
             "en-US": "test2"
         }
     }])
     self.listVerificationHelper(iclist)
示例#16
0
 def test_appendItemCoercion(self):
     iclist = InteractionComponentList()
     iclist.append({"id": "test1", "description": {"en-US": "test1"}})
     iclist.append({"id": "test2", "description": {"en-US": "test2"}})
     self.listVerificationHelper(iclist)
 def test_appendItemCoercion(self):
     iclist = InteractionComponentList()
     iclist.append({"id": "test1", "description": {"en-US": "test1"}})
     iclist.append({"id": "test2", "description": {"en-US": "test2"}})
     self.listVerificationHelper(iclist)
 def test_appendItemException(self):
     iclist = InteractionComponentList()
     with self.assertRaises(TypeError):
         iclist.append('not InteractionComponent')
     self.assertEqual(iclist, [])
示例#19
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))
示例#20
0
 def test_extendExceptionNotComponent(self):
     ic1 = InteractionComponent(id='test1')
     arglist = [ic1, 'not InteractionComponent']
     iclist = InteractionComponentList([InteractionComponent()])
     with self.assertRaises(TypeError):
         iclist.extend(arglist)
示例#21
0
 def test_FromJSONEmptyList(self):
     iclist = InteractionComponentList.from_json('[]')
     self.assertIsInstance(iclist, InteractionComponentList)
     self.assertEqual(iclist, [])
示例#22
0
 def test_appendItemException(self):
     iclist = InteractionComponentList()
     with self.assertRaises(TypeError):
         iclist.append('not InteractionComponent')
     self.assertEqual(iclist, [])
示例#23
0
 def test_insertExceptionNotComponent(self):
     ic1 = InteractionComponent(id='test1')
     ic2 = InteractionComponent(id='test3')
     iclist = InteractionComponentList([ic1, ic2])
     with self.assertRaises(TypeError):
         iclist.insert(1, 'not InteractionComponent')
 def test_FromJSONEmptyList(self):
     iclist = InteractionComponentList.from_json('[]')
     self.assertIsInstance(iclist, InteractionComponentList)
     self.assertEqual(iclist, [])
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         iclist = InteractionComponentList.from_json('{"bad JSON"}')
 def test_insertExceptionNotComponent(self):
     ic1 = InteractionComponent(id='test1')
     ic2 = InteractionComponent(id='test3')
     iclist = InteractionComponentList([ic1, ic2])
     with self.assertRaises(TypeError):
         iclist.insert(1, 'not InteractionComponent')
 def test_extendExceptionNotComponent(self):
     ic1 = InteractionComponent(id='test1')
     arglist = [ic1, 'not InteractionComponent']
     iclist = InteractionComponentList([InteractionComponent()])
     with self.assertRaises(TypeError):
         iclist.extend(arglist)
示例#28
0
 def test_AsVersionEmpty(self):
     iclist = InteractionComponentList()
     check = iclist.as_version()
     self.assertEqual(check, [])
示例#29
0
 def test_InitInteractionComponentList(self):
     ic1 = InteractionComponent(id='test1', description={"en-US": "test1"})
     ic2 = InteractionComponent(id='test2', description={"en-US": "test2"})
     arg = InteractionComponentList([ic1, ic2])
     iclist = InteractionComponentList(arg)
     self.listVerificationHelper(iclist)
示例#30
0
 def test_InitEmpty(self):
     iclist = InteractionComponentList([])
     self.assertEqual(iclist, [])
     self.assertIsInstance(iclist, InteractionComponentList)
 def test_FromJSON(self):
     iclist = InteractionComponentList.from_json(
         '[{"id": "test1", "description": {"en-US": "test1"}}, {"id": "test2", "description": {"en-US": "test2"}}]'
     )
     self.listVerificationHelper(iclist)
示例#32
0
 def test_InitExceptionNotInteractionComponent(self):
     with self.assertRaises(TypeError):
         InteractionComponentList(
             [InteractionComponent(), 'not InteractionComponent'])
 def test_FromJSONExceptionNestedObject(self):
     with self.assertRaises(TypeError):
         iclist = InteractionComponentList.from_json(
             '[{"id": "test1", "description": {"en-US": "test1"}}, [{"id": "nested!"}]]'
         )
示例#34
0
 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_AsVersionEmpty(self):
     iclist = InteractionComponentList()
     check = iclist.as_version()
     self.assertEqual(check, [])
示例#36
0
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         InteractionComponentList.from_json('{"bad JSON"}')
 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)
示例#38
0
 def test_FromJSONExceptionNestedObject(self):
     with self.assertRaises(TypeError):
         InteractionComponentList.from_json(
             '[{"id": "test1", "description": {"en-US": "test1"}}, [{"id": "nested!"}]]'
         )