forked from docusign/docusign-esign-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit_tests.py
671 lines (521 loc) · 26.2 KB
/
unit_tests.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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
# coding: utf-8
"""
DocuSign REST API
The DocuSign REST API provides you with a powerful, convenient, and simple Web services API for interacting with DocuSign.
OpenAPI spec version: v2
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import, print_function
import base64
import subprocess
from pprint import pprint
import unittest
import webbrowser
import docusign_esign as docusign
from docusign_esign import AuthenticationApi, EnvelopesApi, TemplatesApi, DiagnosticsApi
from docusign_esign.rest import ApiException
username = "[email protected]"
password = "qweqweasd"
integrator_key = "ae30ea4e-3959-4d1c-b867-fcb57d2dc4df"
BASE_URL = "https://demo.docusign.net/restapi"
sign_test1_file = "test/docs/SignTest1.pdf"
template_id = "cf2a46c2-8d6e-4258-9d62-752547b1a419"
envelope_id = "21009b53-0596-4901-aa06-055ce1799147"
user_id = "fcc5726c-cd73-4844-b580-40bbbe6ca126"
oauth_base_url = "account-d.docusign.com" # use account.docusign.com for Live/Production
redirect_uri = "https://www.docusign.com/api"
private_key_filename = "test/keys/docusign_private_key.txt"
client_secret = "b4dccdbe-232f-46cc-96c5-b2f0f7448f8f"
class SdkUnitTests(unittest.TestCase):
def setUp(self):
self.api_client = docusign.ApiClient(BASE_URL)
# IMPORTANT NOTE:
# the first time you ask for a JWT access token, you should grant access by making the following call
# get DocuSign OAuth authorization url:
oauth_login_url = self.api_client.get_jwt_uri(integrator_key, redirect_uri, oauth_base_url)
# open DocuSign OAuth authorization url in the browser, login and grant access
# webbrowser.open_new_tab(oauth_login_url)
print(oauth_login_url)
# END OF NOTE
# configure the ApiClient to asynchronously get an access to token and store it
self.api_client.configure_jwt_authorization_flow(private_key_filename, oauth_base_url, integrator_key, user_id, 3600)
docusign.configuration.api_client = self.api_client
def tearDown(self):
pass
def testLogin(self):
auth_api = AuthenticationApi()
try:
login_info = auth_api.login(api_password='true', include_account_id_guid='true')
assert login_info is not None
assert len(login_info.login_accounts) > 0
login_accounts = login_info.login_accounts
assert login_accounts[0].account_id is not None
print("LoginInformation: ", end="")
pprint(login_info)
# parse first account's baseUrl
base_url, _ = login_accounts[0].base_url.split('/v2')
# below code required for production, no effect in demo (same domain)
self.api_client.host = base_url
docusign.configuration.api_client = self.api_client
except ApiException as e:
print("\nException when calling DocuSign API: %s" % e)
assert e is None # make the test case fail in case of an API exception
def testOAuthLogin(self):
# create a separate api client for this test case
api_client = docusign.ApiClient(BASE_URL)
# make sure to pass the redirect uri
api_client.configure_authorization_flow(integrator_key, client_secret, redirect_uri)
# get DocuSign OAuth authorization url
oauth_login_url = api_client.get_authorization_uri()
# open DocuSign OAuth login in the browser
print(oauth_login_url)
# webbrowser.open_new_tab(oauth_login_url)
# IMPORTANT NOTE: after the login, DocuSign will send back a fresh authorization code as a query param of the redirect URI.
# You should set up a route that handles the redirect call to get that code and pass it to token endpoint as shown in the next lines:
'''
code = raw_input("Enter the authorization code here:")
api_client.authenticate_with_code(code)
auth_api = AuthenticationApi(api_client)
try:
login_info = auth_api.login(api_password='true', include_account_id_guid='true')
assert login_info is not None
assert len(login_info.login_accounts) > 0
login_accounts = login_info.login_accounts
assert login_accounts[0].account_id is not None
print("LoginInformation: ", end="")
pprint(login_info)
# parse first account's baseUrl
base_url, _ = login_accounts[0].base_url.split('/v2')
# below code required for production, no effect in demo (same domain)
self.api_client.host = base_url
docusign.configuration.api_client = self.api_client
except ApiException as e:
print("\nException when calling DocuSign API: %s" % e)
assert e is None # make the test case fail in case of an API exception
'''
def testRequestASignature(self):
file_contents = open(sign_test1_file, 'rb').read()
# create an envelope to be signed
envelope_definition = docusign.EnvelopeDefinition()
envelope_definition.email_subject = 'Please Sign my Python SDK Envelope'
envelope_definition.email_blurb = 'Hello, Please sign my Python SDK Envelope.'
# add a document to the envelope
doc = docusign.Document()
base64_doc = base64.b64encode(file_contents).decode("utf-8")
doc.document_base64 = base64_doc
doc.name = 'TestFile.pdf'
doc.document_id = '1'
envelope_definition.documents = [doc]
# Add a recipient to sign the document
signer = docusign.Signer()
signer.email = username
signer.name = 'Pat Developer'
signer.recipient_id = '1'
# Create a SignHere tab somewhere on the document for the signer to sign
sign_here = docusign.SignHere()
sign_here.document_id = '1'
sign_here.page_number = '1'
sign_here.recipient_id = '1'
sign_here.x_position = '100'
sign_here.y_position = '100'
sign_here.scale_value = '0.5'
tabs = docusign.Tabs()
tabs.sign_here_tabs = [sign_here]
signer.tabs = tabs
recipients = docusign.Recipients()
recipients.signers = [signer]
envelope_definition.recipients = recipients
envelope_definition.status = 'sent'
auth_api = AuthenticationApi()
envelopes_api = EnvelopesApi()
try:
login_info = auth_api.login(api_password='true', include_account_id_guid='true')
assert login_info is not None
assert len(login_info.login_accounts) > 0
login_accounts = login_info.login_accounts
assert login_accounts[0].account_id is not None
base_url, _ = login_accounts[0].base_url.split('/v2')
self.api_client.host = base_url
docusign.configuration.api_client = self.api_client
envelope_summary = envelopes_api.create_envelope(login_accounts[0].account_id, envelope_definition=envelope_definition)
assert envelope_summary is not None
assert envelope_summary.envelope_id is not None
assert envelope_summary.status == 'sent'
print("EnvelopeSummary: ", end="")
pprint(envelope_summary)
except ApiException as e:
print("\nException when calling DocuSign API: %s" % e)
assert e is None # make the test case fail in case of an API exception
def testRequestSignatureFromTemplate(self):
template_role_name = 'Needs to sign'
# create an envelope to be signed
envelope_definition = docusign.EnvelopeDefinition()
envelope_definition.email_subject = 'Please Sign my Python SDK Envelope'
envelope_definition.email_blurb = 'Hello, Please sign my Python SDK Envelope.'
# assign template information including ID and role(s)
envelope_definition.template_id = template_id
# create a template role with a valid templateId and roleName and assign signer info
t_role = docusign.TemplateRole()
t_role.role_name = template_role_name
t_role.name ='Pat Developer'
t_role.email = username
# create a list of template roles and add our newly created role
# assign template role(s) to the envelope
envelope_definition.template_roles = [t_role]
# send the envelope by setting |status| to "sent". To save as a draft set to "created"
envelope_definition.status = 'sent'
auth_api = AuthenticationApi()
envelopes_api = EnvelopesApi()
try:
login_info = auth_api.login(api_password='true', include_account_id_guid='true')
assert login_info is not None
assert len(login_info.login_accounts) > 0
login_accounts = login_info.login_accounts
assert login_accounts[0].account_id is not None
base_url, _ = login_accounts[0].base_url.split('/v2')
self.api_client.host = base_url
docusign.configuration.api_client = self.api_client
envelope_summary = envelopes_api.create_envelope(login_accounts[0].account_id, envelope_definition=envelope_definition)
assert envelope_summary is not None
assert envelope_summary.envelope_id is not None
assert envelope_summary.status == 'sent'
print("EnvelopeSummary: ", end="")
pprint(envelope_summary)
except ApiException as e:
print("\nException when calling DocuSign API: %s" % e)
assert e is None # make the test case fail in case of an API exception
def testEmbeddedSigning(self):
file_contents = open(sign_test1_file, 'rb').read()
# create an envelope to be signed
envelope_definition = docusign.EnvelopeDefinition()
envelope_definition.email_subject = 'Please Sign my Python SDK Envelope'
envelope_definition.email_blurb = 'Hello, Please sign my Python SDK Envelope.'
# add a document to the envelope
doc = docusign.Document()
base64_doc = base64.b64encode(file_contents).decode("utf-8")
doc.document_base64 = base64_doc
doc.name = 'TestFile.pdf'
doc.document_id = '1'
envelope_definition.documents = [doc]
# Add a recipient to sign the document
signer = docusign.Signer()
signer.email = username
signer.name = 'Pat Developer'
signer.recipient_id = '1'
# this value represents the client's unique identifier for the signer
client_user_id = '2939'
signer.client_user_id = client_user_id
# Create a SignHere tab somewhere on the document for the signer to sign
sign_here = docusign.SignHere()
sign_here.document_id = '1'
sign_here.page_number = '1'
sign_here.recipient_id = '1'
sign_here.x_position = '100'
sign_here.y_position = '100'
sign_here.scale_value = '0.5'
tabs = docusign.Tabs()
tabs.sign_here_tabs = [sign_here]
signer.tabs = tabs
recipients = docusign.Recipients()
recipients.signers = [signer]
envelope_definition.recipients = recipients
envelope_definition.status = 'sent'
auth_api = AuthenticationApi()
envelopes_api = EnvelopesApi()
try:
login_info = auth_api.login()
assert login_info is not None
assert len(login_info.login_accounts) > 0
login_accounts = login_info.login_accounts
assert login_accounts[0].account_id is not None
base_url, _ = login_accounts[0].base_url.split('/v2')
self.api_client.host = base_url
docusign.configuration.api_client = self.api_client
envelope_summary = envelopes_api.create_envelope(login_accounts[0].account_id,
envelope_definition=envelope_definition)
assert envelope_summary is not None
assert envelope_summary.envelope_id is not None
assert envelope_summary.status == 'sent'
print("EnvelopeSummary: ", end="")
pprint(envelope_summary)
return_url = 'http://www.docusign.com/developer-center'
recipient_view_request = docusign.RecipientViewRequest()
recipient_view_request.return_url = return_url
recipient_view_request.client_user_id = client_user_id
recipient_view_request.authentication_method = 'email'
recipient_view_request.user_name = 'Pat Developer'
recipient_view_request.email = username
view_url = envelopes_api.create_recipient_view(login_accounts[0].account_id, envelope_summary.envelope_id, recipient_view_request=recipient_view_request)
assert view_url is not None
assert view_url.url is not None
# This Url should work in an Iframe or browser to allow signing
print("ViewUrl is ", end="")
pprint(view_url)
except ApiException as e:
print("\nException when calling DocuSign API: %s" % e)
assert e is None # make the test case fail in case of an API exception
def testCreateTemplate(self):
file_contents = open(sign_test1_file, 'rb').read()
# create an envelope to be signed
envelope_template = docusign.EnvelopeTemplate()
envelope_template.email_subject = 'Please Sign my Python SDK Envelope (Embedded Signer)'
envelope_template.email_blurb = 'Hello, Please sign my Python SDK Envelope.'
# add a document to the template
doc = docusign.Document()
base64_doc = base64.b64encode(file_contents).decode("utf-8")
doc.document_base64 = base64_doc
doc.name = 'TestFile.pdf'
doc.document_id = '1'
envelope_template.documents = [doc]
# Add a recipient to sign the document
signer = docusign.Signer()
signer.email = username
signer.name = 'Pat Developer'
signer.recipient_id = '1'
# Create a SignHere tab somewhere on the document for the signer to sign
sign_here = docusign.SignHere()
sign_here.document_id = '1'
sign_here.page_number = '1'
sign_here.recipient_id = '1'
sign_here.x_position = '100'
sign_here.y_position = '100'
sign_here.scale_value = '0.5'
tabs = docusign.Tabs()
tabs.sign_here_tabs = [sign_here]
signer.tabs = tabs
recipients = docusign.Recipients()
recipients.signers = [signer]
envelope_template.recipients = recipients
env_template_definition = docusign.EnvelopeTemplateDefinition()
env_template_definition.name = 'myTemplate'
envelope_template.envelope_template_definition = env_template_definition
auth_api = AuthenticationApi()
templates_api = TemplatesApi()
try:
login_info = auth_api.login()
assert login_info is not None
assert len(login_info.login_accounts) > 0
login_accounts = login_info.login_accounts
assert login_accounts[0].account_id is not None
base_url, _ = login_accounts[0].base_url.split('/v2')
self.api_client.host = base_url
docusign.configuration.api_client = self.api_client
template_summary = templates_api.create_template(login_accounts[0].account_id, envelope_template=envelope_template)
assert template_summary is not None
assert template_summary.template_id is not None
print("TemplateSummary: ", end="")
pprint(template_summary)
except ApiException as e:
print("\nException when calling DocuSign API: %s" % e)
assert e is None # make the test case fail in case of an API exception
def testDownLoadEnvelopeDocuments(self):
file_contents = open(sign_test1_file, 'rb').read()
# create an envelope to be signed
envelope_definition = docusign.EnvelopeDefinition()
envelope_definition.email_subject = 'Please Sign my Python SDK Envelope'
envelope_definition.email_blurb = 'Hello, Please sign my Python SDK Envelope.'
# add a document to the envelope
doc = docusign.Document()
base64_doc = base64.b64encode(file_contents).decode("utf-8")
doc.document_base64 = base64_doc
doc.name = 'TestFile.pdf'
doc.document_id = '1'
envelope_definition.documents = [doc]
# Add a recipient to sign the document
signer = docusign.Signer()
signer.email = username
signer.name = 'Pat Developer'
signer.recipient_id = '1'
# this value represents the client's unique identifier for the signer
client_user_id = '2939'
signer.client_user_id = client_user_id
# Create a Text tab somewhere on the document for the signer to sign
text = docusign.Text()
text.document_id = '1'
text.page_number = '1'
text.recipient_id = '1'
text.x_position = '100'
text.y_position = '100'
text.scale_value = '0.5'
tabs = docusign.Tabs()
tabs.text_tabs = [text]
signer.tabs = tabs
recipients = docusign.Recipients()
recipients.signers = [signer]
envelope_definition.recipients = recipients
# send the envelope (otherwise it will be "created" in the Draft folder)
envelope_definition.status = 'sent'
auth_api = AuthenticationApi()
envelopes_api = EnvelopesApi()
try:
login_info = auth_api.login()
assert login_info is not None
assert len(login_info.login_accounts) > 0
login_accounts = login_info.login_accounts
assert login_accounts[0].account_id is not None
base_url, _ = login_accounts[0].base_url.split('/v2')
self.api_client.host = base_url
docusign.configuration.api_client = self.api_client
envelope_summary = envelopes_api.create_envelope(login_accounts[0].account_id, envelope_definition=envelope_definition)
assert envelope_summary is not None
assert envelope_summary.envelope_id is not None
print("EnvelopeSummary: ", end="")
pprint(envelope_summary)
file = envelopes_api.get_document(login_accounts[0].account_id, 'combined', envelope_summary.envelope_id)
assert len(file) > 0
subprocess.call('open ' + file, shell=True)
except ApiException as e:
print("\nException when calling DocuSign API: %s" % e)
assert e is None # make the test case fail in case of an API exception
def testListDocuments(self):
auth_api = AuthenticationApi()
envelopes_api = EnvelopesApi()
try:
login_info = auth_api.login()
assert login_info is not None
assert len(login_info.login_accounts) > 0
login_accounts = login_info.login_accounts
assert login_accounts[0].account_id is not None
base_url, _ = login_accounts[0].base_url.split('/v2')
self.api_client.host = base_url
docusign.configuration.api_client = self.api_client
docs_list = envelopes_api.list_documents(login_accounts[0].account_id, envelope_id)
assert docs_list is not None
assert (docs_list.envelope_id == envelope_id)
print("EnvelopeDocumentsResult: ", end="")
pprint(docs_list)
except ApiException as e:
print("\nException when calling DocuSign API: %s" % e)
assert e is None # make the test case fail in case of an API exception
def testResendEnvelope(self):
file_contents = open(sign_test1_file, 'rb').read()
# create an envelope to be signed
envelope_definition = docusign.EnvelopeDefinition()
envelope_definition.email_subject = 'Please Sign my Python SDK Envelope'
envelope_definition.email_blurb = 'Hello, Please sign my Python SDK Envelope.'
# add a document to the envelope
doc = docusign.Document()
base64_doc = base64.b64encode(file_contents).decode("utf-8")
doc.document_base64 = base64_doc
doc.name = 'TestFile.pdf'
doc.document_id = '1'
envelope_definition.documents = [doc]
# Add a recipient to sign the document
signer = docusign.Signer()
signer.email = username
signer.name = 'Pat Developer'
signer.recipient_id = '1'
# this value represents the client's unique identifier for the signer
client_user_id = '2939'
signer.client_user_id = client_user_id
# Create a SignHere tab somewhere on the document for the signer to sign
sign_here = docusign.SignHere()
sign_here.document_id = '1'
sign_here.page_number = '1'
sign_here.recipient_id = '1'
sign_here.x_position = '100'
sign_here.y_position = '100'
sign_here.scale_value = '0.5'
tabs = docusign.Tabs()
tabs.sign_here_tabs = [sign_here]
signer.tabs = tabs
recipients = docusign.Recipients()
recipients.signers = [signer]
envelope_definition.recipients = recipients
# send the envelope (otherwise it will be "created" in the Draft folder)
envelope_definition.status = 'sent'
auth_api = AuthenticationApi()
envelopes_api = EnvelopesApi()
try:
login_info = auth_api.login()
assert login_info is not None
assert len(login_info.login_accounts) > 0
login_accounts = login_info.login_accounts
assert login_accounts[0].account_id is not None
base_url, _ = login_accounts[0].base_url.split('/v2')
self.api_client.host = base_url
docusign.configuration.api_client = self.api_client
envelope_summary = envelopes_api.create_envelope(login_accounts[0].account_id, envelope_definition=envelope_definition)
assert envelope_summary is not None
assert envelope_summary.envelope_id is not None
print("EnvelopeSummary: ", end="")
pprint(envelope_summary)
recipients_update_summary = envelopes_api.update_recipients(login_accounts[0].account_id, envelope_summary.envelope_id, recipients=recipients, resend_envelope='true')
assert recipients_update_summary is not None
assert len(recipients_update_summary.recipient_update_results) > 0
assert ("SUCCESS" == recipients_update_summary.recipient_update_results[0].error_details.error_code);
print("RecipientsUpdateSummary: ", end="")
pprint(recipients_update_summary)
except ApiException as e:
print("\nException when calling DocuSign API: %s" % e)
assert e is None # make the test case fail in case of an API exception
def testGetDiagnosticLogs(self):
file_contents = open(sign_test1_file, 'rb').read()
# create an envelope to be signed
envelope_definition = docusign.EnvelopeDefinition()
envelope_definition.email_subject = 'Please Sign my Python SDK Envelope'
envelope_definition.email_blurb = 'Hello, Please sign my Python SDK Envelope.'
# add a document to the envelope
doc = docusign.Document()
base64_doc = base64.b64encode(file_contents).decode("utf-8")
doc.document_base64 = base64_doc
doc.name = 'TestFile.pdf'
doc.document_id = '1'
envelope_definition.documents = [doc]
# Add a recipient to sign the document
signer = docusign.Signer()
signer.email = username
signer.name = 'Pat Developer'
signer.recipient_id = '1'
# this value represents the client's unique identifier for the signer
client_user_id = '2939'
signer.client_user_id = client_user_id
# Create a SignHere tab somewhere on the document for the signer to sign
sign_here = docusign.SignHere()
sign_here.document_id = '1'
sign_here.page_number = '1'
sign_here.recipient_id = '1'
sign_here.x_position = '100'
sign_here.y_position = '100'
sign_here.scale_value = '0.5'
tabs = docusign.Tabs()
tabs.sign_here_tabs = [sign_here]
signer.tabs = tabs
recipients = docusign.Recipients()
recipients.signers = [signer]
envelope_definition.recipients = recipients
# send the envelope (otherwise it will be "created" in the Draft folder)
envelope_definition.status = 'sent'
auth_api = AuthenticationApi()
envelopes_api = EnvelopesApi()
diag_api = DiagnosticsApi()
try:
login_info = auth_api.login()
assert login_info is not None
assert len(login_info.login_accounts) > 0
login_accounts = login_info.login_accounts
assert login_accounts[0].account_id is not None
base_url, _ = login_accounts[0].base_url.split('/v2')
self.api_client.host = base_url
docusign.configuration.api_client = self.api_client
diagnostics_settings_information = docusign.DiagnosticsSettingsInformation()
diagnostics_settings_information.api_request_logging = 'true'
diag_api.update_request_log_settings(diagnostics_settings_information=diagnostics_settings_information)
envelope_summary = envelopes_api.create_envelope(login_accounts[0].account_id, envelope_definition=envelope_definition)
assert envelope_summary is not None
assert envelope_summary.envelope_id is not None
print("EnvelopeSummary: ", end="")
pprint(envelope_summary)
file1 = envelopes_api.get_document(login_accounts[0].account_id, 'combined', envelope_summary.envelope_id)
assert len(file1) > 0
subprocess.call('open ' + file1, shell=True)
logsList = diag_api.list_request_logs()
request_log_id = logsList.api_request_logs[0].request_log_id
file2 = diag_api.get_request_log(request_log_id)
assert len(file2) > 0
subprocess.call('open ' + file2, shell=True)
except ApiException as e:
print("\nException when calling DocuSign API: %s" % e)
assert e is None # make the test case fail in case of an API exception
if __name__ == '__main__':
unittest.main()