1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
from fatcat_openapi_client import ReleaseEntity
from fatcat_scholar.schema import *
from fatcat_scholar.api_entities import *
from fatcat_scholar.transform import *
def test_es_release_from_release() -> None:
with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4.json", "r") as f:
release = entity_from_json(f.read(), ReleaseEntity)
obj = es_release_from_release(release)
d = json.loads(obj.json())
assert obj.ident == release.ident == d["ident"] == "hsmo6p4smrganpb3fndaj2lon4"
assert obj.doi_registrar == "crossref"
assert obj.doi_prefix == "10.7717"
def test_es_biblio_from_release() -> None:
with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4.json", "r") as f:
release = entity_from_json(f.read(), ReleaseEntity)
obj = es_biblio_from_release(release)
d = json.loads(obj.json())
assert (
obj.release_ident
== release.ident
== d["release_ident"]
== "hsmo6p4smrganpb3fndaj2lon4"
)
def test_run_refs() -> None:
with open("tests/files/work_iarm6swodra2bcrzhxrfaah7py_bundle.json", "r") as f:
run_refs(f.readlines())
def test_run_transform() -> None:
with open("tests/files/work_iarm6swodra2bcrzhxrfaah7py_bundle.json", "r") as f:
run_transform(f.readlines())
with open("tests/files/sim_page_bundle.json", "r") as f:
run_transform(f.readlines())
def test_biblio_metadata_hacks() -> None:
biblio = ScholarBiblio(
title="some example paper",
contrib_names=["able seaperson"],
release_year=2000,
volume="10",
issue="5",
publisher="some university",
issns=[],
affiliations=[],
)
out = biblio_metadata_hacks(biblio)
biblio.release_year = 2030
out = biblio_metadata_hacks(biblio)
assert out.release_year == None
biblio.doi_prefix = "10.1101"
biblio.container_name = None
biblio.release_stage = None
biblio.release_type = "post"
out = biblio_metadata_hacks(biblio)
assert out.container_name
assert out.release_stage == "submitted"
assert out.release_type == "article"
|