def test_basic_elasticsearch_convert(crossref_importer): with open('tests/files/crossref-works.single.json', 'r') as f: # not a single line raw = json.loads(f.read()) r = crossref_importer.parse_record(raw) r.state = 'active' release_to_elasticsearch(r)
def test_basic_ingest_release(crossref_importer): with open('tests/files/crossref-works.single.json', 'r') as f: # not a single line raw = json.loads(f.read()) r = crossref_importer.parse_record(raw) r.state = 'active' req = release_ingest_request(r) assert req is not None
def test_basic_toml(crossref_importer): with open("tests/files/crossref-works.single.json", "r") as f: # not a single line raw = json.loads(f.read()) r = crossref_importer.parse_record(raw) r.state = "active" toml_str = entity_to_toml(r) r2 = entity_from_toml(toml_str, ReleaseEntity) assert r == r2 toml_str = entity_to_toml( r, pop_fields=["ident", "revision", "blah", "extra"]) r3 = entity_from_toml(toml_str, ReleaseEntity) assert r != r3
def test_csl_crossref(crossref_importer): with open('tests/files/crossref-works.single.json', 'r') as f: # not a single line raw = json.loads(f.read()) r = crossref_importer.parse_record(raw) csl = release_to_csl(r) citeproc_csl(csl, 'csl-json') citeproc_csl(csl, 'bibtex') citeproc_csl(csl, 'harvard1') citeproc_csl(csl, 'harvard1', html=True) # check that with no author surnames, can't run for c in r.contribs: c.raw_name = None c.surname = None with pytest.raises(ValueError): release_to_csl(r) with pytest.raises(ValueError): csl = release_to_csl(r) citeproc_csl(csl, 'csl-json')
def test_csl_crossref(crossref_importer): with open('tests/files/crossref-works.single.json', 'r') as f: # not a single line raw = json.loads(f.read()) r = crossref_importer.parse_record(raw) # this work has some null contrib names; these should cause errors with pytest.raises(ValueError): release_to_csl(r) with pytest.raises(ValueError): csl = release_to_csl(r) citeproc_csl(csl, 'csl-json') # set with dummy so we can run other tests for c in r.contribs: if not c.raw_name: c.raw_name = "dummy" csl = release_to_csl(r) citeproc_csl(csl, 'csl-json') citeproc_csl(csl, 'bibtex') citeproc_csl(csl, 'harvard1') citeproc_csl(csl, 'harvard1', html=True)