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_get_tickets(self): tckts = ingest.get_tickets() assert len(tckts) > 0 for t in tckts: assert 'tester/test,' in str(t)