-
Notifications
You must be signed in to change notification settings - Fork 16
/
model_Article.py
36 lines (28 loc) · 1.13 KB
/
model_Article.py
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
from doajtest.fixtures import JournalFixtureFactory
from portality.models import Journal
class ModelArticleMockFactory(object):
@classmethod
def get_journal(cls, specs, in_doaj=True):
journals = []
for spec in specs:
source = JournalFixtureFactory.make_journal_source(in_doaj=in_doaj)
j = Journal(**source)
bj = j.bibjson()
bj.title = spec.get("title", "Journal Title")
del bj.eissn
del bj.pissn
if "pissn" in spec:
bj.add_identifier(bj.P_ISSN, spec.get("pissn"))
if "eissn" in spec:
bj.add_identifier(bj.E_ISSN, spec.get("eissn"))
spec["instance"] = j
journals.append(spec)
def mock(self):
bibjson = self.bibjson()
# first, get the ISSNs associated with the record
pissns = bibjson.get_identifiers(bibjson.P_ISSN)
eissns = bibjson.get_identifiers(bibjson.E_ISSN)
for j in journals:
if j["pissn"] in pissns and j["eissn"] in eissns:
return j["instance"]
return mock