-
Notifications
You must be signed in to change notification settings - Fork 16
/
article_doajxml.py
99 lines (74 loc) · 3.26 KB
/
article_doajxml.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import os
from io import BytesIO, StringIO
from lxml import etree
from doajtest import test_constants
ARTICLES = test_constants.PATH_RESOURCES / "doajxml_article_uploads.xml"
class DoajXmlArticleFixtureFactory(object):
@classmethod
def _response_from_xpath(cls, xpath):
with open(ARTICLES) as f:
doc = etree.parse(f)
records = doc.getroot()
articles = records.xpath(xpath)
nr = etree.Element("records")
for a in articles:
nr.append(a)
out = etree.tostring(nr, encoding="UTF-8", xml_declaration=True)
return BytesIO(out)
@classmethod
def upload_2_issns_correct(cls):
return cls._response_from_xpath("//record[journalTitle='2 ISSNs Correct']")
@classmethod
def upload_2_issns_ambiguous(cls):
return cls._response_from_xpath("//record[journalTitle='2 ISSNs Ambiguous']")
@classmethod
def upload_1_issn_correct(cls):
return cls._response_from_xpath("//record[journalTitle='PISSN Correct']")
@classmethod
def upload_no_issns(cls):
return cls._response_from_xpath("//record[journalTitle='No issns']")
@classmethod
def upload_author_email_address(cls):
return cls._response_from_xpath("//record[journalTitle='author email address']")
@classmethod
def upload_1_issn_superlong_should_not_clip(cls):
return cls._response_from_xpath("//record[journalTitle='PISSN Correct Superlong Abstract Expected to Not be Clipped']")
@classmethod
def upload_1_issn_superlong_should_clip(cls):
return cls._response_from_xpath("//record[journalTitle='PISSN Correct Superlong Abstract Expected to be Clipped']")
@classmethod
def invalid_schema_xml(cls):
return StringIO("<this><isnot my='schema'></isnot></this>")
@classmethod
def noids(cls):
return cls._response_from_xpath("//record[journalTitle='NOIDS']")
@classmethod
def valid_url_http(cls):
return cls._response_from_xpath("//record[journalTitle='Url starting with http']")
@classmethod
def valid_url_https(cls):
return cls._response_from_xpath("//record[journalTitle='Url starting with https']")
@classmethod
def valid_url_non_ascii_chars(cls):
return cls._response_from_xpath("//record[journalTitle='Url containing non-ascii characters']")
@classmethod
def invalid_url(cls):
return cls._response_from_xpath("//record[journalTitle='Invalid url']")
@classmethod
def invalid_url_http_missing(cls):
return cls._response_from_xpath("//record[journalTitle='Url with http missing']")
@classmethod
def valid_url_http_anchor(cls):
return cls._response_from_xpath("//record[journalTitle='Url with http anchor']")
@classmethod
def valid_url_parameters(cls):
return cls._response_from_xpath("//record[journalTitle='Url with parameters']")
@classmethod
def valid_orcid_id(cls):
return cls._response_from_xpath("//record[journalTitle='With valid orcid_id']")
@classmethod
def invalid_orcid_id(cls):
return cls._response_from_xpath("//record[journalTitle='With invalid orcid_id']")
@classmethod
def upload_the_same_issns(cls):
return cls._response_from_xpath("//record[journalTitle='2 The Same ISSNs']")