forked from ip-tools/python-epo-ops-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_helpers.py
More file actions
130 lines (94 loc) · 3.95 KB
/
Copy pathapi_helpers.py
File metadata and controls
130 lines (94 loc) · 3.95 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import re
import requests
from epo_ops.models import Docdb, Epodoc, Original
data = ("publication", Docdb("1000000", "EP", "A1"))
rdata = ("publication", Epodoc("EP1000000"))
idata = ("published-data/images/EP/1000000/A1/fullimage", 1)
# idata path is the result @path from images published-data json request
def find_range(document, pattern):
return re.search("range.*{0}".format(pattern), document)
def assert_request_success(response):
assert response.status_code == requests.codes.ok
assert response.headers["X-API"] == "ops-v3.2"
def assert_family_success(client):
response = client.family(*data)
assert_request_success(response)
assert "patent-family" in response.text
return response
def assert_family_biblio_success(client):
response = client.family(*data, constituents=["biblio"])
assert_request_success(response)
assert "patent-family" in response.text
assert "exchange-document" in response.text
assert "bibliographic-data" in response.text
return response
def assert_family_legal_success(client):
response = client.family(*data, constituents=["legal"])
assert_request_success(response)
assert 'patent-family legal="true"' in response.text
assert "ops:legal" in response.text
return response
def assert_image_success(client):
response = client.image(*idata)
assert_request_success(response)
return response
def assert_legal_success(client):
response = client.legal(*data)
assert_request_success(response)
assert "ops:legal" in response.text
return response
def assert_published_data_success(client):
response = client.published_data(*data)
assert_request_success(response)
assert "bibliographic-data" in response.text
return response
def assert_published_data_search_success(client):
response = client.published_data_search("applicant=IBM")
assert_request_success(response)
assert "biblio-search" in response.text
return response
def assert_published_data_search_with_range_success(client):
response = client.published_data_search("applicant=IBM", 5, 6)
assert find_range(response.text, 'begin="5"')
assert find_range(response.text, 'end="6"')
# Second time to make sure our cache key works properly
response = client.published_data_search("applicant=IBM", 50, 60)
assert_request_success(response)
assert "biblio-search" in response.text
assert find_range(response.text, 'begin="50"')
assert find_range(response.text, 'end="60"')
return response
def assert_register_success(client):
response = client.register(*rdata)
assert_request_success(response)
assert "bibliographic-data" in response.text
return response
def assert_register_search_success(client):
response = client.register_search("applicant=IBM")
assert_request_success(response)
assert "register-documents" in response.text
return response
def assert_register_search_with_range_success(client):
response = client.register_search("applicant=IBM", 5, 6)
assert find_range(response.text, 'begin="5"')
assert find_range(response.text, 'end="6"')
response = client.register_search("applicant=IBM", 50, 60)
assert_request_success(response)
assert "register-documents" in response.text
assert find_range(response.text, 'begin="50"')
assert find_range(response.text, 'end="60"')
return response
def issue_number_request(client, output_format):
return client.number(
"application",
Original("2006-147056", country_code="JP", kind_code="A"),
output_format,
)
def assert_number_service_success(client):
response = issue_number_request(client, "docdb")
assert "ops:standardization" in response.text
return response
def assert_bulk_service_retrival_success(client):
input_list = [Docdb("1000000", "EP", "A1"), Epodoc("US2018265402")]
response = client.published_data("publication", input=input_list)
assert response.status_code == requests.codes.ok