def test_init_by_properties(self): rl = CollectionResource(client=MagicMock(), properties={ 'href': '/', 'offset': 0, 'limit': 25, 'items': [{ 'href': 'test/resource' }, { 'href': 'another/resource' }] }) self.assertTrue(rl.is_materialized()) # test length computation self.assertEqual(len(rl), 2) # test indexing self.assertEqual(rl[0].href, 'test/resource') self.assertEqual(rl[1].href, 'another/resource') # test iteration hrefs = [r.href for r in rl] self.assertTrue(hrefs, ['test/resource', 'another/resource'])
def test_init_by_properties(self): rl = CollectionResource(client=MagicMock(), properties={ 'href': '/', 'offset': 0, 'limit': 25, 'items': [ {'href': 'test/resource'}, {'href': 'another/resource'} ] }) self.assertTrue(rl.is_materialized()) # test length computation self.assertEqual(len(rl), 2) # test indexing self.assertEqual(rl[0].href, 'test/resource') self.assertEqual(rl[1].href, 'another/resource') # test iteration hrefs = [r.href for r in rl] self.assertTrue(hrefs, ['test/resource', 'another/resource'])