From a47673134e6ff765e80835e3cd560c7b48db097f Mon Sep 17 00:00:00 2001 From: Oleg Liubimov Date: Thu, 21 Oct 2021 12:10:14 +0300 Subject: [PATCH 01/10] Added .env to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d14f5c50..0c6c44b0 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,4 @@ target/ # Local files *.DS_Store +.env From 0fbd812146c517b3fbf9b4c6fdc9e87c70fa3789 Mon Sep 17 00:00:00 2001 From: Oleg Liubimov Date: Thu, 21 Oct 2021 12:12:45 +0300 Subject: [PATCH 02/10] Added .env_example. Updated test-requirement.txt and README.md --- .env_example | 13 +++++++++++++ README.md | 31 +++++++++++++++++++++++++++++++ test-requirements.txt | 1 + 3 files changed, 45 insertions(+) create mode 100644 .env_example diff --git a/.env_example b/.env_example new file mode 100644 index 00000000..f4b86e9d --- /dev/null +++ b/.env_example @@ -0,0 +1,13 @@ +USER_NAME="< your e-mail on which to register an account >" +CLIENT_SECRET="< The secret key of your application >" +INTEGRATOR_KEY_JWT="< your Integration Key >" +TEMPLATE_ID="< your template id >" +REDIRECT_URI="< URI for redirect >" +USER_ID="< your User ID >" +BRAND_ID="< your brand ID >" + +PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY----- +... +< your private key > +... +-----END RSA PRIVATE KEY-----" \ No newline at end of file diff --git a/README.md b/README.md index 01d43375..2f7b5354 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,37 @@ For details regarding which type of OAuth grant will work best for your DocuSign For security purposes, DocuSign recommends using the [Authorization Code Grant](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant) flow. +## Running tests: + +To run tests, you need: +1. Create a .env file at the root of the repository (or rename an existing .env_example file) +2. Enter your data from the developer account +* USER_NAME=< your e-mail on which to register an account > +* CLIENT_SECRET=< The secret key of your application > \ + settings => Apps and Keys => + Apps and Integration Keys your app "ACTIONS" => Edit => + Authentication => Secret Keys +* INTEGRATOR_KEY_JWT=< your Integration Key > \ + settings => Apps and Keys => Integration Key of your app +* TEMPLATE_ID=< your template id > \ + templates => in MyTemplates list click by choosen template => template id +* REDIRECT_URI=< URI for redirect > +* USER_ID=< your User ID > \ + settings => Apps and Keys => User ID +* BRAND_ID=< your brand ID > \ + settings => Brands => your Brand => "Edit" => Brand id +* PRIVATE_KEY=< your private key > \ + Settings => "Apps and Keys" + in Apps and Integration Keys choose your application name => "ACTIONS" Edit => Service Integration => + GENERATE RSA + +3. Install dependencies from test-requirements.txt: \ + python3 -m pip install --upgrade pip \ + pip3 install -r test-requirements.txt + +4. Run tests: \ + python3 -m unittest test.test_oauth \ + python3 -m unittest test.unit_tests + ## Support Log issues against this client through GitHub. We also have an [active developer community on Stack Overflow](https://stackoverflow.com/questions/tagged/docusignapi). diff --git a/test-requirements.txt b/test-requirements.txt index 4fb18ac3..1a93485e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,4 +3,5 @@ nose>=1.3.7 pluggy>=0.3.1 py>=1.4.31 randomize>=0.13 +python-dotenv tox From 9a6d1e8198c454de33d7649903a4eef152de6d48 Mon Sep 17 00:00:00 2001 From: Oleg Liubimov Date: Thu, 21 Oct 2021 12:17:47 +0300 Subject: [PATCH 03/10] Minor edits to test_oauth.py --- test/test_oauth.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_oauth.py b/test/test_oauth.py index 792c60e3..e7539c10 100644 --- a/test/test_oauth.py +++ b/test/test_oauth.py @@ -15,10 +15,12 @@ import base64 import os import unittest +from dotenv import load_dotenv from docusign_esign.client.api_client import ApiClient from docusign_esign.client.auth.oauth import OAuthToken +load_dotenv() class TestConfig(object): def __init__(self, user_name=None, client_secret =None, user_id=None, integrator_key=None, host=None, recipient_email=None, @@ -36,7 +38,7 @@ def __init__(self, user_name=None, client_secret =None, user_id=None, integrator self.redirect_uri = redirect_uri if redirect_uri else os.environ.get("REDIRECT_URI") self.oauth_host_name = "account-d.docusign.com" - self.private_key_bytes = base64.b64decode(os.environ.get("PRIVATE_KEY")) + self.private_key_bytes = os.environ.get("PRIVATE_KEY") self.expires_in = 3600 From 27b158a408ca4b7d4a11fd71a404a9bcb5a8bdc9 Mon Sep 17 00:00:00 2001 From: Oleg Liubimov Date: Thu, 21 Oct 2021 12:19:27 +0300 Subject: [PATCH 04/10] Added 10 unit tests to unit_tests.py --- test/unit_tests.py | 235 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 204 insertions(+), 31 deletions(-) diff --git a/test/unit_tests.py b/test/unit_tests.py index 8b8b51a4..3bf50718 100644 --- a/test/unit_tests.py +++ b/test/unit_tests.py @@ -8,9 +8,24 @@ import unittest from pprint import pprint from time import sleep +from dotenv import load_dotenv import docusign_esign as docusign -from docusign_esign import AuthenticationApi, EnvelopesApi, TemplatesApi, DiagnosticsApi, FoldersApi, ApiException +from docusign_esign import ( + AuthenticationApi, + EnvelopesApi, + TemplatesApi, + DiagnosticsApi, + FoldersApi, + ApiException, + RecipientViewRequest, + AccountsApi, + Recipients, + CarbonCopy, + UsersApi + ) + +load_dotenv() Username = os.environ.get("USER_NAME") IntegratorKey = os.environ.get("INTEGRATOR_KEY_JWT") @@ -21,7 +36,10 @@ TemplateId = os.environ.get("TEMPLATE_ID") UserId = os.environ.get("USER_ID") BrandId = os.environ.get("BRAND_ID") -PrivateKeyBytes = base64.b64decode(os.environ.get("PRIVATE_KEY")) +PrivateKeyBytes = os.environ.get("PRIVATE_KEY") +Name = "Pat Developer" +ClientUserID = "1000" +AccountNumber = 1 class SdkUnitTests(unittest.TestCase): @@ -37,15 +55,16 @@ def setUp(self): template_id = TemplateId role_name = 'Needs to sign' - name = 'Pat Developer' + name = Name email = Username t_role = docusign.TemplateRole(role_name=role_name, name=name, - email=email) + email=email, + client_user_id=ClientUserID) # send the envelope by setting |status| to "sent". To save as a draft set to "created" status = 'sent' # create an envelope definition - envelope_definition = docusign.EnvelopeDefinition(email_subject=email_subject, + self.envelope_definition = docusign.EnvelopeDefinition(email_subject=email_subject, email_blurb=email_blurb, template_id=template_id, template_roles=[t_role], @@ -59,11 +78,12 @@ def setUp(self): oauth_host_name=OauthHostName, private_key_bytes=PrivateKeyBytes, expires_in=3600)) - self.user_info = self.api_client.get_user_info(token.access_token) + user_info = self.api_client.get_user_info(token.access_token) + self.account_id = user_info.accounts[AccountNumber].account_id self.api_client.rest_client.pool_manager.clear() docusign.configuration.api_client = self.api_client - envelope_summary = envelopes_api.create_envelope(self.user_info.accounts[0].account_id, - envelope_definition=envelope_definition) + envelope_summary = envelopes_api.create_envelope(self.account_id, + envelope_definition=self.envelope_definition) self.api_client.rest_client.pool_manager.clear() self.envelope_id = envelope_summary.envelope_id @@ -105,7 +125,7 @@ def testTemplateGet(self): from docusign_esign import TemplatesApi template_api = TemplatesApi(self.api_client) - template_obj = template_api.get(self.user_info.accounts[0].account_id, template_id=TemplateId).to_dict() + template_obj = template_api.get(self.account_id, template_id=TemplateId).to_dict() assert template_obj is not None assert template_obj['uri'] is not None @@ -121,7 +141,7 @@ def testPutUpdateBrandResourceByContentType(self): try: from docusign_esign import AccountsApi acc_api = AccountsApi(self.api_client) - acc_obj = acc_api.update_brand_resources_by_content_type(self.user_info.accounts[0].account_id, BrandId, "email", brandFile) + acc_obj = acc_api.update_brand_resources_by_content_type(self.account_id, BrandId, "email", brandFile) assert acc_obj is not None assert acc_obj.resources_content_uri is not None @@ -188,7 +208,7 @@ def testRequestASignature(self): envelopes_api = EnvelopesApi() try: - envelope_summary = envelopes_api.create_envelope(self.user_info.accounts[0].account_id, + envelope_summary = envelopes_api.create_envelope(self.account_id, envelope_definition=envelope_definition) assert envelope_summary is not None assert envelope_summary.envelope_id is not None @@ -236,7 +256,7 @@ def testRequestSignatureFromTemplate(self): envelopes_api = EnvelopesApi() try: - envelope_summary = envelopes_api.create_envelope(self.user_info.accounts[0].account_id, + envelope_summary = envelopes_api.create_envelope(self.account_id, envelope_definition=envelope_definition) assert envelope_summary is not None assert envelope_summary.envelope_id is not None @@ -322,11 +342,11 @@ def testEmbeddedSigning(self): recipient_view_request.user_name = 'Pat Developer' recipient_view_request.email = Username - envelope_summary = envelopes_api.create_envelope(self.user_info.accounts[0].account_id, + envelope_summary = envelopes_api.create_envelope(self.account_id, envelope_definition=envelope_definition) envelope_id = envelope_summary.envelope_id - view_url = envelopes_api.create_recipient_view(self.user_info.accounts[0].account_id, envelope_id, + view_url = envelopes_api.create_recipient_view(self.account_id, envelope_id, recipient_view_request=recipient_view_request) # This Url should work in an Iframe or browser to allow signing @@ -398,7 +418,7 @@ def testCreateTemplate(self): try: - template_summary = templates_api.create_template(self.user_info.accounts[0].account_id, + template_summary = templates_api.create_template(self.account_id, envelope_template=envelope_template) assert template_summary is not None assert template_summary.template_id is not None @@ -472,10 +492,10 @@ def testDownLoadEnvelopeDocuments(self): try: docusign.configuration.api_client = self.api_client - file1 = envelopes_api.get_document(self.user_info.accounts[0].account_id, 'combined', self.envelope_id) + document = envelopes_api.get_document(self.account_id, 'combined', self.envelope_id) - assert len(file1) > 0 - subprocess.call('open ' + file1, shell=True) + assert len(document) > 0 + subprocess.call('open ' + document, shell=True) except ApiException as e: print("\nException when calling DocuSign API: %s" % e) @@ -575,7 +595,7 @@ def testResendEnvelope(self): try: docusign.configuration.api_client = self.api_client - recipients_update_summary = envelopes_api.update_recipients(self.user_info.accounts[0].account_id, + recipients_update_summary = envelopes_api.update_recipients(self.account_id, self.envelope_id, recipients=recipients, resend_envelope='true') assert recipients_update_summary is not None @@ -659,13 +679,13 @@ def testGetDiagnosticLogs(self): 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(self.user_info.accounts[0].account_id, + envelope_summary = envelopes_api.create_envelope(self.account_id, envelope_definition=envelope_definition) envelope_id = envelope_summary.envelope_id - file1 = envelopes_api.get_document(self.user_info.accounts[0].account_id, 'combined', envelope_id) - assert len(file1) > 0 - subprocess.call('open ' + file1, shell=True) + document = envelopes_api.get_document(self.account_id, 'combined', envelope_id) + assert len(document) > 0 + subprocess.call('open ' + document, shell=True) logs_list = diag_api.list_request_logs() request_log_id = logs_list.api_request_logs[0].request_log_id @@ -684,7 +704,7 @@ def testGetFormData(self): try: envelopes_api = EnvelopesApi() - form_data = envelopes_api.get_form_data(account_id=self.user_info.accounts[0].account_id, + form_data = envelopes_api.get_form_data(account_id=self.account_id, envelope_id=self.envelope_id) assert form_data is not None assert form_data.prefill_form_data is not None @@ -734,16 +754,16 @@ def testListTabs(self): envelopes_api = EnvelopesApi() # Create Envelope with the new role - envelope_summary = envelopes_api.create_envelope(self.user_info.accounts[0].account_id, + envelope_summary = envelopes_api.create_envelope(self.account_id, envelope_definition=envelope_definition) # Read the new Envelope - created_envelope = envelopes_api.get_envelope(account_id=self.user_info.accounts[0].account_id, + created_envelope = envelopes_api.get_envelope(account_id=self.account_id, envelope_id=envelope_summary.envelope_id) - recipients = envelopes_api.list_recipients(account_id=self.user_info.accounts[0].account_id, + recipients = envelopes_api.list_recipients(account_id=self.account_id, envelope_id=created_envelope.envelope_id) - tabs = envelopes_api.list_tabs(account_id=self.user_info.accounts[0].account_id, + tabs = envelopes_api.list_tabs(account_id=self.account_id, envelope_id=created_envelope.envelope_id, recipient_id=recipients.signers[0].recipient_id) list_tabs = tabs.list_tabs @@ -813,7 +833,7 @@ def testMoveEnvelopes(self): envelopes_api = EnvelopesApi() try: - envelope_summary = envelopes_api.create_envelope(self.user_info.accounts[0].account_id, + envelope_summary = envelopes_api.create_envelope(self.account_id, envelope_definition=envelope_definition) assert envelope_summary is not None assert envelope_summary.envelope_id is not None @@ -824,7 +844,7 @@ def testMoveEnvelopes(self): to_folder_id = "draft" - folders_api.move_envelopes(self.user_info.accounts[0].account_id, to_folder_id, + folders_api.move_envelopes(self.account_id, to_folder_id, folders_request=folders_request) # Wait for 3 second to make sure the newly created envelope was moved to the 'sentitems' folder @@ -835,7 +855,7 @@ def testMoveEnvelopes(self): # Test if we moved the envelope to the correct folder search_options = "true" - list_from_drafts_folder = folders_api.list_items(self.user_info.accounts[0].account_id, to_folder_id, include_items=search_options) + list_from_drafts_folder = folders_api.list_items(self.account_id, to_folder_id, include_items=search_options) assert list_from_drafts_folder is not None @@ -853,6 +873,159 @@ def testMoveEnvelopes(self): print("\nException when calling DocuSign API: %s" % e) assert e is None # make the test case fail in case of an API exception + def ListRecipients_CorrectAccountIdAndEnvelopeId_ReturnRecipientsList(self): + envelopes_api = EnvelopesApi() + try: + recipients_list = envelopes_api.list_recipients(self.account_id, self.envelope_id) + assert recipients_list is not None + except ApiException as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + except Exception as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + + def CreateRecipientView_CorrectAccountIdAndEnvelopeId_ReturnViewUrl(self): + envelopes_api = EnvelopesApi() + try: + # Create the recipient view request object + recipient_view_request = RecipientViewRequest( + authentication_method="None", + client_user_id=ClientUserID, + recipient_id="1", + return_url="http://localhost", + user_name=Name, + email=Username + ) + + recipient_view = envelopes_api.create_recipient_view( + self.account_id, + self.envelope_id, + recipient_view_request=recipient_view_request + ) + assert 'https://' in recipient_view.url + except ApiException as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + except Exception as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + + def ListDocuments_CorrectAccountIdAndEnvelopeId_ReturnEnvelopeDocumentsResult(self): + envelopes_api = EnvelopesApi() + try: + envelope_documents = envelopes_api.list_documents(self.account_id, self.envelope_id) + assert envelope_documents.envelope_documents is not None + except ApiException as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + except Exception as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + + def Update_CorrectAccountIdAndEnvelopeIdAndEnvelope_ReturnEnvelopeUpdateSummary(self): + envelopes_api = EnvelopesApi() + try: + envelope_update = envelopes_api.update( + self.account_id, + self.envelope_id, + envelope=self.envelope_definition + ) + assert envelope_update.envelope_id == self.envelope_id + except ApiException as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + except Exception as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + + def GetAccountInformation_CorrectAccountId_ReturnAccountInfo(self): + accounts_api = AccountsApi() + try: + acc_info = accounts_api.get_account_information(self.account_id) + assert acc_info.account_name is not None + except ApiException as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + except Exception as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + + def UpdateRecipients_CorrectAccountIdAndEnvelopeId_ReturnRecipientsUpdateSummary(self): + envelopes_api = EnvelopesApi() + + recipients = Recipients() + recipients.carbon_copies = [] + cc = CarbonCopy() + cc.email = 'janedoe@example.com' + cc.name = 'Jane Doe' + cc.delivery_method ='email' + cc.recipient_id = '11' + cc.routing_order = '3' + recipients.carbon_copies.append(cc) + + try: + updated_recipients = envelopes_api.update_recipients( + self.account_id, + self.envelope_id, + recipients=recipients + ) + assert updated_recipients.recipient_update_results[0].recipient_id == cc.recipient_id + except ApiException as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + except Exception as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + + def ListTemplates_CorrectAccountId_ReturnTemplatesList(self): + templates_api = TemplatesApi() + try: + templates_list = templates_api.list_templates(self.account_id) + assert templates_list.envelope_templates is not None + except ApiException as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + except Exception as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + + def List_CorrectAccountId_ReturnUsersList(self): + users_api = UsersApi() + try: + users_list = users_api.list(self.account_id) + assert users_list.users is not None + except ApiException as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + except Exception as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + + def Get_CorrectAccountIdAndTemplateId_ReturnTemplate(self): + templates_api = TemplatesApi() + try: + template = templates_api.get(self.account_id, TemplateId) + assert template.documents is not None + except ApiException as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + except Exception as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + + def ListAuditEvents_CorrectAccountIdAndEnvelopeId_ReturnAuditList(self): + envelopes_api = EnvelopesApi() + try: + audit_list = envelopes_api.list_audit_events(self.account_id, self.envelope_id) + assert audit_list.audit_events is not None + except ApiException as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + except Exception as e: + print("\nException when calling DocuSign API: %s" % e) + assert e is None + if __name__ == '__main__': unittest.main() From 574e3494b71e39abd9b2ed3a9b25f160f60a1861 Mon Sep 17 00:00:00 2001 From: Oleg Liubimov Date: Tue, 9 Nov 2021 17:08:30 +0200 Subject: [PATCH 05/10] Updated readme file --- README.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2f7b5354..b424419d 100644 --- a/README.md +++ b/README.md @@ -67,11 +67,18 @@ For details regarding which type of OAuth grant will work best for your DocuSign For security purposes, DocuSign recommends using the [Authorization Code Grant](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant) flow. -## Running tests: - -To run tests, you need: -1. Create a .env file at the root of the repository (or rename an existing .env_example file) -2. Enter your data from the developer account +## Tests: + +### Test configuration +1. Login with your DocuSign account on https://appdemo.docusign.com. +2. Open Apps and Keys section in Settings and press Add App and Integration Key button. +3. Enter App name, add secret key, generate RSA key and press Save button. +4. Create new brand on https://admindemo.docusign.com/brands page and save its ID. +5. Create new template on https://appdemo.docusign.com/templates page and save its ID. +6. Create a .env file at the root of the repository (or rename an existing .env_example file) and fill it with required data from steps 3-5. +7. Write your generated private key into .env file + +8. Where in the developer account to look for data for the .env file: * USER_NAME=< your e-mail on which to register an account > * CLIENT_SECRET=< The secret key of your application > \ settings => Apps and Keys => @@ -90,14 +97,17 @@ To run tests, you need: Settings => "Apps and Keys" in Apps and Integration Keys choose your application name => "ACTIONS" Edit => Service Integration => + GENERATE RSA -3. Install dependencies from test-requirements.txt: \ +9. Install dependencies from test-requirements.txt: \ python3 -m pip install --upgrade pip \ pip3 install -r test-requirements.txt -4. Run tests: \ +10. Run tests: \ python3 -m unittest test.test_oauth \ python3 -m unittest test.unit_tests +### Recomended operating system +The prefered operating system to run unit-tests is Linux. + ## Support Log issues against this client through GitHub. We also have an [active developer community on Stack Overflow](https://stackoverflow.com/questions/tagged/docusignapi). From 6ef379d565180d0f7b77c192550a2eaab1a42b5f Mon Sep 17 00:00:00 2001 From: Oleg Liubimov Date: Tue, 9 Nov 2021 17:25:50 +0200 Subject: [PATCH 06/10] Updated readme file --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b424419d..360ca9d4 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,9 @@ For security purposes, DocuSign recommends using the [Authorization Code Grant]( Settings => "Apps and Keys" in Apps and Integration Keys choose your application name => "ACTIONS" Edit => Service Integration => + GENERATE RSA -9. Install dependencies from test-requirements.txt: \ +9. Install dependencies: \ python3 -m pip install --upgrade pip \ + pip3 install -r requirements.txt \ pip3 install -r test-requirements.txt 10. Run tests: \ @@ -108,6 +109,12 @@ For security purposes, DocuSign recommends using the [Authorization Code Grant]( ### Recomended operating system The prefered operating system to run unit-tests is Linux. +### Installing Python3 language on PC +To run tests for this project, please, install the Python 3.7 or higher on your PC:\ +https://www.python.org/downloads/ \ +After downloading process is complete, check if you have a Python3 installed on your PC by using \ +python3 --version + ## Support Log issues against this client through GitHub. We also have an [active developer community on Stack Overflow](https://stackoverflow.com/questions/tagged/docusignapi). From 3ffe8172de339814780a40adda7e10116a406e66 Mon Sep 17 00:00:00 2001 From: Oleg Liubimov Date: Tue, 16 Nov 2021 19:14:50 +0200 Subject: [PATCH 07/10] Removed the non-working subprocess.call command --- test/unit_tests.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/unit_tests.py b/test/unit_tests.py index 3bf50718..7e926dcb 100644 --- a/test/unit_tests.py +++ b/test/unit_tests.py @@ -495,7 +495,6 @@ def testDownLoadEnvelopeDocuments(self): document = envelopes_api.get_document(self.account_id, 'combined', self.envelope_id) assert len(document) > 0 - subprocess.call('open ' + document, shell=True) except ApiException as e: print("\nException when calling DocuSign API: %s" % e) @@ -685,13 +684,11 @@ def testGetDiagnosticLogs(self): document = envelopes_api.get_document(self.account_id, 'combined', envelope_id) assert len(document) > 0 - subprocess.call('open ' + document, shell=True) logs_list = diag_api.list_request_logs() request_log_id = logs_list.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) From 6216fca38f483cdfda5ebe1fe225a72ecfe891bf Mon Sep 17 00:00:00 2001 From: Oleg Liubimov Date: Tue, 16 Nov 2021 21:18:51 +0200 Subject: [PATCH 08/10] Fixed tests testGetFormData and testListTabs --- test/unit_tests.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/unit_tests.py b/test/unit_tests.py index 7e926dcb..66d798b0 100644 --- a/test/unit_tests.py +++ b/test/unit_tests.py @@ -705,8 +705,7 @@ def testGetFormData(self): envelope_id=self.envelope_id) assert form_data is not None assert form_data.prefill_form_data is not None - assert form_data.prefill_form_data.form_data[0] is not None - assert form_data.prefill_form_data.form_data[0].name is not None + assert isinstance(form_data.prefill_form_data.form_data, list) except ApiException as e: print("\nException when calling DocuSign API: %s" % e) @@ -762,8 +761,8 @@ def testListTabs(self): tabs = envelopes_api.list_tabs(account_id=self.account_id, envelope_id=created_envelope.envelope_id, - recipient_id=recipients.signers[0].recipient_id) - list_tabs = tabs.list_tabs + recipient_id=recipients.signers[1].recipient_id) + list_tabs = tabs assert list_tabs is not None From cb3be707b41376a2a876c72ed57c1f733808afbb Mon Sep 17 00:00:00 2001 From: Oleg Liubimov Date: Tue, 16 Nov 2021 21:42:56 +0200 Subject: [PATCH 09/10] Added test_ prefix in test names --- test/unit_tests.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/unit_tests.py b/test/unit_tests.py index 66d798b0..0d7a5251 100644 --- a/test/unit_tests.py +++ b/test/unit_tests.py @@ -869,7 +869,7 @@ def testMoveEnvelopes(self): print("\nException when calling DocuSign API: %s" % e) assert e is None # make the test case fail in case of an API exception - def ListRecipients_CorrectAccountIdAndEnvelopeId_ReturnRecipientsList(self): + def test_ListRecipients_CorrectAccountIdAndEnvelopeId_ReturnRecipientsList(self): envelopes_api = EnvelopesApi() try: recipients_list = envelopes_api.list_recipients(self.account_id, self.envelope_id) @@ -881,7 +881,7 @@ def ListRecipients_CorrectAccountIdAndEnvelopeId_ReturnRecipientsList(self): print("\nException when calling DocuSign API: %s" % e) assert e is None - def CreateRecipientView_CorrectAccountIdAndEnvelopeId_ReturnViewUrl(self): + def test_CreateRecipientView_CorrectAccountIdAndEnvelopeId_ReturnViewUrl(self): envelopes_api = EnvelopesApi() try: # Create the recipient view request object @@ -907,7 +907,7 @@ def CreateRecipientView_CorrectAccountIdAndEnvelopeId_ReturnViewUrl(self): print("\nException when calling DocuSign API: %s" % e) assert e is None - def ListDocuments_CorrectAccountIdAndEnvelopeId_ReturnEnvelopeDocumentsResult(self): + def test_ListDocuments_CorrectAccountIdAndEnvelopeId_ReturnEnvelopeDocumentsResult(self): envelopes_api = EnvelopesApi() try: envelope_documents = envelopes_api.list_documents(self.account_id, self.envelope_id) @@ -919,7 +919,7 @@ def ListDocuments_CorrectAccountIdAndEnvelopeId_ReturnEnvelopeDocumentsResult(se print("\nException when calling DocuSign API: %s" % e) assert e is None - def Update_CorrectAccountIdAndEnvelopeIdAndEnvelope_ReturnEnvelopeUpdateSummary(self): + def test_Update_CorrectAccountIdAndEnvelopeIdAndEnvelope_ReturnEnvelopeUpdateSummary(self): envelopes_api = EnvelopesApi() try: envelope_update = envelopes_api.update( @@ -935,7 +935,7 @@ def Update_CorrectAccountIdAndEnvelopeIdAndEnvelope_ReturnEnvelopeUpdateSummary( print("\nException when calling DocuSign API: %s" % e) assert e is None - def GetAccountInformation_CorrectAccountId_ReturnAccountInfo(self): + def test_GetAccountInformation_CorrectAccountId_ReturnAccountInfo(self): accounts_api = AccountsApi() try: acc_info = accounts_api.get_account_information(self.account_id) @@ -947,7 +947,7 @@ def GetAccountInformation_CorrectAccountId_ReturnAccountInfo(self): print("\nException when calling DocuSign API: %s" % e) assert e is None - def UpdateRecipients_CorrectAccountIdAndEnvelopeId_ReturnRecipientsUpdateSummary(self): + def test_UpdateRecipients_CorrectAccountIdAndEnvelopeId_ReturnRecipientsUpdateSummary(self): envelopes_api = EnvelopesApi() recipients = Recipients() @@ -974,7 +974,7 @@ def UpdateRecipients_CorrectAccountIdAndEnvelopeId_ReturnRecipientsUpdateSummary print("\nException when calling DocuSign API: %s" % e) assert e is None - def ListTemplates_CorrectAccountId_ReturnTemplatesList(self): + def test_ListTemplates_CorrectAccountId_ReturnTemplatesList(self): templates_api = TemplatesApi() try: templates_list = templates_api.list_templates(self.account_id) @@ -986,7 +986,7 @@ def ListTemplates_CorrectAccountId_ReturnTemplatesList(self): print("\nException when calling DocuSign API: %s" % e) assert e is None - def List_CorrectAccountId_ReturnUsersList(self): + def test_List_CorrectAccountId_ReturnUsersList(self): users_api = UsersApi() try: users_list = users_api.list(self.account_id) @@ -998,7 +998,7 @@ def List_CorrectAccountId_ReturnUsersList(self): print("\nException when calling DocuSign API: %s" % e) assert e is None - def Get_CorrectAccountIdAndTemplateId_ReturnTemplate(self): + def test_Get_CorrectAccountIdAndTemplateId_ReturnTemplate(self): templates_api = TemplatesApi() try: template = templates_api.get(self.account_id, TemplateId) @@ -1010,7 +1010,7 @@ def Get_CorrectAccountIdAndTemplateId_ReturnTemplate(self): print("\nException when calling DocuSign API: %s" % e) assert e is None - def ListAuditEvents_CorrectAccountIdAndEnvelopeId_ReturnAuditList(self): + def test_ListAuditEvents_CorrectAccountIdAndEnvelopeId_ReturnAuditList(self): envelopes_api = EnvelopesApi() try: audit_list = envelopes_api.list_audit_events(self.account_id, self.envelope_id) From afc10350da4361c9c8493a3b4c3d71ba6ed48e6c Mon Sep 17 00:00:00 2001 From: Oleg Liubimov Date: Tue, 16 Nov 2021 21:44:07 +0200 Subject: [PATCH 10/10] minor readme fixes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 360ca9d4..d9ac15ad 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ For security purposes, DocuSign recommends using the [Authorization Code Grant]( python3 -m unittest test.unit_tests ### Recomended operating system -The prefered operating system to run unit-tests is Linux. +You can use Windows or Linux to run these unit tests. ### Installing Python3 language on PC To run tests for this project, please, install the Python 3.7 or higher on your PC:\