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_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_upload_post(self): startnum = dao.Record.query()['hits']['total'] res = self.app.post('/upload?format=bibtex&collection='+urllib.quote_plus('"My Test Collection"'), data = {'upfile': (open('test/data/sample.bibtex'), 'sample.bibtex')}, headers={'REMOTE_USER': Fixtures.account.id} ) assert res.status == '302 FOUND', res.status # Now we have to trigger the ingest handling of the ticket # which is normally done asynchronously for state in ('new', 'downloaded', 'parsed'): for t in ingest.get_tickets(state): ingest.determine_action(t) endnum = dao.Record.query()['hits']['total'] assert_equal(endnum, startnum+1)
def test_upload_post(self): startnum = dao.Record.query()['hits']['total'] res = self.app.post('/upload?format=bibtex&collection=' + urllib.quote_plus('"My Test Collection"'), data={ 'upfile': (open('test/data/sample.bibtex'), 'sample.bibtex') }, headers={'REMOTE_USER': Fixtures.account.id}) assert res.status == '302 FOUND', res.status # Now we have to trigger the ingest handling of the ticket # which is normally done asynchronously for state in ('new', 'downloaded', 'parsed'): for t in ingest.get_tickets(state): ingest.determine_action(t) endnum = dao.Record.query()['hits']['total'] assert_equal(endnum, startnum + 1)
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_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_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_failed_download(self): t = ingest.IngestTicket(source_url="bogus_url", owner="tester", collection="test", format="json") ingest.determine_action(t) assert t["state"] == "failed"