Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"bundle": "redocly bundle openapi.json -o dist/bundledSchema.json",
"generate-java": "rm -rf ./dist/java-sdk && npm run bundle && npx mkdirp dist/java-sdk/src/test/java/unit/java/sdk && cp -a ./unit/e2e_tests/java/. ./dist/java-sdk/src/test/java/unit/java/sdk && openapi-generator-cli generate -g java -i ./dist/bundledSchema.json -o ./dist/java-sdk -p hideGenerationTimestamp=true -p packageName=unit.java.sdk -p modelPackage=unit.java.sdk.model -p apiPackage=unit.java.sdk.api --library native -p useJakartaEe=true --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true",
"generate-ruby": "rm -rf ./dist/ruby-sdk && npm run bundle && cp -r unit ./dist/ruby-sdk && openapi-generator-cli generate -g ruby -i ./dist/bundledSchema.json -o ./dist/ruby-sdk",
"generate-python": "rm -rf dist/pythonsdk && npm run bundle && cp -r unit dist/pythonsdk && openapi-generator-cli generate -g python -i ./dist/bundledSchema.json -o dist/pythonsdk",
"generate-node": "rm -rf ./dist/node-sdk && npm run bundle && openapi-generator-cli generate -g typescript-axios -i ./dist/bundledSchema.json -o ./dist/node-sdk",
"lint": "redocly lint --config .redocly.yaml openapi.json",
"format": "prettier ./schemas --write"
Expand Down
36 changes: 20 additions & 16 deletions unit/e2e_tests/python/account_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

from helpers.helpers import create_api_client, create_individual_application_request, \
create_business_application_request
from swagger_client import CreateApplicationApi, CreateAnAccountApi, \
CreateDepositAccountAttributes, CreateDepositAccountRelationships, CreateDepositAccount, GetListAccountsApi, \
GetAccountApi, CloseAnAccountApi, ReopenAnAccountApi, FreezeAnAccountApi, UnfreezeAccountApi, \
CreateCreditAccountAttributes, CreateCreditAccount
from dist.pythonsdk.openapi_client.api.unit_api import UnitApi
from dist.pythonsdk.openapi_client.models import CreateDepositAccountAttributes, CreateDepositAccountRelationships, CreateCreditAccountAttributes, \
CreateCreditAccount, CreateDepositAccount


class TestAccountApi(unittest.TestCase):
Expand All @@ -20,11 +19,16 @@ def tearDown(self):
pass

def create_individual_customer(self):
app = CreateApplicationApi(self.api_client).execute(create_individual_application_request()).data
# Ensure that create_individual_application_request() returns the correct type
application_request = create_individual_application_request()

# Pass the application_request directly to create_application
app = UnitApi.create_application(self.api_client).execute(application_request).data

return app.relationships.customer.data.id

def create_business_customer(self):
app = CreateApplicationApi(self.api_client).execute(create_business_application_request()).data
app = UnitApi.create_application(self.api_client).execute(create_business_application_request()).data
return app.relationships.customer.data.id

def create_deposit_account(self):
Expand All @@ -35,7 +39,7 @@ def create_deposit_account(self):
"id": customer_id}})
req = CreateDepositAccount("depositAccount", attributes, relationships)

response = CreateAnAccountApi(self.api_client).execute({"data": req})
response = UnitApi.create_account(self.api_client).execute({"data": req})
return response.data

def create_credit_account_for_business(self):
Expand All @@ -45,7 +49,7 @@ def create_credit_account_for_business(self):
"id": customer_id}})

req = CreateCreditAccount("creditAccount", attributes, relationships)
response = CreateAnAccountApi(self.api_client).execute({"data": req})
response = UnitApi.create_account(self.api_client).execute({"data": req})

return response.data

Expand All @@ -61,7 +65,7 @@ def create_deposit_account_for_business(self):
"id": customer_id}})
req = CreateDepositAccount("depositAccount", attributes, relationships)

response = CreateAnAccountApi(self.api_client).execute({"data": req})
response = UnitApi.create_account(self.api_client).execute({"data": req})
return response.data

def test_create_deposit_account(self):
Expand All @@ -75,22 +79,22 @@ def test_create_business_deposit_account(self):
assert account.type == "depositAccount"

def test_list_accounts(self):
res = GetListAccountsApi(self.api_client).execute() #no unit response type
res = UnitApi.get_accounts_list(self.api_client).execute() #no unit response type
for acc in res.data:
assert acc.type == "depositAccount"

def test_list_accounts(self):
res = GetListAccountsApi(self.api_client).execute() #no unit response type
res = UnitApi.get_accounts_list(self.api_client).execute() #no unit response type
for acc in res.data:
assert acc.type == "depositAccount"
response_account = GetAccountApi(self.api_client).execute(acc.id).data
response_account = UnitApi.get_account(self.api_client).execute(acc.id).data
assert acc.type == response_account.type
assert acc.id == response_account.id

def close_account(self, close_reason="Fraud"):
account_id = self.create_deposit_account().id

account = CloseAnAccountApi(self.api_client).execute({"data": {
account = UnitApi.close_account(self.api_client).execute({"data": {
"type": "depositAccountClose",
"attributes": {
"reason": close_reason
Expand All @@ -111,7 +115,7 @@ def test_reopen_account(self):
account = self.close_account("ByCustomer")
assert account.type == "depositAccount"

reopen_account = ReopenAnAccountApi(self.api_client).execute(account.id).data
reopen_account = UnitApi.reopen_account(self.api_client).execute(account.id).data
assert reopen_account.id == account.id
assert reopen_account.type == "depositAccount"
assert reopen_account.attributes.status == "Open"
Expand All @@ -121,7 +125,7 @@ def freeze_account(self):

freeze_reason_text = "This is a test - SDK"

account = FreezeAnAccountApi(self.api_client).execute({"data": {
account = UnitApi.freeze_account(self.api_client).execute({"data": {
"type": "accountFreeze",
"attributes": {
"reason": "Other",
Expand All @@ -143,7 +147,7 @@ def test_unfreeze_account(self):
account = self.freeze_account()
assert account.type == "depositAccount"

reopen_account = UnfreezeAccountApi(self.api_client).execute(account.id).data
reopen_account = UnitApi.unfreeze_account(self.api_client).execute(account.id).data
assert reopen_account.id == account.id
assert reopen_account.type == "depositAccount"
assert reopen_account.attributes.status == "Open"
Expand Down
9 changes: 4 additions & 5 deletions unit/e2e_tests/python/application_form_test.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import unittest

from e2e_tests.python.helpers.helpers import create_api_client
from swagger_client import GetListApplicationFormsApi

from helpers.helpers import create_api_client
from dist.pythonsdk.openapi_client.api.unit_api import UnitApi

class TestApplicationFormApi(unittest.TestCase):
"""ApplicationFormApi unit test stubs"""

def setUp(self):
self.api_client = create_api_client()
self.unit_api = UnitApi(self.api_client) # Instantiate UnitApi with ApiClient

def tearDown(self):
pass

def test_get_list_application_forms(self):
response = GetListApplicationFormsApi(self.api_client).execute()
response = self.unit_api.get_application_forms_list().execute()
for w in response.data:
assert w.type == "applicationForm"

93 changes: 15 additions & 78 deletions unit/e2e_tests/python/application_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import base64
import unittest

from e2e_tests.python.helpers.helpers import create_api_client, create_individual_application_request,\
from helpers.helpers import create_api_client, create_individual_application_request,\
create_business_application_request
from swagger_client import GetListApplicationsApi, CreateApplicationApi, CreateSoleProprietorApplication, \
CreateSoleProprietorApplicationAttributes, Address, FullName, Phone, \
CreateTrustApplication, CreateTrustApplicationAttributes, Grantor, Trustee, Beneficiary, TrustContact, \
UploadAPNGDocumentForAnApplicationApi, UploadAJPEGDocumentForAnApplicationApi, UploadAPDFDocumentForAnApplicationApi
from swagger_client.api.get_application_api import GetApplicationApi # noqa: E501
from dist.pythonsdk.openapi_client.api.unit_api import UnitApi
from dist.pythonsdk.openapi_client.models import CreateDepositAccountAttributes, CreateDepositAccountRelationships, CreateCreditAccountAttributes, \
CreateCreditAccount, CreateDepositAccount, Address, Phone, FullName, CreateSoleProprietorApplicationAttributes, \
CreateSoleProprietorApplication

ApplicationTypes = ["individualApplication", "businessApplication", "trustApplication"]

Expand All @@ -24,12 +23,12 @@ def tearDown(self):
pass

def create_individual_application(self, ssn="721074426"):
app = CreateApplicationApi(self.api_client).execute(create_individual_application_request(ssn))
app = UnitApi.create_application(self.api_client).execute(create_individual_application_request(ssn))

return app.data

def create_individual_application_with_included(self, ssn="721074426"):
app = CreateApplicationApi(self.api_client).execute(create_individual_application_request(ssn))
app = UnitApi.create_application(self.api_client).execute(create_individual_application_request(ssn))

return app

Expand All @@ -39,7 +38,7 @@ def test_create_individual_application(self):
assert res.type == "individualApplication"

def test_find_application_by_id(self):
get_application_api = GetApplicationApi(self.api_client)
get_application_api = UnitApi.get_application(self.api_client)

app = self.create_individual_application()
res = get_application_api.execute(app.id).data
Expand All @@ -48,7 +47,7 @@ def test_find_application_by_id(self):
assert res.id == app.id

def create_business_application(self):
app = CreateApplicationApi(self.api_client).execute(create_business_application_request())
app = UnitApi.create_application(self.api_client).execute(create_business_application_request())

return app.data

Expand All @@ -57,13 +56,13 @@ def test_create_business_application(self):
assert response.type == "businessApplication"

def test_list_applications(self):
res = GetListApplicationsApi(self.api_client).execute()
res = UnitApi.get_applications_list(self.api_client).execute()
for app in res.data:
assert app.type in ApplicationTypes

def test_list_and_get_applications(self):
res = GetListApplicationsApi(self.api_client).execute()
get_application_api = GetApplicationApi(self.api_client)
res = UnitApi.get_applications_list(self.api_client).execute()
get_application_api = UnitApi.get_application(self.api_client)

for app in res.data:
assert app.type in ApplicationTypes
Expand All @@ -79,7 +78,7 @@ def test_upload_png_document(self):

image_file = open("unit_photo.png", 'rb').read()

res = UploadAPNGDocumentForAnApplicationApi(self.api_client).execute(image_file.decode('latin-1'), application_id, document_id)
res = UnitApi.upload_application_document_file(self.api_client).execute(image_file.decode('latin-1'), application_id, document_id)
assert res.data.type == "document"

def test_upload_jpg_document(self):
Expand All @@ -90,7 +89,7 @@ def test_upload_jpg_document(self):

image_file = open("Unit_Logo.jpg", "r", encoding='latin-1').read()

res = UploadAJPEGDocumentForAnApplicationApi(self.api_client).execute(str(image_file), application_id, document_id)
res = UnitApi.upload_application_document_file(self.api_client).execute(str(image_file), application_id, document_id)
assert res.data.type == "document"

def test_upload_pdf_document(self):
Expand All @@ -101,70 +100,8 @@ def test_upload_pdf_document(self):

image_file = open("sample.pdf", "r").read()

res = UploadAPDFDocumentForAnApplicationApi(self.api_client).execute(str(image_file), application_id, document_id)
res = UnitApi.upload_application_document_file(self.api_client).execute(str(image_file), application_id, document_id)
assert res.data.type == "document"

def test_create_sole_proprietor_application(self):
address = Address(street="1600 Pennsylvania Avenue Northwest", city="Washington", state="CA",
postal_code="20500",
country="US")
attr = CreateSoleProprietorApplicationAttributes(FullName("Peter", "Parker"), "[email protected]",
Phone("1", "2025550108"), "721074426",
address=address, date_of_birth="2001-08-10",
dba="Piedpiper Inc", ein="123456789",
annual_income="Between50kAnd100k",
source_of_income="EmploymentOrPayrollIncome",
annual_revenue="Between100kAnd200k",
sole_proprietorship=True,
number_of_employees="Between5And10",
business_vertical="TechnologyMediaOrTelecom",
jwt_subject="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9fQ")

req = {"data": CreateSoleProprietorApplication(attributes=attr)}

app = CreateApplicationApi(self.api_client).execute(req)

assert app.data.type == "individualApplication"

def test_create_trust_application(self):
address = Address(street="1600 Pennsylvania Avenue Northwest", city="Washington", state="CA",
postal_code="20500",
country="US")
full_name = FullName("Richard", "Hendricks")

attr = CreateTrustApplicationAttributes("Trust me Inc.", "CA", "Revocable", "Salary", "123456789",
Grantor(full_name, "[email protected]",
Phone("1", "2025550108"), "000000002",
date_of_birth="2000-01-01", address=address),
[Trustee(full_name, "[email protected]", address=address,
date_of_birth="2000-01-01", ssn="000000002",
phone=Phone("1", "2025550108"))],
[Beneficiary(FullName("Dinesh","Chugtai"), "2000-01-01"),
Beneficiary(FullName("Gilfoyle","Unknown"), "2000-01-01")],
TrustContact(FullName("Jared","Dann"), "[email protected]",
Phone("1", "2025550108"),
address=Address("5230 Newell Rd", "", "Palo Alto", "CA",
"94303")))

req = {"data": CreateTrustApplication(attributes=attr)}

app = CreateApplicationApi(self.api_client).execute(req)

assert app.data.type == "trustApplication"

if __name__ == '__main__':
unittest.main()

# def test_update_individual_application():
# app = create_individual_application()
# updated = client.applications.update(PatchApplicationRequest(app.data.id, tags={"patch": "test-patch"}))
# assert updated.data.type == "individualApplication"
#
# def test_update_business_application():
# app = create_business_application()
# updated = client.applications.update(PatchApplicationRequest(app.data.id, "businessApplication",
# tags={"patch": "test-patch"}))
# assert updated.data.type == "businessApplication"



10 changes: 5 additions & 5 deletions unit/e2e_tests/python/authorization_request_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import unittest

from e2e_tests.python.helpers.helpers import create_api_client
from swagger_client import GetAuthorizationRequestApi, GetListAuthorizationRequestsApi
from helpers.helpers import create_api_client
from dist.pythonsdk.openapi_client.api.unit_api import UnitApi


class TestAuthorizationRequestsApi(unittest.TestCase):
Expand All @@ -16,13 +16,13 @@ def tearDown(self):
pass

def test_list_authorization_requests(self):
res = GetListAuthorizationRequestsApi(self.api_client).execute()
res = UnitApi.get_authorizations_list(self.api_client).execute()
for app in res.data:
assert "AuthorizationRequest" in app.type

def test_list_and_get_authorization_requests(self):
res = GetListAuthorizationRequestsApi(self.api_client).execute()
get_application_request_api = GetAuthorizationRequestApi(self.api_client)
res = UnitApi.get_authorizations_list(self.api_client).execute()
get_application_request_api = UnitApi.get_authorization_request(self.api_client)

for app in res.data:
assert "AuthorizationRequest" in app.type
Expand Down
Loading