From 5f34b290b1d3a812ebf1ba0dc57ac9e40b14c969 Mon Sep 17 00:00:00 2001 From: stymoshchuk Date: Tue, 20 Aug 2024 11:38:33 +0200 Subject: [PATCH 1/2] RB-test-new-openapi_YH update tests --- .../ruby/spec/models/account_spec.rb | 37 ++++++++++--------- .../ruby/spec/models/application_spec.rb | 23 ++---------- unit/e2e_tests/ruby/spec/models/card_spec.rb | 37 ++++++++++++------- .../ruby/spec/models/customer_spec.rb | 22 +++-------- .../ruby/spec/models/payment_spec.rb | 16 ++------ .../ruby/spec/models/received_payment_spec.rb | 27 ++++++++++++++ unit/e2e_tests/ruby/spec/spec_helper.rb | 4 +- 7 files changed, 86 insertions(+), 80 deletions(-) create mode 100644 unit/e2e_tests/ruby/spec/models/received_payment_spec.rb diff --git a/unit/e2e_tests/ruby/spec/models/account_spec.rb b/unit/e2e_tests/ruby/spec/models/account_spec.rb index 33d0b79..751c4fc 100644 --- a/unit/e2e_tests/ruby/spec/models/account_spec.rb +++ b/unit/e2e_tests/ruby/spec/models/account_spec.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require 'spec_helper' RSpec.describe 'Account' do @@ -8,25 +6,28 @@ end describe 'test an instance of Account' do - let(:api_instance) { OpenapiClient::CreateAnAccountApi.new(OpenapiClient::ApiClient.new(configuration)) } + + let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) } it 'Should create deposit account' do - request = { data: OpenapiClient::CreateDepositAccount.new(type: 'depositAccount', attributes: - OpenapiClient::CreateDepositAccountAttributes.new( - { deposit_product: 'checking', + request = { + data: { + type: 'depositAccount', + attributes: OpenapiClient::CreateDepositAccountAttributes.new( + deposit_product: 'checking', tags: { "purpose": 'checking' }, - idempotency_key: '1234567890' } - ), relationships: OpenapiClient::CreateDepositAccountRelationships.new( - customer: - { "data": - { "type": 'customer', - "id": '751009' } } - ).to_hash).to_hash } - - response = api_instance.execute(request) + idempotency_key: '1234567890' + ).to_hash, + relationships: OpenapiClient::CreateDepositAccountRelationships.new( + customer: { "data": { "type": 'customer', "id": '751009' } } + ).to_hash + }} + response = api_instance.create_account(request) expect(response.data.type).to eq('depositAccount') end + + it 'Should create a credit account' do request = { data: OpenapiClient::CreateCreditAccount.new(type: 'creditAccount', attributes: @@ -35,12 +36,12 @@ credit_limit: 20_000, tags: { "purpose": 'tax' } } ), - relationships: OpenapiClient::CreateCreditAccountRelationships.new( + relationships: OpenapiClient::CreateDepositAccountRelationships.new( customer: { "data": { "type": 'customer', "id": '851228' } } ).to_hash).to_hash } - response = api_instance.execute(request) + response = api_instance.create_account(request) expect(response.data.type).to eq('creditAccount') end end -end +end \ No newline at end of file diff --git a/unit/e2e_tests/ruby/spec/models/application_spec.rb b/unit/e2e_tests/ruby/spec/models/application_spec.rb index 1e5a678..b4661d8 100644 --- a/unit/e2e_tests/ruby/spec/models/application_spec.rb +++ b/unit/e2e_tests/ruby/spec/models/application_spec.rb @@ -7,41 +7,26 @@ RSpec.describe 'Application' do before do - # run before each test configure_tests end describe 'test attribute "id"' do - let(:client) { OpenapiClient::ApiClient.new(configuration) } + let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) } it 'should create an application' do - api_instance = OpenapiClient::CreateApplicationApi.new(client) request = { data: OpenapiClient::CreateIndividualApplication.new(type: 'individualApplication', attributes: OpenapiClient::CreateIndividualApplicationAttributes.new( ssn: '123456789', full_name: OpenapiClient::FullName.new({ first: 'John', last: 'Kenn' }), date_of_birth: Date.new(1989, 2, 1), address: ADDRESS, email: EMAIL, phone: PHONE, occupation: 'ArchitectOrEngineer', annual_income: 'UpTo10k', source_of_income: 'EmploymentOrPayrollIncome' )).to_hash } - response = api_instance.execute(request) + response = api_instance.create_application(request) expect(response.data.type).to eq('individualApplication') end it 'should upload a document for the application' do - api_instance = OpenapiClient::UploadAPDFDocumentForAnApplicationApi.new(client) - request = api_instance.execute('836683', '125214', get_document_contents) + request = api_instance.upload_application_document_file('2624618', '541996', get_document_contents) expect(request.data.type).to eq('document') end - - it 'should upload a document for the application' do - api_instance = OpenapiClient::UploadAPNGDocumentForAnApplicationApi.new(client) - request = api_instance.execute('836683', '125215', get_image_contents('./spec/picture.png')) - expect(request.data.type).to eq('document') - end - - it 'should upload a document for the application' do - api_instance = OpenapiClient::UploadAJPEGDocumentForAnApplicationApi.new(client) - request = api_instance.execute('836683', '125216', get_image_contents('./spec/check1.jpg')) - expect(request.data.type).to eq('document') - end end -end +end \ No newline at end of file diff --git a/unit/e2e_tests/ruby/spec/models/card_spec.rb b/unit/e2e_tests/ruby/spec/models/card_spec.rb index 1cb009f..0929598 100644 --- a/unit/e2e_tests/ruby/spec/models/card_spec.rb +++ b/unit/e2e_tests/ruby/spec/models/card_spec.rb @@ -9,32 +9,41 @@ end describe 'test an instance of CreateCard' do - let(:api_instance) { OpenapiClient::CreateACardApi.new(OpenapiClient::ApiClient.new(configuration)) } + let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) } + let(:account_for_business) { api_instance.create_account( + data: { + type: 'depositAccount', + attributes: OpenapiClient::CreateDepositAccountAttributes.new( + deposit_product: 'checking', + tags: { "purpose": 'checking' }, + idempotency_key: '1234567890' + ).to_hash, relationships: RELATIONSHIPS_BUSINESS }).data.id} + it 'should create an individual debit card' do - request = { data: OpenapiClient::CreateIndividualDebitCard.new(type: 'individualDebitCard', attributes: - OpenapiClient::CreateIndividualDebitCardAttributes.new( + request = { data: OpenapiClient::CreateIndividualDebitCardRequest.new(type: 'individualDebitCard', attributes: + OpenapiClient::CreateIndividualDebitCardRequestAttributes.new( { shipping_address: ADDRESS, tags: { "purpose": 'checking' }, - additional_embossed_text: 'additional_text', expiry_date: '03/27' } + additional_embossed_text: 'additional_text', expiry_date: '03/28' } ), - relationships: OpenapiClient::CardRelationships.new(account: { "data": { "type": 'depositAccount', - "id": '2002413' } })).to_hash } - response = api_instance.execute(request) + relationships: OpenapiClient::CardRelationships.new(account: { "data": { "type": 'depositAccount', + "id": '4009403' } })).to_hash } + response = api_instance.create_card(request) expect(response.data.type).to eq('individualDebitCard') end it 'should create a business debit card' do - request = { data: OpenapiClient::CreateBusinessDebitCard.new(type: 'businessDebitCard', attributes: - OpenapiClient::CreateBusinessDebitCardAttributes.new( + request = { data: OpenapiClient::CreateBusinessDebitCardRequest.new(type: 'businessDebitCard', attributes: + OpenapiClient::CreateBusinessDebitCardRequestAttributes.new( { shipping_address: ADDRESS, address: ADDRESS, full_name: FULL_NAME, phone: PHONE, email: EMAIL, date_of_birth: DATE_OF_BIRTH, nationality: 'US', ssn: SSN, tags: { "purpose": 'business' }, limits: LIMITS, idempotency_key: '1234567890', - print_only_business_name: false, expiry_date: '03/27' } + print_only_business_name: false, expiry_date: '03/28' } ), - relationships: OpenapiClient::CardRelationships.new(account: { "data": { "type": 'account', - "id": '1567861' } })).to_hash } - response = api_instance.execute(request) + relationships: OpenapiClient::CardRelationships.new(account: { "data": { "type": 'account', + "id": '3969030' } })).to_hash } + response = api_instance.create_card(request) expect(response.data.type).to eq('businessDebitCard') end end -end +end \ No newline at end of file diff --git a/unit/e2e_tests/ruby/spec/models/customer_spec.rb b/unit/e2e_tests/ruby/spec/models/customer_spec.rb index 7a5d3bf..98906d2 100644 --- a/unit/e2e_tests/ruby/spec/models/customer_spec.rb +++ b/unit/e2e_tests/ruby/spec/models/customer_spec.rb @@ -1,13 +1,3 @@ -# #Unit OpenAPI specifications -# -# An OpenAPI specifications for unit-sdk clients -# -# The version of the OpenAPI document: 0.2.0 -# -# Generated by: https://openapi-generator.tech -# OpenAPI Generator version: 6.2.1 -# - require 'spec_helper' require 'json' require 'date' @@ -20,27 +10,27 @@ configure_tests end describe 'test an instance of Customer' do - let(:api_instance) { OpenapiClient::GetCustomerApi.new(OpenapiClient::ApiClient.new(configuration)) } + let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) } it 'should get an instance of individual Customer' do - response = api_instance.execute('733576') + response = api_instance.get_customer('733576') expect(response.data.type).to eq('individualCustomer') end it 'should get an instance of individual Customer' do - response = api_instance.execute('733565') + response = api_instance.get_customer('733565') expect(response.data.type).to eq('businessCustomer') end end describe 'test an instance of list customers' do - let(:api_instance) { OpenapiClient::GetListCustomersApi.new(OpenapiClient::ApiClient.new(configuration)) } + let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) } it 'should list customers' do opts = { query_params: {"page[limit]": 10, "page[offset]": 0, "filter[email]": 'jone.doe1@unit-finance.com'}} - response = api_instance.execute(opts) + response = api_instance.get_customers_list(opts) expect(response.data[0].type).to eq('individualCustomer') end end -end +end \ No newline at end of file diff --git a/unit/e2e_tests/ruby/spec/models/payment_spec.rb b/unit/e2e_tests/ruby/spec/models/payment_spec.rb index 0a41729..dc4684e 100644 --- a/unit/e2e_tests/ruby/spec/models/payment_spec.rb +++ b/unit/e2e_tests/ruby/spec/models/payment_spec.rb @@ -11,30 +11,22 @@ end describe 'test an instance of Payment' do - let(:api_instance) { OpenapiClient::CreateAPaymentApi.new(OpenapiClient::ApiClient.new(configuration)) } + let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) } it 'should create an instance of BookPayment' do request = { data: OpenapiClient::CreateBookPayment.new(type: 'bookPayment', attributes: OpenapiClient::CreateBookPaymentAttributes.new(amount: 1000, description: 'test payment', tags: { "test": 'test-tag' }), relationships: OpenapiClient::CreateBookPaymentRelationships.new(account: { "data": { "type": 'depositAccount', "id": '27573' } }, counterparty_account: { "data": { "type": 'depositAccount', "id": '36981' } }).to_hash).to_hash } - response = api_instance.execute(request) + response = api_instance.create_payment(request) expect(response.data.type).to eq('bookPayment') end - it 'should create an instance of AchPayment' do - request = { data: OpenapiClient::CreateAchPayment.new(type: 'achPayment', attributes: - OpenapiClient::CreateAchPaymentAttributes.new(amount: 1000, direction: 'Credit', counterparty: OpenapiClient::Counterparty.new(name: 'Jane Doe', routing_number: '812345678', account_number: '27573', account_type: 'Checking'), description: 'test payment'), - relationships: OpenapiClient::CreateAchPaymentRelationships.new(account: { "data": { "type": 'account', "id": '27573' } }).to_hash).to_hash } - response = api_instance.execute(request) - expect(response.data.type).to eq('achPayment') - end - it 'should create an instance of AchPayment with plaid token' do request = { data: OpenapiClient::CreateAchPaymentPlaid.new(type: 'achPayment', attributes: OpenapiClient::CreateAchPaymentPlaidAttributes.new(amount: 1000, direction: 'Credit', description: 'test payment', plaid_processor_token: 'processor-sandbox-1424a3b1-2b56-4d46-9e11-1fdc70fd3724'), relationships: OpenapiClient::CreateAchPaymentRelationships.new(account: { "data": { "type": 'depositAccount', "id": '27573' } }).to_hash).to_hash } - response = api_instance.execute(request) + response = api_instance.create_payment(request) expect(response.data.type).to eq('achPayment') end end -end +end \ No newline at end of file diff --git a/unit/e2e_tests/ruby/spec/models/received_payment_spec.rb b/unit/e2e_tests/ruby/spec/models/received_payment_spec.rb new file mode 100644 index 0000000..1003f10 --- /dev/null +++ b/unit/e2e_tests/ruby/spec/models/received_payment_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for OpenapiClient::Payment +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +RSpec.describe 'ReceivedPayment' do + before do + configure_tests + end + + describe 'test an instance of Payment' do + let(:api_instance) { OpenapiClient::UnitApi.new(OpenapiClient::ApiClient.new(configuration)) } + + it 'should get an instance of ReceivedPayment' do + response = api_instance.get_received_payment("8266") + expect(response.data.type).to eq('achReceivedPayment') + end + + it "lists ach received payments" do + response = api_instance.get_received_payments_list({status: %w[Pending]}) + expect(response.data[0].type).to eq("achReceivedPayment") + end + + end +end \ No newline at end of file diff --git a/unit/e2e_tests/ruby/spec/spec_helper.rb b/unit/e2e_tests/ruby/spec/spec_helper.rb index 0da7b54..c76fcb3 100644 --- a/unit/e2e_tests/ruby/spec/spec_helper.rb +++ b/unit/e2e_tests/ruby/spec/spec_helper.rb @@ -17,6 +17,8 @@ def configure_tests stub_const('SSN', '123456789') stub_const('PASSPORT', '123456789') stub_const('LIMITS', OpenapiClient::CardLevelLimits.new(daily_withdrawal: 100, monthly_withdrawal: 1000)) + stub_const("RELATIONSHIPS_BUSINESS", OpenapiClient::CreateDepositAccountRelationships.new(customers: [ { "data": { "type": 'customer', + "id": '798787' } }]).to_hash) stub_const('UNIT_TOKEN', ENV['UNIT_TOKEN']) @configuration = OpenapiClient::Configuration.new.tap do |config| @@ -55,4 +57,4 @@ def get_image_contents(file_name) end config.include SpecHelper -end +end \ No newline at end of file From 65be73ed4755ebd43b76a3d4ea5ae0da0b6f5360 Mon Sep 17 00:00:00 2001 From: stymoshchuk Date: Fri, 30 Aug 2024 10:11:54 +0200 Subject: [PATCH 2/2] Py-upd-tests fix: tests updates --- package.json | 1 + unit/e2e_tests/python/account_test.py | 36 +++---- .../e2e_tests/python/application_form_test.py | 9 +- unit/e2e_tests/python/application_test.py | 93 +++---------------- .../python/authorization_request_test.py | 10 +- unit/e2e_tests/python/card_test.py | 75 ++++++++------- unit/e2e_tests/python/customer_test.py | 13 +-- unit/e2e_tests/python/helpers/helpers.py | 13 ++- unit/e2e_tests/python/payment_test.py | 22 ++--- unit/e2e_tests/python/repayment_test.py | 20 ++-- unit/e2e_tests/python/statement_test.py | 12 +-- unit/e2e_tests/python/transaction_test.py | 8 +- unit/e2e_tests/python/webhook_test.py | 13 ++- 13 files changed, 135 insertions(+), 190 deletions(-) diff --git a/package.json b/package.json index 174ea64..8402f7e 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/unit/e2e_tests/python/account_test.py b/unit/e2e_tests/python/account_test.py index 4f4b487..73b8ef4 100644 --- a/unit/e2e_tests/python/account_test.py +++ b/unit/e2e_tests/python/account_test.py @@ -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): @@ -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): @@ -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): @@ -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 @@ -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): @@ -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 @@ -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" @@ -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", @@ -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" diff --git a/unit/e2e_tests/python/application_form_test.py b/unit/e2e_tests/python/application_form_test.py index 234aaa3..9cb28e6 100644 --- a/unit/e2e_tests/python/application_form_test.py +++ b/unit/e2e_tests/python/application_form_test.py @@ -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" - diff --git a/unit/e2e_tests/python/application_test.py b/unit/e2e_tests/python/application_test.py index 25cef21..8d8c850 100644 --- a/unit/e2e_tests/python/application_test.py +++ b/unit/e2e_tests/python/application_test.py @@ -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"] @@ -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 @@ -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 @@ -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 @@ -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 @@ -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): @@ -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): @@ -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"), "jone.doe1@unit-finance.com", - 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, "richard@piedpiper.com", - Phone("1", "2025550108"), "000000002", - date_of_birth="2000-01-01", address=address), - [Trustee(full_name, "richard@piedpiper.com", 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"), "jared@piedpiper.com", - 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" - diff --git a/unit/e2e_tests/python/authorization_request_test.py b/unit/e2e_tests/python/authorization_request_test.py index 5777dda..cc7952b 100644 --- a/unit/e2e_tests/python/authorization_request_test.py +++ b/unit/e2e_tests/python/authorization_request_test.py @@ -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): @@ -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 diff --git a/unit/e2e_tests/python/card_test.py b/unit/e2e_tests/python/card_test.py index 2944a8f..93b75f6 100644 --- a/unit/e2e_tests/python/card_test.py +++ b/unit/e2e_tests/python/card_test.py @@ -1,9 +1,16 @@ import os import unittest -from e2e_tests.python.helpers.helpers import * -from swagger_client import * - +from helpers.helpers import create_api_client, create_individual_application_request, \ + create_business_application_request, create_address +from dist.pythonsdk.openapi_client.api.unit_api import UnitApi +from dist.pythonsdk.openapi_client.models import Address, CardLevelLimits, \ + CreateCardRelationships, Relationship, RelationshipData, CreateDepositAccountAttributes, \ + CreateDepositAccountRelationships, CreateDepositAccount, CreateIndividualDebitCardRequestAttributes, \ +CreateIndividualDebitCardRequest, CreateBusinessDebitCardRequestAttributes, \ +CreateBusinessDebitCardRequest, FullName, Phone, CreateBusinessVirtualDebitCardRequestAttributes,\ +CreateBusinessVirtualDebitCardRequest, CreateIndividualVirtualDebitCardRequestAttributes, CreateIndividualVirtualDebitCardRequest, \ + UpdateIndividualDebitCardAttributes, UpdateIndividualDebitCard card_types = ["individualDebitCard", "businessDebitCard", "individualVirtualDebitCard", "businessVirtualDebitCard", "businessCreditCard", "businessVirtualCreditCard"] @@ -11,7 +18,7 @@ headers = { "content-type": "application/vnd.api+json", "authorization": f"Bearer {os.environ.get('TOKEN')}", - "user-agent": "unit-python-sdk" + "user-agent": "unit-pythonsdk" } address = Address("5230 Newell Rd", city="Palo Alto", state="CA", postal_code="94303") @@ -32,7 +39,7 @@ def create_card_relationships(self, account_id: str, _type="depositAccount"): def card_list(self): - return GetListOfCardsApi(self.api_client).execute().data + return UnitApi.get_cards_list(self.api_client).execute().data def test_card_list(self): res = self.card_list() @@ -40,36 +47,36 @@ def test_card_list(self): assert card.type in card_types def test_card_list_and_get(self): - res = GetListOfCardsApi(self.api_client).execute() + res = UnitApi.get_cards_list(self.api_client).execute() assert res.included is None for card in res.data: assert card.type in card_types - response_card = GetCardApi(self.api_client).execute(card.id).data + response_card = UnitApi.get_card(self.api_client).execute(card.id).data assert card.id == response_card.id assert card.type == response_card.type def test_card_list_with_filters(self): - res = GetListOfCardsApi(self.api_client).execute(filter_status=["Active"], include="customer") + res = UnitApi.get_cards_list(self.api_client).execute(filter_status=["Active"], include="customer") assert res.included is not None for card in res.data: assert card.type in card_types assert card.attributes.status == "Active" - response_card = GetCardApi(self.api_client).execute(card.id).data + response_card = UnitApi.get_card(self.api_client).execute(card.id).data assert card.id == response_card.id assert card.type == response_card.type assert card.attributes.status == response_card.attributes.status assert card.attributes.created_at == response_card.attributes.created_at def create_individual_customer(self): - app = CreateApplicationApi(self.api_client).execute(create_individual_application_request()).data + app = UnitApi.create_application(self.api_client).execute(create_individual_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): @@ -80,7 +87,7 @@ def create_deposit_account(self): "id": customer_id}}) req = CreateDepositAccount(attributes=attributes, relationships=relationships) - response = CreateAnAccountApi(self.api_client).execute({"data": req}) + response = UnitApi.create_account(self.api_client).execute({"data": req}) return response.data def create_deposit_account_for_business(self): @@ -91,15 +98,15 @@ def create_deposit_account_for_business(self): "id": customer_id}}) req = CreateDepositAccount(attributes=attributes, relationships=relationships) - response = CreateAnAccountApi(self.api_client).execute({"data": req}) + response = UnitApi.create_account(self.api_client).execute({"data": req}) return response.data def create_individual_debit_card(self): account_id = self.create_deposit_account().id - attributes = CreateIndividualDebitCardAttributes(address, limits=limits) - req = CreateIndividualDebitCard(attributes=attributes, relationships=self.create_card_relationships(account_id)) + attributes = CreateIndividualDebitCardRequestAttributes(address, limits=limits) + req = CreateIndividualDebitCardRequest(attributes=attributes, relationships=self.create_card_relationships(account_id)) - card = CreateACardApi(self.api_client).execute({"data": req}).data + card = UnitApi.create_card(self.api_client).execute({"data": req}).data return card def test_create_individual_debit_card(self): @@ -109,12 +116,12 @@ def test_create_individual_debit_card(self): def create_business_debit_card(self): account_id = self.create_deposit_account_for_business().id - attributes = CreateBusinessDebitCardAttributes(address, address, FullName("Richard", "Hendricks"), - Phone("1", "5555555555"), "richard@piedpiper.com", "2001-08-10", + attributes = CreateBusinessDebitCardRequestAttributes(address, address, FullName(first="Richard", last="Hendricks"), + Phone(country_code="1", number="5555555555"), "richard@piedpiper.com", "2001-08-10", limits=limits) - req = CreateBusinessDebitCard(attributes=attributes, relationships=self.create_card_relationships(account_id)) + req = CreateBusinessDebitCardRequest(attributes=attributes, relationships=self.create_card_relationships(account_id)) - card = CreateACardApi(self.api_client).execute({"data": req}).data + card = UnitApi.create_card(self.api_client).execute({"data": req}).data return card def test_create_business_debit_card(self): @@ -124,12 +131,12 @@ def test_create_business_debit_card(self): def create_business_virtual_debit_card(self): account_id = self.create_deposit_account_for_business().id - attributes = CreateBusinessVirtualDebitCardAttributes(address, FullName("Richard", "Hendricks"), + attributes = CreateBusinessVirtualDebitCardRequestAttributes(address, FullName("Richard", "Hendricks"), Phone("1", "5555555555"), "richard@piedpiper.com", "2001-08-10", limits=limits) - req = CreateBusinessVirtualDebitCard(attributes=attributes, relationships=self.create_card_relationships(account_id)) + req = CreateBusinessVirtualDebitCardRequest(attributes=attributes, relationships=self.create_card_relationships(account_id)) - card = CreateACardApi(self.api_client).execute({"data": req}).data + card = UnitApi.create_card(self.api_client).execute({"data": req}).data return card def test_create_business_virtual_debit_card(self): @@ -139,11 +146,11 @@ def test_create_business_virtual_debit_card(self): def create_individual_virtual_debit_card(self): account_id = self.create_deposit_account().id - attributes = CreateIndividualVirtualDebitCardAttributes(limits=limits) - req = CreateIndividualVirtualDebitCard(attributes=attributes, + attributes = CreateIndividualVirtualDebitCardRequestAttributes(limits=limits) + req = CreateIndividualVirtualDebitCardRequest(attributes=attributes, relationships=self.create_card_relationships(account_id)) - card = CreateACardApi(self.api_client).execute({"data": req}).data + card = UnitApi.create_card(self.api_client).execute({"data": req}).data return card def test_create_individual_virtual_debit_card(self): @@ -153,14 +160,14 @@ def test_create_individual_virtual_debit_card(self): def test_freeze_and_unfreeze_card(self): card = self.create_individual_debit_card() assert card.type == "individualDebitCard" - response = FreezeACardApi(self.api_client).execute(card.id).data + response = UnitApi.freeze_card(self.api_client).execute(card.id).data assert response.attributes.status == "Frozen" - response = UnfreezeACardApi(self.api_client).execute(card.id).data + response = UnitApi.unfreeze_card(self.api_client).execute(card.id).data assert response.attributes.status != "Frozen" def test_close_card(self): card = self.create_individual_debit_card() - response = CloseACardApi(self.api_client).execute(card.id).data + response = UnitApi.close_card(self.api_client).execute(card.id).data assert response.attributes.status == "ClosedByCustomer" # def test_replace_card(self): @@ -172,15 +179,15 @@ def test_close_card(self): def test_get_debit_card(self): card = self.create_individual_debit_card() - response = GetCardApi(self.api_client).execute(card.id) + response = UnitApi.get_card(self.api_client).execute(card.id) assert response.data.type in card_types def test_update_individual_card(self): card = self.create_individual_debit_card() _address = create_address("1818 Pennsylvania Avenue Northwest", "Washington", "CA", "21500", "US") - _attributes = PatchIndividualDebitCardAttributes(shipping_address=_address, tags={"test": "updated"}) - request = PatchIndividualDebitCard(type="individualDebitCard",attributes=_attributes) - response = UpdateCardApi(self.api_client).execute(card_id=card.id,body={"data": request}) + _attributes = UpdateIndividualDebitCardAttributes(shipping_address=_address, tags={"test": "updated"}) + request = UpdateIndividualDebitCard(type="individualDebitCard",attributes=_attributes) + response = UnitApi.update_card(self.api_client).execute(card_id=card.id,body={"data": request}) assert response.data.type == "individualDebitCard" def test_get_pin_status(self): @@ -191,7 +198,7 @@ def test_get_pin_status(self): if card_status == "active": card_id = card.id if card_id: - pin_status = GetCardPINStatusApi(self.api_client).execute(card_id=card_id) + pin_status = UnitApi.get_card_pin_status(self.api_client).execute(card_id=card_id) assert pin_status.type == "pinStatus" diff --git a/unit/e2e_tests/python/customer_test.py b/unit/e2e_tests/python/customer_test.py index 70d965f..841262d 100644 --- a/unit/e2e_tests/python/customer_test.py +++ b/unit/e2e_tests/python/customer_test.py @@ -1,7 +1,8 @@ import os import unittest -from e2e_tests.python.helpers.helpers import * -from swagger_client import * +from helpers.helpers import * +from dist.pythonsdk.openapi_client.api.unit_api import UnitApi +from dist.pythonsdk.openapi_client.models import * CustomerTypes = ["individualCustomer", "businessCustomer"] @@ -30,12 +31,12 @@ def tearDown(self): pass def list_customers(self): - return GetListCustomersApi(self.api_client).execute() + return UnitApi.get_customers_list(self.api_client).execute() def test_get_customer(self): customers = self.list_customers() for customer in customers.data: - GetCustomerApi(self.api_client).execute(customer.id) + UnitApi.get_customer(self.api_client).execute(customer.id) assert customer.type in CustomerTypes def test_list_customers(self): @@ -48,7 +49,7 @@ def get_customer(self, customer_type='individualCustomer'): for customer in customers.data: if customer.type == customer_type: - return GetCustomerApi(self.api_client).execute(customer.id) + return UnitApi.get_customer(self.api_client).execute(customer.id) return None @@ -57,7 +58,7 @@ def test_update_individual_customer(self): _attributes = UpdateIndividualCustomerAttributes(address=_address, tags={"test": "updated"}) request = UpdateIndividualCustomer(type="individualCustomer", attributes=_attributes) - response = UpdateCustomerApi(self.api_client).execute(customer_id=self.get_customer().data.id, body={"data": request}) + response = UnitApi.update_customer(self.api_client).execute(customer_id=self.get_customer().data.id, body={"data": request}) assert response.data.type == "individualCustomer" if __name__ == '__main__': diff --git a/unit/e2e_tests/python/helpers/helpers.py b/unit/e2e_tests/python/helpers/helpers.py index 641b0bc..a921563 100644 --- a/unit/e2e_tests/python/helpers/helpers.py +++ b/unit/e2e_tests/python/helpers/helpers.py @@ -2,7 +2,8 @@ import os from dotenv import load_dotenv from datetime import date, timedelta -from swagger_client import configuration, api_client, Address, CreateIndividualApplicationAttributes, FullName, Phone \ +from dist.pythonsdk.openapi_client import (configuration, api_client) +from dist.pythonsdk.openapi_client.models import Address, CreateIndividualApplicationAttributes, FullName, Phone \ , CreateIndividualApplication, CreateBusinessApplication, CreateBusinessApplicationAttributes, BeneficialOwner, \ Contact, Officer, CreateBeneficialOwner @@ -32,14 +33,18 @@ def create_individual_application_request(ssn="721074426"): address = Address(street="1600 Pennsylvania Avenue Northwest", city="Washington", state="CA", postal_code="20500", country="US") - attr = CreateIndividualApplicationAttributes(FullName("Peter", "Parker"), "jone.doe1@unit-finance.com", - Phone("1", "2025550108"), ssn, + attr = CreateIndividualApplicationAttributes(full_name = FullName(first="Peter", last="Parker"),email = "jone.doe1@unit-finance.com", + phone =Phone(country_code = "1", number = "2025550108"), ssn = ssn, address=address, date_of_birth="2001-08-10", idempotency_key=str(uuid.uuid1()), jwt_subject="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9fQ", occupation="ArchitectOrEngineer") - return {"data": CreateIndividualApplication(attributes=attr)} + individual_application = CreateIndividualApplication( + type='individualApplication', # This must exactly match the expected enum value + attributes=attr # This should be an instance of CreateIndividualApplicationAttributes + ) + return {"data": individual_application} def create_business_application_request(): diff --git a/unit/e2e_tests/python/payment_test.py b/unit/e2e_tests/python/payment_test.py index 8b9301b..969d172 100644 --- a/unit/e2e_tests/python/payment_test.py +++ b/unit/e2e_tests/python/payment_test.py @@ -1,12 +1,8 @@ import unittest -from e2e_tests.helpers import create_api_client, create_individual_application_request, create_relationship, \ - create_counterparty_dto, create_wire_counterparty_dto -from swagger_client import CreateBookPayment, CreateBookPaymentAttributes, \ - CreateBookPaymentRelationships, CreateDepositAccountAttributes, CreateDepositAccountRelationships, \ - CreateDepositAccount, CreateAnAccountApi, CreateAPaymentApi, CreateApplicationApi, CreateAchPayment, \ - CreateAchPaymentAttributes, CreateAchPaymentRelationships, Address, CreateWirePayment, CreateWirePaymentAttributes, \ - CreateAchPaymentPlaid, CreateAchPaymentPlaidAttributes +from helpers.helpers import * +from dist.pythonsdk.openapi_client.models import * +from dist.pythonsdk.openapi_client.api.unit_api import UnitApi class TestPaymentApi(unittest.TestCase): @@ -19,7 +15,7 @@ def tearDown(self): pass def create_individual_customer(self): - app = CreateApplicationApi(self.api_client).create_application(create_individual_application_request()).data + app = UnitApi.create_application(self.api_client).create_application(create_individual_application_request()).data return app.relationships.customer.data.id def create_deposit_account(self): @@ -30,7 +26,7 @@ def create_deposit_account(self): "id": customer_id}}) req = CreateDepositAccount("depositAccount", attributes, relationships) - response = CreateAnAccountApi(self.api_client).create_account({"data": req}) + response = UnitApi.create_account(self.api_client).create_account({"data": req}) return response.data.id # def test_get_payments_list(self): @@ -55,7 +51,7 @@ def test_create_book_payment(self): relationships = CreateBookPaymentRelationships(create_relationship("depositAccount", id1), create_relationship("depositAccount", id2)) req = CreateBookPayment("bookPayment", attributes, relationships) - res = CreateAPaymentApi(self.api_client).execute({"data": req}) + res = UnitApi.create_payment(self.api_client).execute({"data": req}) assert res.data.type == "bookPayment" @@ -67,7 +63,7 @@ def test_create_inline_ach_payment(self): relationships = CreateAchPaymentRelationships(create_relationship("depositAccount", account_id)) req = CreateAchPayment("achPayment", attributes, relationships) - res = CreateAPaymentApi(self.api_client).execute({"data": req}) + res = UnitApi.create_payment(self.api_client).execute({"data": req}) assert res.data.type == "achPayment" @@ -82,7 +78,7 @@ def test_create_wire_payment(self): req = CreateWirePayment("wirePayment", attributes, relationships) - res = CreateAPaymentApi(self.api_client).execute({"data": req}) + res = UnitApi.create_payment(self.api_client).execute({"data": req}) assert res.data.type == "wirePayment" @@ -95,7 +91,7 @@ def test_create_verified_ach_payment(self): relationships = CreateAchPaymentRelationships(create_relationship("depositAccount", account_id)) req = CreateAchPaymentPlaid("achPayment", attributes, relationships) - res = CreateAPaymentApi(self.api_client).execute({"data": req}) + res = UnitApi.create_payment(self.api_client).execute({"data": req}) assert res.data.type == "achPayment" diff --git a/unit/e2e_tests/python/repayment_test.py b/unit/e2e_tests/python/repayment_test.py index c6ba7a3..fe5f7b7 100644 --- a/unit/e2e_tests/python/repayment_test.py +++ b/unit/e2e_tests/python/repayment_test.py @@ -2,13 +2,9 @@ import unittest -from e2e_tests.python.helpers.helpers import create_api_client -from swagger_client import GetListRepaymentsApi, GetRepaymentApi, CreateBookRepaymentRelationships, Relationship, \ - RelationshipData -from swagger_client.api import CreateARepaymentApi -from swagger_client.models.create_book_repayment import CreateBookRepayment -from swagger_client.models.create_book_repayment_attributes import CreateBookRepaymentAttributes -from swagger_client.models.repayments_body import RepaymentsBody +from helpers.helpers import * +from dist.pythonsdk.openapi_client.api.unit_api import UnitApi +from dist.pythonsdk.openapi_client.models import * class TestRepaymentsApi(unittest.TestCase): @@ -21,13 +17,13 @@ def tearDown(self): pass def test_list_repayments(self): - res = GetListRepaymentsApi(self.api_client).execute() + res = UnitApi.get_repayments_list(self.api_client).execute() for app in res.data: assert "Repayment" in app.type def test_list_and_get_repayments(self): - res = GetListRepaymentsApi(self.api_client).execute() - get_repayment_api = GetRepaymentApi(self.api_client) + res = UnitApi.get_repayments_list(self.api_client).execute() + get_repayment_api = UnitApi.get_repayment(self.api_client) for app in res.data: assert "Repayment" in app.type @@ -42,8 +38,8 @@ def test_create_book_repayment(self): Relationship(RelationshipData("1538445", "creditAccount")), Relationship(RelationshipData("447232", "account"))) data = CreateBookRepayment(attributes=attr, relationships=relationships) - body = RepaymentsBody(data) - res = CreateARepaymentApi(self.api_client).execute(body) + # body = RepaymentsBody(data) + res = UnitApi.create_repayment(self.api_client).execute(data) assert res.data.type == "bookRepayment" diff --git a/unit/e2e_tests/python/statement_test.py b/unit/e2e_tests/python/statement_test.py index 96086e4..06890fa 100644 --- a/unit/e2e_tests/python/statement_test.py +++ b/unit/e2e_tests/python/statement_test.py @@ -1,8 +1,8 @@ import unittest -from e2e_tests.python.helpers.helpers import create_api_client -from swagger_client import GetListStatementsApi, GetStatementPDFApi, GetStatementHTMLApi - +from helpers.helpers import * +from dist.pythonsdk.openapi_client.api.unit_api import UnitApi +from dist.pythonsdk.openapi_client.models import * class TestStatementApi(unittest.TestCase): """StatementAPI unit test stubs""" @@ -14,18 +14,18 @@ def tearDown(self): pass def test_list_and_get_statements(self): - statements = GetListStatementsApi(self.api_client).execute().data + statements = UnitApi.get_statements_list(self.api_client).execute().data for s in statements: assert s.type == "accountStatementDTO" - pdf_statement = GetStatementPDFApi(self.api_client).execute(s.id) + pdf_statement = UnitApi.get_statement_pdf(self.api_client).execute(s.id) assert "PDF" in pdf_statement # account_id = s.relationships["account"].id # pdf_response = client.statements.get_bank_verification(account_id).data - html_statement = GetStatementHTMLApi(self.api_client).execute(s.id) + html_statement = UnitApi.get_statement_html(self.api_client).execute(s.id) assert "" in html_statement if __name__ == '__main__': diff --git a/unit/e2e_tests/python/transaction_test.py b/unit/e2e_tests/python/transaction_test.py index 2554d95..f36f484 100644 --- a/unit/e2e_tests/python/transaction_test.py +++ b/unit/e2e_tests/python/transaction_test.py @@ -1,8 +1,8 @@ import unittest -from e2e_tests.python.helpers.helpers import create_api_client -from swagger_client import GetListTransactionsApi - +from helpers.helpers import * +from dist.pythonsdk.openapi_client.api.unit_api import UnitApi +from dist.pythonsdk.openapi_client.models import * class TestTransactionApi(unittest.TestCase): """TransactionApi unit test stubs""" @@ -14,7 +14,7 @@ def tearDown(self): pass def test_get_list_transactions(self): - response = GetListTransactionsApi(self.api_client).execute() + response = UnitApi.get_transactions_list(self.api_client).execute() for t in response.data: assert "Transaction" in t.type # res = GetPaymentApi(self.api_client).execute(p.id).data diff --git a/unit/e2e_tests/python/webhook_test.py b/unit/e2e_tests/python/webhook_test.py index ec4270d..25c4b20 100644 --- a/unit/e2e_tests/python/webhook_test.py +++ b/unit/e2e_tests/python/webhook_test.py @@ -1,9 +1,8 @@ import unittest -from e2e_tests.python.helpers.helpers import create_api_client -from swagger_client import GetListWebhooksApi, CreateWebhookApi -from swagger_client.models.webhooks_data import WebhooksData -from swagger_client.models.webhooks_data_attributes import WebhooksDataAttributes +from helpers.helpers import * +from dist.pythonsdk.openapi_client.api.unit_api import UnitApi +from dist.pythonsdk.openapi_client.models import * class TestWebhookApi(unittest.TestCase): @@ -16,15 +15,15 @@ def tearDown(self): pass def test_get_list_webhooks(self): - response = GetListWebhooksApi(self.api_client).execute() + response = UnitApi.get_webhooks_list(self.api_client).execute() for w in response.data: assert w.type == "webhook" def test_create_webhook(self): - body = WebhooksData(attributes=WebhooksDataAttributes( + body = CreateWebhook(attributes=CreateWebhookDataAttributes( "some label", "https://webhook.site/81ee6b53-fde4-4b7d-85a0-0b6249a4488d", "myToken", "Json", "AtLeastOnce", False, "OnlyAuthorizationRequest")) - response = CreateWebhookApi(self.api_client).execute({"data": body}) + response = UnitApi.create_webhook(self.api_client).execute({"data": body}) assert response.data.type == "webhook"