def test_AsVersionNotEmpty(self):
     a1 = Activity(id='test1', object_type='Activity')
     a2 = Activity(id='test2', object_type='Activity')
     alist = ActivityList([a1, a2])
     check = alist.as_version()
     self.assertEqual(check,
                      [{"id": "test1", "objectType": "Activity"}, {"id": "test2", "objectType": "Activity"}])
 def test_appendItem(self):
     a1 = Activity(id='test1', object_type='Activity')
     a2 = Activity(id='test2', object_type='Activity')
     alist = ActivityList()
     alist.append(a1)
     alist.append(a2)
     self.listVerificationHelper(alist)
 def test_insert(self):
     a1 = Activity(id='test1', object_type='Activity')
     a2 = Activity(id='test3')
     alist = ActivityList([a1, a2])
     alist.insert(1, Activity(id='test2', object_type='Activity'))
     self.assertEqual(len(alist), 3)
     self.assertEqual(alist[0].id, 'test1')
     self.assertEqual(alist[1].id, 'test2')
     self.assertEqual(alist[2].id, 'test3')
 def test_extend(self):
     a1 = Activity(id='test1', object_type='Activity')
     a2 = Activity(id='test2', object_type='Activity')
     arglist = ActivityList([a1, a2])
     alist = ActivityList([Activity(id='test3')])
     alist.extend(arglist)
     self.assertEqual(len(alist), 3)
     self.assertEqual(alist[0].id, 'test3')
     self.assertEqual(alist[1].id, 'test1')
     self.assertEqual(alist[2].id, 'test2')
 def test_ToJSON(self):
     alist = ActivityList([{"id": "test1"}, {"id": "test2"}])
     self.assertEqual(alist.to_json(),
                      '[{"id": "test1", "objectType": "Activity"}, {"id": "test2", "objectType": "Activity"}]')
 def test_ToJSONFromJSON(self):
     json_str = '[{"id": "test1", "objectType": "Activity"}, {"id": "test2", "objectType": "Activity"}]'
     alist = ActivityList.from_json(json_str)
     self.listVerificationHelper(alist)
     self.assertEqual(alist.to_json(), json_str)
 def test_AsVersionEmpty(self):
     alist = ActivityList()
     check = alist.as_version()
     self.assertEqual(check, [])
 def test_FromJSONEmptyList(self):
     alist = ActivityList.from_json('[]')
     self.assertIsInstance(alist, ActivityList)
     self.assertEqual(alist, [])
 def test_FromJSONExceptionNestedObject(self):
     with self.assertRaises(TypeError):
         ActivityList.from_json(
             '[{"id": "test1"}, [{"id": "nested!"}]]'
         )
 def test_FromJSONExceptionBadJSON(self):
     with self.assertRaises(ValueError):
         ActivityList.from_json('{"bad JSON"}')
 def test_FromJSON(self):
     alist = ActivityList.from_json(
         '[{"id": "test1"}, {"id": "test2"}]'
     )
     self.listVerificationHelper(alist)
 def test_insertExceptionNotComponent(self):
     a1 = Activity(id='test1', object_type='Activity')
     a2 = Activity(id='test3')
     alist = ActivityList([a1, a2])
     with self.assertRaises(TypeError):
         alist.insert(1, 'not Activity')
 def test_extendExceptionNotComponent(self):
     a1 = Activity(id='test1', object_type='Activity')
     arglist = [a1, 'not Activity']
     alist = ActivityList([Activity()])
     with self.assertRaises(TypeError):
         alist.extend(arglist)
 def test_appendItemCoercion(self):
     alist = ActivityList()
     alist.append({"id": "test1"})
     alist.append({"id": "test2"})
     self.listVerificationHelper(alist)
 def test_appendItemException(self):
     alist = ActivityList()
     with self.assertRaises(TypeError):
         alist.append('not Activity')
     self.assertEqual(alist, [])
 def test_setItem(self):
     alist = ActivityList([Activity(), Activity()])
     alist[0] = {"id": "test1"}
     alist[1] = Activity(id="test2")
     self.listVerificationHelper(alist)