def test_owner_valid_01(self): unknown_owner = dao.Account.get('moocow') assert unknown_owner is None t = ingest.IngestTicket(owner='moocow', collection='test', format='json', source_url='')
def test_failed_download(self): t = ingest.IngestTicket( source_url='bogus_url', owner='tester', collection='test', format='json', ) ingest.determine_action(t) assert t['state'] == 'failed'
def test_download(self): # Note: the URL intentionally has a space at the end URL = 'https://raw.github.com/okfn/bibserver/master/test/data/sample.bibtex ' t = ingest.IngestTicket(owner='tester', collection='test', format='bibtex', source_url=URL) assert t['state'] == 'new' t.save() assert len(ingest.get_tickets()) == 1 ingest.determine_action(t) assert t['state'] == 'downloaded' assert t['data_md5'] == 'b61489f0a0f32a26be4c8cfc24574c0e'
def test_parse_and_index(self): URL = 'https://raw.github.com/okfn/bibserver/master/test/data/sample.bibtex' t = ingest.IngestTicket(owner='tester', collection=u'test', format='bibtex', source_url=URL) ingest.determine_action(t); print repr(t) assert t['state'] == 'downloaded' ingest.determine_action(t); print repr(t) assert t['state'] == 'parsed' ingest.determine_action(t); print repr(t) assert t['state'] == 'done' data_path = 'test/data/downloads/' + t['data_json'] data = json.loads(open(data_path).read()) assert data['records'][0]['title'] == 'Visibility to infinity in the hyperbolic plane, despite obstacles'
def test_owner_valid_02(self): t = ingest.IngestTicket(owner={}, collection='test', format='json', source_url='')
def test_owner_none(self): t = ingest.IngestTicket(owner=None, collection='test', format='json', source_url='')
def test_params(self): t = ingest.IngestTicket(owner='tester')