def test_index_xml(self): request = Mock() result = self.controller.index(request) self.assertIsNotNone(result, 'Result was None') id = VERSIONS['1.0']['id'] status = VERSIONS['1.0']['status'] base_url = BASE_URL updated = VERSIONS['1.0']['updated'] version = Version(id, status, base_url, updated) result._data = Mock() result._data.data_for_xml = lambda: {'versions': [version]} xml_data = result.data("application/xml") self.assertIsNotNone(xml_data, 'Result xml_data was None') versions = xml_data['versions'] self.assertIsNotNone(versions, "Versions was None") self.assertTrue(len(versions) == 1, "Versions length was != 1") v = versions[0] self.assertEqual('v1.0', v.id, 'Version id is incorrect') self.assertEqual('CURRENT', v.status, 'Version status is incorrect') self.assertEqual('2012-08-01T00:00:00Z', v.updated, 'Version updated value is incorrect')
def setUp(self): super(VersionTestCase, self).setUp() id = VERSIONS['1.0']['id'] status = VERSIONS['1.0']['status'] base_url = BASE_URL updated = VERSIONS['1.0']['updated'] self.version = Version(id, status, base_url, updated) self.assertIsNotNone(self.version, 'Version instance was None')
def setUp(self): super(VersionDataViewTestCase, self).setUp() # get a version object first id = VERSIONS['1.0']['id'] status = VERSIONS['1.0']['status'] base_url = BASE_URL updated = VERSIONS['1.0']['updated'] self.version = Version(id, status, base_url, updated) self.assertIsNotNone(self.version, 'Version instance was None') # then create an instance of VersionDataView self.version_data_view = VersionDataView(self.version) self.assertIsNotNone(self.version_data_view, 'Version Data view instance was None')