def test_adds_readme_if_there_is(self): descriptor = {'name': 'test', 'resources': []} readme = 'README' with self.app.app_context(): db.drop_all() db.create_all() publisher = Publisher(name=self.publisher) metadata = MetaDataDB(name=self.package) metadata.descriptor = json.dumps(descriptor) metadata.readme = readme publisher.packages.append(metadata) db.session.add(publisher) db.session.commit() response = self.client.get('/api/package/%s/%s'%\ (self.publisher, self.package)) catalog = Catalog(json.loads(response.data)) dataset = catalog.construct_dataset() self.assertEqual(dataset.get('readme'), 'README')
def test_return_all_metadata_is_there(self): descriptor = {'name': 'test description'} readme = 'README' with self.app.app_context(): publisher = Publisher(name=self.publisher) metadata = MetaDataDB(name=self.package) metadata.descriptor = json.dumps(descriptor) metadata.readme = readme publisher.packages.append(metadata) db.session.add(publisher) db.session.commit() response = self.client.get('/api/package/%s/%s'%\ (self.publisher, self.package)) data = json.loads(response.data) self.assertEqual(response.status_code, 200) self.assertEqual(len(data), 5) self.assertEqual(data['descriptor']['name'], 'test description') self.assertEqual(data['readme'], 'README') self.assertEqual(data['id'], 1) self.assertEqual(data['name'], self.package) self.assertEqual(data['publisher'], self.publisher)