Skip to content

Commit ae5b8c4

Browse files
committed
Test unit cases and Format with black
1 parent 12874aa commit ae5b8c4

2 files changed

Lines changed: 81 additions & 3 deletions

File tree

tests/test_client.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,79 @@ def test_process_document_url():
194194
boost_mode=True,
195195
)
196196
assert d == mock
197+
198+
199+
@responses.activate
200+
def test_process_w9_document_url():
201+
mock = {
202+
"account_numbers": "",
203+
"address1": "28 E 3rd Ave, Suite 201",
204+
"address2": "San Mateo, California, 94401",
205+
"business_name": "",
206+
"c_corp": 0,
207+
"ein": "",
208+
"exempt_payee_code": "",
209+
"exemption": "",
210+
"individual": 0,
211+
"llc": 0,
212+
"name": "Veryfi, Inc.",
213+
"other": 0,
214+
"other_description": "",
215+
"partnership": 0,
216+
"pdf_url": "https://scdn.veryfi.com/w9s/ec278ba0-31d6-4bd4-9d18-cb6a1232788e/output-1.pdf?Expires=1653031170&Signature=bftl34pf~Yni3ysaauqwL4BkfzgMPdAwMpw-SkjKZaxkgSt2~EYmX7NK~BGZ5IFUNdUIGBxTIsBsVWrP8LDQ3fME3kFM6qSn-udZp9Y8WJ-HbqQrIf1DwZQp-A2NSBCkRWgqAtYJo5dQW~UJJdCJx19ZIaYQZzYVQvuHmornzBStTV6D2qXQKUZpv9d5BrvTExZDnIxKy-ibyy09CfUPMc-lsVQLQEb-uQvud-JTf9Guy6k9Y4oT32HSvKcL0pMLvJqYC6mJUM2-5MJiBsYQSNs2e6s8xXcSBotiChMQwBg3RhGv5y-o8Aih1GNmBcvPHJIEyKOuiHeC9TUSELvp~w__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ",
217+
"requester": "AcMe Corporation 1010 Elm Str,\nMountain View, CA 94043",
218+
"s_corp": 1,
219+
"signature": 1,
220+
"signature_date": "June 19, 2020",
221+
"ssn": "",
222+
"trust_estate": 0,
223+
}
224+
225+
client = Client(client_id="v", client_secret="w", username="o", api_key="c")
226+
responses.add(
227+
responses.POST,
228+
f"{client.versioned_url}/partner/w9s/",
229+
json=mock,
230+
status=200,
231+
)
232+
d = client.process_w9_document_url(
233+
file_url="http://cdn-dev.veryfi.com/testing/veryfi-python/receipt_public.jpg",
234+
)
235+
assert d == mock
236+
237+
238+
@responses.activate
239+
def test_process_w9_document():
240+
mock = {
241+
"account_numbers": "",
242+
"address1": "28 E 3rd Ave, Suite 201",
243+
"address2": "San Mateo, California, 94401",
244+
"business_name": "",
245+
"c_corp": 0,
246+
"ein": "",
247+
"exempt_payee_code": "",
248+
"exemption": "",
249+
"individual": 0,
250+
"llc": 0,
251+
"name": "Veryfi, Inc.",
252+
"other": 0,
253+
"other_description": "",
254+
"partnership": 0,
255+
"pdf_url": "https://scdn.veryfi.com/w9s/ec278ba0-31d6-4bd4-9d18-cb6a1232788e/output-1.pdf?Expires=1653031170&Signature=bftl34pf~Yni3ysaauqwL4BkfzgMPdAwMpw-SkjKZaxkgSt2~EYmX7NK~BGZ5IFUNdUIGBxTIsBsVWrP8LDQ3fME3kFM6qSn-udZp9Y8WJ-HbqQrIf1DwZQp-A2NSBCkRWgqAtYJo5dQW~UJJdCJx19ZIaYQZzYVQvuHmornzBStTV6D2qXQKUZpv9d5BrvTExZDnIxKy-ibyy09CfUPMc-lsVQLQEb-uQvud-JTf9Guy6k9Y4oT32HSvKcL0pMLvJqYC6mJUM2-5MJiBsYQSNs2e6s8xXcSBotiChMQwBg3RhGv5y-o8Aih1GNmBcvPHJIEyKOuiHeC9TUSELvp~w__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ",
256+
"requester": "AcMe Corporation 1010 Elm Str,\nMountain View, CA 94043",
257+
"s_corp": 1,
258+
"signature": 1,
259+
"signature_date": "June 19, 2020",
260+
"ssn": "",
261+
"trust_estate": 0,
262+
}
263+
264+
client = Client(client_id="v", client_secret="w", username="o", api_key="c")
265+
responses.add(
266+
responses.POST,
267+
f"{client.versioned_url}/partner/w9s/",
268+
json=mock,
269+
status=200,
270+
)
271+
d = client.process_w9_document(file_path="tests/assets/receipt_public.jpg")
272+
assert d == mock

veryfi/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ def process_document_url(
215215
request_arguments.update(kwargs)
216216
return self._request("POST", endpoint_name, request_arguments)
217217

218-
def process_w9_document_url(self, file_url: str, file_name: Optional[str] = None, **kwargs: Dict) -> Dict:
218+
def process_w9_document_url(
219+
self, file_url: str, file_name: Optional[str] = None, **kwargs: Dict
220+
) -> Dict:
219221
"""
220222
Process W9 Document from url and extract all the fields from it.
221223
@@ -229,8 +231,8 @@ def process_w9_document_url(self, file_url: str, file_name: Optional[str] = None
229231
file_name = os.path.basename(file_url)
230232
endpoint_name = "/w9s/"
231233
request_arguments = {
232-
'file_name': file_name,
233-
'file_url': file_url,
234+
"file_name": file_name,
235+
"file_url": file_url,
234236
}
235237
request_arguments.update(kwargs)
236238
return self._request("POST", endpoint_name, request_arguments)

0 commit comments

Comments
 (0)