Exemplo n.º 1
0
 def test_Init(self):
     iclist = InteractionComponentList([{
         "id": "test1",
         "description": {
             "en-US": "test1"
         }
     }, {
         "id": "test2",
         "description": {
             "en-US": "test2"
         }
     }])
     self.listVerificationHelper(iclist)
Exemplo n.º 2
0
 def test_InitUnpack(self):
     obj = {
         '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'
         }
     }
     adef = ActivityDefinition(**obj)
     self.definitionVerificationHelper(adef)
Exemplo n.º 3
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"
         }
     }])
Exemplo n.º 4
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"}}]'))
Exemplo n.º 5
0
 def test_AsVersionEmpty(self):
     iclist = InteractionComponentList()
     check = iclist.as_version()
     self.assertEqual(check, [])
Exemplo n.º 6
0
 def test_InitExceptionNotInteractionComponent(self):
     with self.assertRaises(TypeError):
         InteractionComponentList(
             [InteractionComponent(), 'not InteractionComponent'])
Exemplo n.º 7
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)
Exemplo n.º 8
0
 def test_InitEmpty(self):
     iclist = InteractionComponentList([])
     self.assertEqual(iclist, [])
     self.assertIsInstance(iclist, InteractionComponentList)
Exemplo n.º 9
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')
Exemplo n.º 10
0
 def test_extendExceptionNotComponent(self):
     ic1 = InteractionComponent(id='test1')
     arglist = [ic1, 'not InteractionComponent']
     iclist = InteractionComponentList([InteractionComponent()])
     with self.assertRaises(TypeError):
         iclist.extend(arglist)
Exemplo n.º 11
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)
Exemplo n.º 12
0
 def test_appendItemException(self):
     iclist = InteractionComponentList()
     with self.assertRaises(TypeError):
         iclist.append('not InteractionComponent')
     self.assertEqual(iclist, [])