def test_Init(self): iclist = InteractionComponentList([{ "id": "test1", "description": { "en-US": "test1" } }, { "id": "test2", "description": { "en-US": "test2" } }]) self.listVerificationHelper(iclist)
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)
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_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"}}]'))
def test_AsVersionEmpty(self): iclist = InteractionComponentList() check = iclist.as_version() self.assertEqual(check, [])
def test_InitExceptionNotInteractionComponent(self): with self.assertRaises(TypeError): InteractionComponentList( [InteractionComponent(), 'not InteractionComponent'])
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)
def test_InitEmpty(self): iclist = InteractionComponentList([]) self.assertEqual(iclist, []) self.assertIsInstance(iclist, InteractionComponentList)
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)
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, [])