patentscope 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,220 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Patentscope
4
-
5
- describe PctPubNumber, :core do
6
-
7
- let(:pct_pub_number) { PctPubNumber.new }
8
-
9
- describe "methods" do
10
- it "has the right methods" do
11
- expect(pct_pub_number).to respond_to(:valid?)
12
- expect(pct_pub_number).to respond_to(:validate)
13
- end
14
- end
15
-
16
- describe "valid? validate methods" do
17
-
18
- describe "publication numbers in acceptable format" do
19
-
20
- describe "prefix, year and number run on" do
21
- let(:pct_pub_number) { PctPubNumber.new('WO2009105044') }
22
-
23
- it "is valid" do
24
- expect(pct_pub_number).to be_valid
25
- end
26
-
27
- it "validates" do
28
- expect { pct_pub_number.validate }.to_not raise_error
29
- end
30
- end
31
-
32
- describe "year and number separated by a slash" do
33
- let(:pct_pub_number) { PctPubNumber.new('WO2009/105044') }
34
-
35
- it "is valid" do
36
- expect(pct_pub_number).to be_valid
37
- end
38
-
39
- it "validates" do
40
- expect { pct_pub_number.validate }.to_not raise_error
41
- end
42
- end
43
-
44
- describe "prefix and year and year and number separated by slashes" do
45
- let(:pct_pub_number) { PctPubNumber.new('WO/2009/105044') }
46
-
47
- it "is valid" do
48
- expect(pct_pub_number).to be_valid
49
- end
50
-
51
- it "validates" do
52
- expect { pct_pub_number.validate }.to_not raise_error
53
- end
54
- end
55
-
56
- describe "leading space before application number" do
57
- let(:pct_pub_number) { PctPubNumber.new(' WO2009105044') }
58
-
59
- it "is valid" do
60
- expect(pct_pub_number).to be_valid
61
- end
62
-
63
- it "validates" do
64
- expect { pct_pub_number.validate }.to_not raise_error
65
- end
66
- end
67
-
68
- describe "trailing space after application number" do
69
- let(:pct_pub_number) { PctPubNumber.new('WO2009105044 ') }
70
-
71
- it "is valid" do
72
- expect(pct_pub_number).to be_valid
73
- end
74
-
75
- it "validates" do
76
- expect { pct_pub_number.validate }.to_not raise_error
77
- end
78
- end
79
-
80
- describe "non-existent applications" do
81
- let(:pct_pub_number) { PctPubNumber.new('WO2009999999') }
82
-
83
- it "is valid even when application doesn't exist" do
84
- expect(pct_pub_number).to be_valid
85
- end
86
-
87
- it "validates" do
88
- expect { pct_pub_number.validate }.to_not raise_error
89
- end
90
- end
91
-
92
- describe "space before year, no slash" do
93
- let(:pct_pub_number) { PctPubNumber.new('WO 2009105044') }
94
-
95
- it "is valid" do
96
- expect(pct_pub_number).to be_valid
97
- end
98
-
99
- it "does validates" do
100
- expect { pct_pub_number.validate }.to_not raise_error
101
- end
102
- end
103
-
104
- describe "space before year, with slash" do
105
- let(:pct_pub_number) { PctPubNumber.new('WO 2009/105044') }
106
-
107
- it "is valid" do
108
- expect(pct_pub_number).to be_valid
109
- end
110
-
111
- it "does validates" do
112
- expect { pct_pub_number.validate }.to_not raise_error
113
- end
114
- end
115
-
116
- describe "lowercase" do
117
- let(:pct_pub_number) { PctPubNumber.new('wo 2009/105044') }
118
-
119
- it "is valid" do
120
- expect(pct_pub_number).to be_valid
121
- end
122
-
123
- it "does validates" do
124
- expect { pct_pub_number.validate }.to_not raise_error
125
- end
126
- end
127
-
128
- describe "mixed case" do
129
- let(:pct_pub_number) { PctPubNumber.new('wO 2009/105044') }
130
-
131
- it "is valid" do
132
- expect(pct_pub_number).to be_valid
133
- end
134
-
135
- it "does validates" do
136
- expect { pct_pub_number.validate }.to_not raise_error
137
- end
138
- end
139
- end
140
-
141
- describe "publication numbers not in acceptable format" do
142
-
143
- describe "no application number" do
144
- let(:pct_pub_number) { PctPubNumber.new('') }
145
-
146
- it "is not valid" do
147
- expect(pct_pub_number).to_not be_valid
148
- end
149
-
150
- it "does not validate" do
151
- expect { pct_pub_number.validate }.to raise_error
152
- end
153
- end
154
-
155
- describe "blank application number" do
156
- let(:pct_pub_number) { PctPubNumber.new(' ') }
157
-
158
- it "is not valid" do
159
- expect(pct_pub_number).to_not be_valid
160
- end
161
-
162
- it "does not validate" do
163
- expect { pct_pub_number.validate }.to raise_error
164
- end
165
- end
166
-
167
- describe "incorrectly formatted application numbers" do
168
-
169
- describe "application number is too short" do
170
- let(:pct_pub_number) { PctPubNumber.new('WO200910504') }
171
-
172
- it "is not valid" do
173
- expect(pct_pub_number).to_not be_valid
174
- end
175
-
176
- it "does not validate" do
177
- expect { pct_pub_number.validate }.to raise_error
178
- end
179
- end
180
-
181
- describe "application number is too long" do
182
- let(:pct_pub_number) { PctPubNumber.new('WO20091050449') }
183
-
184
- it "is not valid" do
185
- expect(pct_pub_number).to_not be_valid
186
- end
187
-
188
- it "does not validate" do
189
- expect { pct_pub_number.validate }.to raise_error
190
- end
191
- end
192
-
193
- describe "application number contains non-digits" do
194
- let(:pct_pub_number) { PctPubNumber.new('WO2009A05044') }
195
-
196
- it "is not valid" do
197
- expect(pct_pub_number).to_not be_valid
198
- end
199
-
200
- it "does not validate" do
201
- expect { pct_pub_number.validate }.to raise_error
202
- end
203
- end
204
-
205
- describe "application number has too many slashes" do
206
- let(:pct_pub_number) { PctPubNumber.new('WO//2009/105044') }
207
-
208
- it "is not valid" do
209
- expect(pct_pub_number).to_not be_valid
210
- end
211
-
212
- it "does not validate" do
213
- expect { pct_pub_number.validate }.to raise_error
214
- end
215
- end
216
- end
217
- end
218
- end
219
- end
220
- end
@@ -1,31 +0,0 @@
1
- require 'bundler'
2
- Bundler.setup(:default, :development)
3
-
4
- require 'dotenv'
5
- Dotenv.load
6
- require 'patentscope'
7
- require 'rspec'
8
- require 'vcr'
9
- require 'yaml'
10
- require 'open-uri'
11
-
12
- # generate versions of username and password with unsafe characters encoded
13
- unsafe_characters = %q[$&+,/:;=?!@ "'<>#%{}|\^~[]`]
14
- escaped_patentscope_webservice_username = URI::escape(ENV['PATENTSCOPE_WEBSERVICE_USERNAME'], unsafe_characters)
15
- escaped_patentscope_webservice_password = URI::escape(ENV['PATENTSCOPE_WEBSERVICE_PASSWORD'], unsafe_characters)
16
-
17
- VCR.configure do |config|
18
- config.cassette_library_dir = 'spec/cassettes'
19
- config.hook_into :webmock
20
- config.default_cassette_options = { record: :new_episodes }
21
- config.default_cassette_options = { match_requests_on: [:body] }
22
- config.configure_rspec_metadata!
23
- config.allow_http_connections_when_no_cassette = true
24
- config.filter_sensitive_data('*****') { escaped_patentscope_webservice_username }
25
- config.filter_sensitive_data('*****') { escaped_patentscope_webservice_password }
26
- end
27
-
28
- RSpec.configure do |config|
29
- # config.treat_symbols_as_metadata_keys_with_true_values = true
30
- config.order = 'random'
31
- end
@@ -1,318 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Patentscope
4
-
5
- describe WebserviceSoapBuilder, :core do
6
- before { Patentscope.configure_from_env}
7
-
8
- let(:ws_soap_builder) { WebserviceSoapBuilder.new }
9
-
10
- it "exists" do
11
- expect(ws_soap_builder).to_not be_nil
12
- end
13
-
14
- it "has the right methods" do
15
- expect(ws_soap_builder).to respond_to(:build_envelope)
16
- expect(ws_soap_builder).to respond_to(:strip_envelope)
17
- end
18
-
19
- describe "build_envelope method" do
20
- let(:envelope) { ws_soap_builder.build_envelope('foo', {bar: 'baz'}) }
21
-
22
- it "returns an XML document" do
23
- expect(envelope).to include('<?xml')
24
- end
25
-
26
- it "has an envelope element" do
27
- expect(envelope).to include('<S:Envelope')
28
- end
29
-
30
- it "has a namespace definition for the envelope" do
31
- expect(envelope).to include('xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"')
32
- end
33
-
34
- it "has a body element" do
35
- expect(envelope).to include('<S:Body>')
36
- end
37
-
38
- it "has an operation element" do
39
- expect(envelope).to include('<foo ')
40
- end
41
-
42
- it "has a namespace definition for the operation" do
43
- expect(envelope).to include('xmlns="http://www.wipo.org/wsdl/ps"')
44
- end
45
-
46
- it "has a option key element" do
47
- expect(envelope).to include('<bar>')
48
- end
49
-
50
- it "has an option value element" do
51
- expect(envelope).to include('baz')
52
- end
53
-
54
- describe "specific operations" do
55
-
56
- context "get_available_documents" do
57
-
58
- it 'generates an appropriate soap envelope' do
59
- envelope = ws_soap_builder.build_envelope(:getAvailableDocuments, { iaNumber: 'SG2009000062' })
60
- expect(envelope).to include('<?xml version="1.0"')
61
- expect(envelope).to include('<getAvailableDocuments ')
62
- expect(envelope).to include('<iaNumber>SG2009000062</iaNumber')
63
- end
64
- end
65
-
66
- context "get_document_content" do
67
-
68
- it 'generates an appropriate soap envelope' do
69
- envelope = ws_soap_builder.build_envelope(:getDocumentContent, { docId: 'id50000000125222' })
70
- expect(envelope).to include('<?xml version="1.0"')
71
- expect(envelope).to include('<getDocumentContent ')
72
- expect(envelope).to include('<docId>id50000000125222</docId>')
73
- end
74
- end
75
-
76
- context "get_document_ocr_content" do
77
-
78
- it 'generates an appropriate soap envelope' do
79
- envelope = ws_soap_builder.build_envelope(:getDocumentOcrContent, { docId: 'id50000000125222' })
80
- expect(envelope).to include('<?xml version="1.0"')
81
- expect(envelope).to include('<getDocumentOcrContent ')
82
- expect(envelope).to include('<docId>id50000000125222</docId>')
83
- end
84
- end
85
-
86
- context "get_iasr" do
87
-
88
- it 'generates an appropriate soap envelope' do
89
- envelope = ws_soap_builder.build_envelope(:getIASR, { iaNumber: 'SG2009000062' })
90
- expect(envelope).to include('<?xml version="1.0"')
91
- expect(envelope).to include('<getIASR ')
92
- expect(envelope).to include('<iaNumber>SG2009000062</iaNumber')
93
- end
94
- end
95
-
96
- context "get_document_table_of_contents" do
97
-
98
- it 'generates an appropriate soap envelope' do
99
- envelope = ws_soap_builder.build_envelope(:getDocumentTableOfContents, { docId: 'id50000000125222' })
100
- expect(envelope).to include('<?xml version="1.0"')
101
- expect(envelope).to include('<getDocumentTableOfContents ')
102
- expect(envelope).to include('<docId>id50000000125222</docId>')
103
- end
104
- end
105
-
106
- context "get_document_content_page" do
107
-
108
- it 'generates an appropriate soap envelope' do
109
- envelope = ws_soap_builder.build_envelope(:getDocumentContentPage, { docId: 'id50000000125222', pageId: '000031.tif' })
110
- expect(envelope).to include('<?xml version="1.0"')
111
- expect(envelope).to include('<getDocumentContentPage ')
112
- expect(envelope).to include('<docId>id50000000125222</docId>')
113
- expect(envelope).to include('<pageId>000031.tif</pageId>')
114
- end
115
- end
116
- end
117
- end
118
-
119
- describe "strip_envelope method" do
120
-
121
- context "getAvailableDocuments operation" do
122
- let(:envelope) { '<?xml version="1.0" ?>
123
- <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
124
- <S:Body>
125
- <getAvailableDocumentsResponse xmlns="http://www.wipo.org/wsdl/ps">
126
- <doc gazette="35/2006" docType="PAMPH" docId="id50000000162179"></doc>
127
- <doc docType="WOSA" docId="id50000000125420"></doc>
128
- <doc docType="ETIP1" docId="id50000000329130"></doc>
129
- <doc priorityNumber="10 2005 008 395.1" docType="PDOC" docId="id50000000116310"></doc> <doc docType="IB304" docId="id50000000116985"></doc>
130
- <doc docType="ETWOS" docId="id50000000325635">
131
- </doc>
132
- </getAvailableDocumentsResponse>
133
- </S:Body></S:Envelope>' }
134
- let(:stripped) { ws_soap_builder.strip_envelope(envelope, :getAvailableDocuments) }
135
-
136
- it "retains the xml declaration" do
137
- expect(stripped).to include('<?xml')
138
- end
139
-
140
- it "strips the Envelope element" do
141
- expect(stripped).to_not include('<S:Envelope')
142
- end
143
-
144
- it "strips the Body element" do
145
- expect(stripped).to_not include('<S:Body>')
146
- end
147
-
148
- it "strips the getAvailableDocumentsResponse element" do
149
- expect(stripped).to_not include('<getAvailableDocumentsResponse xmlns="http://www.wipo.org/wsdl/ps">')
150
- end
151
-
152
- it "retains the inner elements" do
153
- expect(stripped).to include('<doc gazette="35/2006" docType="PAMPH" docId="id50000000162179"/>')
154
- end
155
- end
156
-
157
- context "getDocumentContent operation" do
158
- let(:envelope) { '<?xml version="1.0" encoding="utf-8"?>
159
- <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
160
- <S:Body>
161
- <getDocumentContentResponse xmlns="http://www.wipo.org/wsdl/ps">
162
- <documentContent>UEsDBBQACAAIAIyMOy0AAAAAAAAAAAAAAAAKAAAAMDAwMDA...AAAAAA=</documentContent>
163
- </getDocumentContentResponse>
164
- </S:Body>
165
- </S:Envelope>' }
166
- let(:stripped) { ws_soap_builder.strip_envelope(envelope, :getDocumentContent) }
167
-
168
- it "retains the xml declaration" do
169
- expect(stripped).to include('<?xml')
170
- end
171
-
172
- it "strips the Envelope element" do
173
- expect(stripped).to_not include('<S:Envelope')
174
- end
175
-
176
- it "strips the Body element" do
177
- expect(stripped).to_not include('<S:Body>')
178
- end
179
-
180
- it "strips the getDocumentContentResponse element" do
181
- expect(stripped).to_not include('<getDocumentContentResponse xmlns="http://www.wipo.org/wsdl/ps">')
182
- end
183
-
184
- it "retains the inner elements" do
185
- expect(stripped).to include('<documentContent>UEsDBBQACAAIAIyMOy0AAAAAAAAAAAAAAAAKAAAAMDAwMDA...AAAAAA=</documentContent>')
186
- end
187
- end
188
-
189
- context "getDocumentOcrContent operation" do
190
- let(:envelope) { '<?xml version="1.0" encoding="utf-8"?>
191
- <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
192
- <S:Body>
193
- <getDocumentOcrContentResponse xmlns="http://www.wipo.org/wsdl/ps">
194
- <documentContent>JVBERi0xLjQKJeLjz9MKOCAwIG9iago8P...DUKJSVFT0YK</documentContent>
195
- </getDocumentOcrContentResponse>
196
- </S:Body>
197
- </S:Envelope>' }
198
- let(:stripped) { ws_soap_builder.strip_envelope(envelope, :getDocumentOcrContent) }
199
-
200
- it "retains the xml declaration" do
201
- expect(stripped).to include('<?xml')
202
- end
203
-
204
- it "strips the Envelope element" do
205
- expect(stripped).to_not include('<S:Envelope')
206
- end
207
-
208
- it "strips the Body element" do
209
- expect(stripped).to_not include('<S:Body>')
210
- end
211
-
212
- it "strips the getDocumentOcrContentResponse element" do
213
- expect(stripped).to_not include('<getDocumentOcrContentResponse xmlns="http://www.wipo.org/wsdl/ps">')
214
- end
215
-
216
- it "retains the inner elements" do
217
- expect(stripped).to include('<documentContent>JVBERi0xLjQKJeLjz9MKOCAwIG9iago8P...DUKJSVFT0YK</documentContent>')
218
- end
219
- end
220
-
221
- context "getIASR operation" do
222
- let(:envelope) { '<?xml version="1.0" encoding="utf-8"?>
223
- <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
224
- <S:Body>
225
- <getIASRResponse xmlns="http://www.wipo.org/wsdl/ps">
226
- <wo-international-application-status>baz</wo-international-application-status>
227
- </getIASRResponse>
228
- </S:Body>
229
- </S:Envelope>' }
230
- let(:stripped) { ws_soap_builder.strip_envelope(envelope, :getIASR) }
231
-
232
- it "retains the xml declaration" do
233
- expect(stripped).to include('<?xml')
234
- end
235
-
236
- it "strips the Envelope element" do
237
- expect(stripped).to_not include('<S:Envelope')
238
- end
239
-
240
- it "strips the Body element" do
241
- expect(stripped).to_not include('<S:Body>')
242
- end
243
-
244
- it "strips the getIASRResponse element" do
245
- expect(stripped).to_not include('<getIASRResponse xmlns="http://www.wipo.org/wsdl/ps">')
246
- end
247
-
248
- it "retains the inner elements" do
249
- expect(stripped).to include('<wo-international-application-status>baz</wo-international-application-status>')
250
- end
251
- end
252
-
253
- context "getDocumentTableOfContents operation" do
254
- let(:envelope) { '<?xml version=\'1.0\' encoding=\'UTF-8\'?>
255
- <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
256
- <S:Body>
257
- <getDocumentTableOfContentsResponse xmlns="http://www.wipo.org/wsdl/ps">
258
- <content>000001.tif</content>
259
- </getDocumentTableOfContentsResponse>
260
- </S:Body>
261
- </S:Envelope>' }
262
- let(:stripped) { ws_soap_builder.strip_envelope(envelope, :getDocumentTableOfContents) }
263
-
264
- it "retains the xml declaration" do
265
- expect(stripped).to include('<?xml')
266
- end
267
-
268
- it "strips the Envelope element" do
269
- expect(stripped).to_not include('<S:Envelope')
270
- end
271
-
272
- it "strips the Body element" do
273
- expect(stripped).to_not include('<S:Body>')
274
- end
275
-
276
- it "strips the getDocumentTableOfContentsResponse element" do
277
- expect(stripped).to_not include('<getDocumentTableOfContentsResponse xmlns="http://www.wipo.org/wsdl/ps">')
278
- end
279
-
280
- it "retains the inner elements" do
281
- expect(stripped).to include('<content>000001.tif</content>')
282
- end
283
- end
284
-
285
- context "getDocumentContentPage operation" do
286
- let(:envelope) { '<?xml version="1.0" encoding="utf-8"?>
287
- <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
288
- <S:Body>
289
- <getDocumentContentPageResponse xmlns="http://www.wipo.org/wsdl/ps">
290
- <pageContent>SUkqAAgAAAASAP4ABAABAAAAAAAAAAABAwABAAAAqwk...//wAQAQAQAQ==</pageContent>
291
- </getDocumentContentPageResponse>
292
- </S:Body>
293
- </S:Envelope>' }
294
- let(:stripped) { ws_soap_builder.strip_envelope(envelope, :getDocumentContentPage) }
295
-
296
- it "retains the xml declaration" do
297
- expect(stripped).to include('<?xml')
298
- end
299
-
300
- it "strips the Envelope element" do
301
- expect(stripped).to_not include('<S:Envelope')
302
- end
303
-
304
- it "strips the Body element" do
305
- expect(stripped).to_not include('<S:Body>')
306
- end
307
-
308
- it "strips the getDocumentContentPageResponse element" do
309
- expect(stripped).to_not include('<getDocumentContentPageResponse xmlns="http://www.wipo.org/wsdl/ps">')
310
- end
311
-
312
- it "retains the inner elements" do
313
- expect(stripped).to include('<pageContent>SUkqAAgAAAASAP4ABAABAAAAAAAAAAABAwABAAAAqwk...//wAQAQAQAQ==</pageContent>')
314
- end
315
- end
316
- end
317
- end
318
- end