blob: 9dfe94f6ae94142e09f9dda7ed145d01136e5c1a (
plain)
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
|
import json
import pytest
from fixtures import *
def test_release_bibtex(app, api):
# "realistic" demo entity
rv = app.get("/release/aaaaaaaaaaaaarceaaaaaaaaam")
assert rv.status_code == 200
assert b"BibTeX" in rv.data
rv = app.get("/release/aaaaaaaaaaaaarceaaaaaaaaam.bib")
assert rv.status_code == 200
assert b"@article{" in rv.data
rv = app.get("/release/ccccccccccccccccccccccccca.bib")
assert rv.status_code == 404
rv = app.get("/release/aaaaaaaaaaaaarceaaaaaaaaam/citeproc?style=bibtex")
assert rv.status_code == 200
rv = app.get("/release/aaaaaaaaaaaaarceaaaaaaaaam/citeproc?style=csl-json")
assert rv.status_code == 200
# could also rv.get_json() here
json.loads(rv.data.decode("utf-8"))
rv = app.get(
"/release/aaaaaaaaaaaaarceaaaaaaaaam/citeproc?style=modern-language-association"
)
assert rv.status_code == 200
assert rv.data.decode("utf-8").startswith(
"Ioannidis, J.. Why Most Published Research Findings Are False"
)
# "dummy" demo entity; very minimal metadata
rv = app.get("/release/aaaaaaaaaaaaarceaaaaaaaaai")
assert rv.status_code == 200
assert b"BibTeX" in rv.data
rv = app.get("/release/aaaaaaaaaaaaarceaaaaaaaaai.bib")
assert rv.status_code == 200
rv = app.get(
"/release/aaaaaaaaaaaaarceaaaaaaaaai/citeproc?style=modern-language-association"
)
assert rv.status_code == 200
rv = app.get("/release/aaaaaaaaaaaaarceaaaaaaaaai/citeproc?style=csl-json")
assert rv.status_code == 200
# create release which can not have citeproc run on it (no authors)
eg = quick_eg(api)
r1 = ReleaseEntity(
title="some title",
ext_ids=ReleaseExtIds(),
)
r1edit = api.create_release(eg.editgroup_id, r1)
api.accept_editgroup(eg.editgroup_id)
rv = app.get("/release/{}".format(r1edit.ident))
assert rv.status_code == 200
assert b"BibTeX" not in rv.data
rv = app.get("/release/{}.bib".format(r1edit.ident))
assert rv.status_code == 400
# create release can have citeproc run on it (no authors)
eg = quick_eg(api)
r2 = ReleaseEntity(
title="some title again",
contribs=[
ReleaseContrib(given_name="Paul", surname="Otlet"),
],
ext_ids=ReleaseExtIds(),
)
r2edit = api.create_release(eg.editgroup_id, r2)
api.accept_editgroup(eg.editgroup_id)
rv = app.get("/release/{}".format(r2edit.ident))
assert rv.status_code == 200
assert b"BibTeX" in rv.data
rv = app.get("/release/{}.bib".format(r2edit.ident))
assert rv.status_code == 200
|