"""Shared fixtures for tests.""" import datetime import os from typing import Any from unittest.mock import patch from uuid import uuid4 from abacus_common_logic.connectors.database import db from botocore.exceptions import ClientError import pytest from payee.api import create_app from payee.config import Config from payee.connectors.secure_data.dynamodb_client import get_dynamodb_resource from payee.connectors.secure_data.manager import get_local_cmp, SecureDocumentManager from payee.constants.constants import ( BANK_NUMBERS_TYPES, DOCUMENTS_AWAL_APP_BRAND, DOCUMENTS_ORCHARD_APP_BRAND, PAYONEER_ACCOUNT_STATUS_NAMES_CODES, PAYONEER_ACCOUNT_STATUSES, TAX_FORM_TYPES, WESTERN_UNION_STATUSES, ) from payee.logic.secure_document import create_secure_document_details from payee.models.tax_form import TaxFormInfo, USTaxFormW9Document from tests.constants import MOCK_AUDIT_FIELDS, MOCK_TAX_FORM_DETAILS from tests.utils.auth import MockJWTAuth MOCK_DYNAMODB_TABLE_DEFINITION = { 'KeySchema': [ {'AttributeName': 'owner', 'KeyType': 'HASH'}, # Partition key {'AttributeName': 'revision', 'KeyType': 'RANGE'}, # Range key ], 'AttributeDefinitions': [ {'AttributeName': 'owner', 'AttributeType': 'S'}, {'AttributeName': 'revision', 'AttributeType': 'S'}, ], 'ProvisionedThroughput': {'ReadCapacityUnits': 10, 'WriteCapacityUnits': 10}, } Config.ENVIRONMENT = 'test' Config.BANK_DETAILS_SERVICE_IDENTITIES = [str(uuid4())] Config.TAX_FORM_SERVICE_IDENTITIES = [str(uuid4())] Config.PAYONEER_SERVICE_IDENTITIES = [str(uuid4())] @pytest.fixture(scope='session') def mock_config(): """Mock config.""" class TestConfig(Config): """Test configuration.""" SDM_CONFIG = { 'KMS_KEY_ID': None, 'CMP': get_local_cmp(), 'DYNAMODB_TABLE_NAME': 'dynamodb_test_table', 'DYNAMODB_CONNECTION': { 'endpoint_url': os.environ.get('DYNAMODB_URL'), 'region_name': 'us-east-1', 'aws_access_key_id': os.environ.get('AWS_ACCESS_KEY_ID', 'keyId'), 'aws_secret_access_key': os.environ.get( 'AWS_SECRET_ACCESS_KEY', 'secretKey' ), }, } PAYONEER_CLIENT_ID = 'client_id' PAYONEER_CLIENT_SECRET = 'client_secret' PAYONEER_REDIRECT_URL = { DOCUMENTS_ORCHARD_APP_BRAND: DOCUMENTS_ORCHARD_APP_BRAND, DOCUMENTS_AWAL_APP_BRAND: DOCUMENTS_AWAL_APP_BRAND, } PAYONEER_WFORM_CLIENT_CREDS = ( '{"PROGRAM_ID_1":{"client_name": "client_name",' '"client_password": "client_password",' '"client_id": "client_id"},"PROGRAM_ID_2":' '{"client_name": "client_name",' '"client_password":"client_password",' '"client_id": "clent_id"}}' ) MYSQL_DB_NAME = os.environ.get( 'MYSQL_TEST_DB_NAME', Config.MYSQL_DB_NAME + '_test' ) return TestConfig @pytest.fixture(scope='session') def mock_dynamodb_table(mock_config): """Mock dynamoDB table.""" dynamodb_resource = get_dynamodb_resource( mock_config.SDM_CONFIG.get('DYNAMODB_CONNECTION') ) table_name = mock_config.SDM_CONFIG.get('DYNAMODB_TABLE_NAME') try: mock_table = dynamodb_resource.Table(table_name) mock_table.delete() except ClientError: pass try: dynamodb_resource.create_table( TableName=table_name, **MOCK_DYNAMODB_TABLE_DEFINITION ) except ClientError: pass return dynamodb_resource.Table(table_name) @pytest.fixture(scope='session') def mock_secure_document_manager(mock_dynamodb_table): """Create manager.""" sdm = SecureDocumentManager(mock_dynamodb_table, get_local_cmp()) assert sdm.crypto_provider return sdm @pytest.fixture(scope='session', autouse=True) def test_app(mock_config, mock_dynamodb_table): """Create a test application.""" return create_app(mock_config) @pytest.fixture(autouse=True) def test_app_in_context(test_app): """Push the test app onto the context.""" with test_app.app_context(): yield test_app @pytest.fixture(autouse=True) def test_app_request(test_app_in_context): """Push the test app onto the context and trigger preprocessing.""" with test_app_in_context.test_request_context(): test_app_in_context.preprocess_request() yield test_app_in_context @pytest.fixture def fixture_client(test_app_in_context): """Create a client fixture.""" with test_app_in_context.test_client() as test_client: yield test_client @pytest.fixture def fresh_db(mock_dynamodb_table): """Refresh the test database.""" top_level_tables = ( 'abacus_state', 'account', 'account_payee', 'account_payee_kyc_notification', 'account_payee_tax_form_info', 'account_payment_term', 'account_tax_info', 'account_tax_info_history', 'payee', 'payee_collaborator', 'payee_kyc_notification', 'payment_group', 'payment_minimum', 'reference_payment_entity', 'reference_payoneer_program', 'reports_tax_info', 'tax_withholding_override', ) db.session.execute('SET FOREIGN_KEY_CHECKS=0;') for table in top_level_tables: db.session.execute(f'TRUNCATE {table};') db.session.execute('SET FOREIGN_KEY_CHECKS=1;') for item in mock_dynamodb_table.scan()['Items']: mock_dynamodb_table.delete_item( Key={ attr['AttributeName']: item[attr['AttributeName']] for attr in MOCK_DYNAMODB_TABLE_DEFINITION['KeySchema'] } ) @pytest.fixture def account_fixtures(): """Create some accounts in the database.""" # Generate VALUES for accounts 1-100 to support factory sequences values = ',\n '.join( f"({i}, 'Test account {i}', '', NOW(), '', NOW())" for i in range(1, 101) ) sql = f""" INSERT INTO `account` ( account_id, account_name, created_by, created_at, last_modified_by, last_modified ) VALUES {values}; """ db.engine.execute(sql) @pytest.fixture def account_payee_fixtures(): """Create some accounts in the database.""" sql = """ INSERT INTO `account_payee` ( account_payee_id, account_id, payoneer_program_id, payoneer_payee_id, payoneer_payee_name, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 1, 1, '123456', 'Test payee 1', '', NOW(), '', NOW()), (2, 2, 1, '123457', 'Test payee 2', '', NOW(), '', NOW()), (3, 3, 1, '123458', 'Test payee 3', '', NOW(), '', NOW()), (4, 4, 1, '123459', 'Test payee 4', '', NOW(), '', NOW()), (5, 5, 1, '123460', 'Test payee 5', '', NOW(), '', NOW()), (6, 6, NULL, '123461', 'Test payee 6', '', NOW(), '', NOW()); """ db.engine.execute(sql) @pytest.fixture def payee_fixtures(): """Create some payees in the database.""" sql = """ INSERT INTO `payee` ( payee_id, reference_payment_type_id, payoneer_client_reference_id, payoneer_program_id, payee_type, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 8, '1', 1, 'collaborator', '', NOW(), '', NOW()), (2, 8, '2', 1, 'collaborator', '', NOW(), '', NOW()); """ db.engine.execute(sql) @pytest.fixture def payee_collaborator_fixtures(): """Create some payee_collaborators in the database.""" sql = """ INSERT INTO `payee_collaborator` ( payee_collaborator_id, collaborator_id, payee_id, account_id, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 1, 1, 1, '', NOW(), '', NOW()), (2, 2, 2, 1, '', NOW(), '', NOW()); """ db.engine.execute(sql) @pytest.fixture def abacus_state_fixtures(): """Create abacus_state rows.""" sql = """ INSERT INTO `abacus_state` ( parent_table_id, parent_table_name, action_name, action_status, message, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 'payee', 'banking_eligibility', 'complete', '', '', NOW(), '', NOW()), (2, 'payee', 'banking_eligibility', 'error', '', '', NOW(), '', NOW()), (3, 'payee', 'banking_eligibility', 'running', 'KYC NOTIFICATION', '', NOW(), '', NOW()); """ db.engine.execute(sql) @pytest.fixture def abacus_state_fixtures_complete(): """Create abacus_state rows (complete only).""" sql = """ INSERT INTO `abacus_state` ( parent_table_id, parent_table_name, action_name, action_status, message, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 'payee', 'banking_eligibility', 'complete', '', '', NOW(), '', NOW()), (3, 'payee', 'banking_eligibility', 'complete', '', '', NOW(), '', NOW()); """ db.engine.execute(sql) @pytest.fixture def payee_kyc_notification_fixtures(): """Create some payee kyc notification in the database.""" sql = """ INSERT INTO `payee_kyc_notification` ( payee_kyc_notification_id, payee_id, file_upload_link, requirement_id, requirement_type_id, sub_requirement_id, possible_sub_requirement_types, sub_requirement_status_id, entity_reference_id, entity_reference_type_id, created_at, created_by, last_modified, last_modified_by, deleted_at, deleted_by ) VALUES (1,2,'https://link.payoneer.com/token?xyz','151109',NULL,'109023;109026;109050;109379;1091141',NULL,NULL,NULL,NULL,'2025-07-25 04:02:20','default_user_id','2025-07-25 04:02:20','default_user_id',NULL,NULL) """ db.engine.execute(sql) @pytest.fixture def payoneer_program_fixtures(): """Create some accounts in the database.""" sql = """ INSERT INTO `reference_payoneer_program` ( payoneer_program_id, payoneer_program_name, funding_currency, reference_payment_type_id ) VALUES (1, 'random program', 'TBD', 3); """ db.engine.execute(sql) @pytest.fixture def account_payee_tax_form_info(): """Create some tax form info in the database.""" sql = """ INSERT INTO `account_payee_tax_form_info` ( account_payee_tax_form_info_id, account_payee_id, tax_form_type, signed_date, expiration_date, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 1, 'W9', '2020-01-01', null, '', NOW(), '', NOW()), (2, 2, 'W8ECI', '2020-01-01', '2022-12-31', '', NOW(), '', NOW()), (3, 3, 'W8BEN', '2022-01-01', '2035-12-31', '', NOW(), '', NOW()), (4, 4, 'W8BEN-E', '2030-01-01', '2035-12-31', '', NOW(), '', NOW()), (5, 5, 'W8IMY', '2020-01-01', '2035-12-31', '', NOW(), '', NOW()); """ db.engine.execute(sql) @pytest.fixture def tax_withholding_override_fixtures(): """Create some tax withholding overrides in the database.""" sql = """ INSERT INTO `tax_withholding_override` ( tax_withholding_override_id, account_payee_id, rate_override, certificate_expiration_date, message, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 1, 15.25, null, 'test override message', '', NOW(), '', NOW()); """ db.engine.execute(sql) @pytest.fixture def reference_payment_entity_fixtures(): """Create some reference payment types in the database.""" sql = """ INSERT INTO reference_payment_entity (reference_payment_entity_id, payment_entity_name, country_of_tax_reporting, created_by, created_at, last_modified_by, last_modified) VALUES (1, 'AWAL-UK', 'GBR', 'test', '2023-07-06 16:16:00', 'test', '2023-07-06 16:16:00'), (2, 'AWAL-US', 'USA', 'test', '2023-07-06 16:16:00', 'test', '2023-07-06 16:16:00'), (3, 'KNR-UK', 'GBR', 'test', '2023-07-06 16:16:00', 'test', '2023-07-06 16:16:00'), (4, 'KNR-NL', 'NLD', 'test', '2023-07-06 16:16:00', 'test', '2023-07-06 16:16:00'), (5, 'ORCHARD-US', 'USA', 'test', '2024-12-03 14:46:28', 'test', '2024-12-03 14:46:28'), (6, 'ORCHARD-ES', 'ESP', 'test', '2024-12-19 19:10:55', 'test', '2024-12-19 19:10:55'), (7, 'ORCHARD-UK', 'GBR', 'test', '2024-12-19 19:10:55', 'test', '2024-12-19 19:10:55'), (8, 'ORCHARD-DE', 'DEU', 'test', '2024-12-19 19:10:55', 'test', '2024-12-19 19:10:55'), (9, 'ORCHARD-NO', 'NOR', 'test', '2024-12-19 19:10:55', 'test', '2024-12-19 19:10:55'); """ db.engine.execute(sql) @pytest.fixture def account_tax_info_fixtures(): """Create some account tax info in the database.""" sql = """ INSERT INTO `account_tax_info` ( account_tax_info_id, account_id, country_of_tax_residence, is_sba_signed, is_vat_exempt, is_tax_treaty_claimed, tax_employment_type, certificate_of_residence_expiration_date, is_wht_applicable, is_resident_of_spanish_islands, wht_rate_override, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 1, 'USA', 0, 0, 0, 'Individual', null, 1, 0, null, 'test', NOW(), 'test', NOW()), (2, 2, 'GBR', 0, 0, 0, 'Individual', null, 1, 0, null, 'test', NOW(), 'test', NOW()), (3, 3, 'NLD', 0, 0, 0, 'Individual', null, 1, 0, null, 'test', NOW(), 'test', NOW()); """ db.engine.execute(sql) sql = """ INSERT INTO `account_tax_info_history` ( account_tax_info_history_id, account_tax_info_id, account_id, country_of_tax_residence, is_sba_signed, is_vat_exempt, is_tax_treaty_claimed, tax_employment_type, certificate_of_residence_expiration_date, is_wht_applicable, is_resident_of_spanish_islands, wht_rate_override, created_by, created_at, last_modified_by, last_modified ) VALUES (1, 1, 1, 'USA', 0, 0, 0, 'Individual', null, 1, 0, null, 'test', NOW(), 'test', NOW()), (2, 2, 2, 'GBR', 0, 0, 0, 'Individual', null, 1, 0, null, 'test', NOW(), 'test', NOW()), (3, 3, 3, 'NLD', 0, 0, 0, 'Individual', null, 1, 0, null, 'test', NOW(), 'test', NOW()); """ db.engine.execute(sql) @pytest.fixture def tax_form_info_w9_document(mock_config): """Get secure document for W9 tax form info.""" return USTaxFormW9Document( MOCK_TAX_FORM_DETAILS[TAX_FORM_TYPES.W9] | MOCK_AUDIT_FIELDS ) @pytest.fixture @patch('payee.logic.secure_document.get_audit_fields') def tax_form_info_secure_documents(mock_get_audit_fields, mock_config): """Create corresponding secure documents for tax form info instances.""" mock_get_audit_fields.return_value = MOCK_AUDIT_FIELDS for tax_form_info in TaxFormInfo.query.all(): tax_form_details = { **MOCK_TAX_FORM_DETAILS[tax_form_info.tax_form_type], 'account_payee_id': tax_form_info.account_payee_id, } document_class = tax_form_info.tax_form_document_class create_secure_document_details( mock_config.SDM_CONFIG, document_class, **tax_form_details ) @pytest.fixture def mock_check_details(): """Mock check payment details.""" return {'payable_to': 'Mary Berry'} @pytest.fixture def mock_western_union_details(): """Mock western union payment details.""" return {'status': WESTERN_UNION_STATUSES.ENROLLED} @pytest.fixture def mock_wire_transfer_details(): """Mock wire transfer payment details.""" return { 'account_name': 'Paul Hollywood', 'bank_account_number': '788011238', 'bank_address': 'Drury Lane', 'bank_country_code': 'GBR', 'bank_city': 'Holborn', 'bank_name': 'Bank Of GBBO', 'bank_numbers_type': BANK_NUMBERS_TYPES.DOMESTIC, 'bank_postal_code': 'WC2B 5AJ', 'bank_routing_number': '021001088', 'bank_state': 'London', 'iban': 'GB20 1000 0000 0123 4567 89', 'swift_code': 'BREAD101', } @pytest.fixture def remove_fks(): """Delete foreign keys.""" pass @pytest.fixture def mock_payee_vat_registered_tax_details(): """Return Mocked Tax Details Payload.""" return { 'vat_number': 'GB821018768', 'country_of_tax_residency_code': 'USA', 'address': { 'address_1': 'down the lane1', 'address_2': 'down the lane2', 'province': 'New York', 'city': 'Brooklyn', 'zip': '80021', 'country_code': 'UKR', }, 'business_name': 'business_name', 'business_number': 'business_number', } @pytest.fixture def mock_payee_vat_registered_tax_details_flattened(): """Return Mocked Tax Details Payload.""" return { 'vat_number': 'GB821018768', 'country_of_tax_residency_code': 'USA', 'address_1': 'down the lane1', 'address_2': 'down the lane2', 'province': 'New York', 'city': 'Brooklyn', 'zip': '80021', 'country_code': 'UKR', 'business_name': 'business_name', 'business_number': 'business_number', } @pytest.fixture def mock_payee_eu_vat_registered_tax_details(): """Return Mocked KNR EU Tax Details Payload.""" return { 'vat_number': 'SI12345678', 'country_of_tax_residency_code': 'SLV', 'address': { 'address_1': 'down the lane1', 'address_2': 'down the lane2', 'province': 'New York', 'city': 'Brooklyn', 'zip': '80021', 'country_code': 'UKR', }, 'business_name': 'business_name', 'business_number': 'business_number', } @pytest.fixture def mock_payee_gb_vat_registered_tax_details(): """Return Mocked KNR GB Tax Details Payload.""" return { 'vat_number': 'GB12345678', 'country_of_tax_residency_code': 'GB', 'address': { 'address_1': 'down the lane1', 'address_2': 'down the lane2', 'province': 'New York', 'city': 'Brooklyn', 'zip': '80021', 'country_code': 'UKR', }, 'business_name': 'business_name', 'business_number': 'business_number', } @pytest.fixture def mock_payee_es_vat_registered_tax_details() -> dict[str, Any]: """Return Mocked Orchard ES Tax Details Payload.""" return { 'local_tax_id': '12345678', 'is_vat_registered': True, 'address': { 'address_1': 'down the lane1', 'address_2': 'down the lane2', 'province': 'New York', 'city': 'Brooklyn', 'zip': '80021', 'country_code': 'UKR', }, } @pytest.fixture def mock_payee_de_tax_details() -> dict[str, Any]: """Return Mocked Orchard DE Tax Details Payload.""" return { 'local_tax_id': '12345678', 'vat_number': '0987654321', 'address': { 'address_1': 'down the lane1', 'address_2': 'down the lane2', 'province': 'New York', 'city': 'Brooklyn', 'zip': '80021', 'country_code': 'UKR', }, } @pytest.fixture def mock_payee_no_tax_details() -> dict[str, Any]: """Return Mocked Orchard NO Tax Details Payload.""" return { 'business_name': 'business_name', 'vat_number': '821018768', 'address': { 'address_1': 'down the lane1', 'address_2': 'down the lane2', 'province': 'New York', 'city': 'Brooklyn', 'zip': '80021', 'country_code': 'UKR', }, } @pytest.fixture def mock_payee_es_non_vat_registered_tax_details() -> dict[str, Any]: """Return Mocked Orchard ES Tax Details Payload.""" return { 'local_tax_id': '12345678', 'is_vat_registered': False, 'address': None, } @pytest.fixture def mock_payee_knr_details(): """Return Mocked KNR Tax Details Payload.""" return { 'w_form': {'w_form_type': 'W9', 'w_form_expiry': '2022-11-30T17:51:32Z'}, 'sap_vendor_id': 123, } @pytest.fixture def mock_payee_payoneer_details_response(): """Return Mocked Payee Payoneer Details Response.""" return { 'account_holder_id': 'account_holder_id', } @pytest.fixture def mock_payee_non_vat_registered_tax_details(): """Return Mocked Tax Details Payload.""" return {'vat_number': None, 'country_of_tax_residency_code': 'UKR'} @pytest.fixture def payoneer_registration_link_post_success(): """Return an example of a Payoneer success reponse.""" return { 'result': { 'token': '7293f06a1d524e6f80a4f0f414b0f0962010B7745A', 'registration_link': 'http://payouts.sandbox.payoneer.com/partners/lp.aspx?token=7293f06a1d524e6f80a4f0f414b0f0962010B7745A', # noqa: E501 } } @pytest.fixture def payoneer_registration_link_post_failure(): """Return an example of a Payoneer failure reponse.""" return { 'error': 'Not Found', 'error_description': 'The requested resource could not be found', 'error_details': {'code': 404, 'sub_code': None}, } @pytest.fixture def mock_payoneer_mass_payouts(): """Return an example of Mass Payouts request body.""" return [ { 'client_reference_id': 'test1', 'account_payee_id': '56732', 'description': 'Mass Payouts 1', 'currency': 'USD', 'amount': 222, }, { 'client_reference_id': 'test2', 'account_payee_id': '56733', 'description': 'Mass Payouts 2', 'currency': 'USD', 'amount': 555, }, ] @pytest.fixture def mock_payoneer_mass_payouts_collaborator(): """Return an example of Mass Payouts request body with collaborator (payee_id) entries.""" return [ { 'client_reference_id': 'split:20240101:1001', 'payee_id': 99001, 'description': 'Collaborator Payout 1', 'currency': 'USD', 'amount': 100, } ] @pytest.fixture def mock_payoneer_mass_payouts_mixed(): """Return an example of Mass Payouts request body mixing account_payee_id and payee_id entries.""" return [ { 'client_reference_id': 'mixed1', 'account_payee_id': '56732', 'description': 'Account Payout Mixed', 'currency': 'USD', 'amount': 300, }, { 'client_reference_id': 'split:20240101:1002', 'payee_id': 99002, 'description': 'Collaborator Payout Mixed', 'currency': 'USD', 'amount': 400, }, ] @pytest.fixture def mock_register_payee_individual_type_params_US(): return { 'account_payee_id': '123', 'type': 'INDIVIDUAL', 'first_name': 'firstName', 'last_name': 'lastName', 'date_of_birth': '2000-10-10', 'email': 'test@example.com', 'country_code': 'US', 'address_1': 'asdf', 'address_2': 'dfgh', 'city': 'odesa', 'province': 'AZ', 'zip': '65000', 'bank_account_type': 'PERSONAL', 'country': 'US', 'currency': 'USD', 'bank_field_details': [ {'name': 'AccountNumber', 'value': '345234552345'}, {'name': 'AccountName', 'value': 'John Smith'}, {'name': 'BankName', 'value': 'Bank of Hope'}, {'name': 'RoutingNumber', 'value': '122105155'}, {'name': 'AccountType', 'value': 'S'}, ], } @pytest.fixture def mock_register_payee_individual_type_params(): return { 'account_payee_id': '123', 'type': 'INDIVIDUAL', 'first_name': 'firstName', 'last_name': 'lastName', 'date_of_birth': '2000-10-10', 'email': 'test@example.com', 'country_code': 'DE', 'address_1': 'asdf', 'city': 'odesa', 'zip': '65000', 'bank_account_type': 'PERSONAL', 'country': 'US', 'currency': 'USD', 'bank_field_details': [ {'name': 'AccountNumber', 'value': '345234552345'}, {'name': 'AccountName', 'value': 'John Smith'}, {'name': 'BankName', 'value': 'Bank of Hope'}, {'name': 'RoutingNumber', 'value': '122105155'}, {'name': 'AccountType', 'value': 'S'}, ], } @pytest.fixture def mock_register_payee_individual_type_params_GB(): return { 'account_payee_id': '123', 'type': 'INDIVIDUAL', 'first_name': 'firstName', 'last_name': 'lastName', 'date_of_birth': '2000-10-10', 'email': 'test@example.com', 'country_code': 'GB', 'address_1': 'asdf', 'city': 'odesa', 'zip': '65000', 'bank_account_type': 'PERSONAL', 'country': 'GB', 'currency': 'USD', 'bank_field_details': [ {'name': 'AccountNumber', 'value': '345234552345'}, {'name': 'AccountName', 'value': 'John Smith'}, {'name': 'BankName', 'value': 'Bank of Hope'}, {'name': 'RoutingNumber', 'value': '122105155'}, {'name': 'AccountType', 'value': 'S'}, ], } @pytest.fixture def mock_register_payee_company_type_params(): return { 'account_payee_id': '123', 'type': 'COMPANY', 'country_code': 'US', 'address_1': 'asdf', 'address_2': 'dfgh', 'city': 'odesa', 'province': 'AZ', 'zip': '65000', 'name': 'company_name', 'bank_account_type': 'COMPANY', 'country': 'US', 'currency': 'USD', 'bank_field_details': [ {'name': 'AccountNumber', 'value': '345234552345'}, {'name': 'AccountName', 'value': 'John Smith'}, {'name': 'BankName', 'value': 'Bank of Hope'}, {'name': 'RoutingNumber', 'value': '122105155'}, {'name': 'AccountType', 'value': 'S'}, ], } @pytest.fixture def mock_payoneer_mass_payouts_bad_response(): """Return an example of bad response from Payoneer on mass payouts.""" return { 'error': 'Bad request', 'error_description': 'There are multiple validation errors.', 'error_details': { 'code': 1000, 'target': 'parameters', 'errors': [ { 'code': 1000, 'target': 'payments[0].amount', 'message': 'The specified condition was not met for "amount".', 'client_reference_id': 'test1', }, { 'code': 1000, 'target': 'payments[1].client_reference_id', 'message': '"client_reference_id" must not be empty.', }, { 'code': 1000, 'target': 'payments[2].payee_id', 'message': '"payee_id" must not be empty.', 'client_reference_id': 'test3', }, ], }, } @pytest.fixture def mock_payoneer_register_payee_bad_response(): """Return an example of bad response from Payoneer on register payee.""" return { 'error': 'Bad request', 'error_description': 'There are multiple validation errors.', 'error_details': { 'code': 1000, 'target': 'parameters', 'errors': [ { 'code': 1000, 'target': 'payout_method.bank_account_type', 'message': 'The specified type is invalid.', } ], }, } @pytest.fixture def mock_payoneer_response_status_active(): """Return an example of response from Payoneer payee active.""" return { 'result': { 'status': { 'type': PAYONEER_ACCOUNT_STATUS_NAMES_CODES[ PAYONEER_ACCOUNT_STATUSES.ACTIVE ] } } } @pytest.fixture def mock_datetime_object(): """Return a datetime object.""" return datetime.datetime(2022, 5, 4, 12, 16, 57, 474487) @pytest.fixture def mock_headers(): """Return request headers.""" return mock_abacus_headers() @pytest.fixture def mock_bypass_headers(): """Return request headers.""" return mock_documents_headers() @pytest.fixture def mock_account360_headers(): return mock_abacus_readonly_headers() @pytest.fixture def mock_identity_fields(): """Return modified_by_* fields.""" return { 'modified_at': '2023-02-09T10:13:36.372660+0000', 'modified_by': None, 'modified_by_identity': 'aksjKJASD66340ooOHSDA)D!d1s', 'modified_by_profile_id': '90000020', 'modified_by_profile_type': 'AbacusProfile', } def mock_abacus_readonly_headers(): return { 'Orchard-Profile-Id': '90000020', 'Orchard-Profile-Type': 'Account360Profile', 'Orchard-Identity-Id': 'aksjKJASD66340ooOHSDA)D!d1s', } def mock_abacus_headers(): """Return abaacus headers.""" return { 'Orchard-Profile-Id': '90000020', 'Orchard-Profile-Type': 'AbacusProfile', 'Orchard-Identity-Id': 'aksjKJASD66340ooOHSDA)D!d1s', 'Orchard-Roles': 'administrator', } def mock_documents_headers(): """Return documents headers.""" return { 'Orchard-Profile-Id': '90000020', 'Orchard-Profile-Type': 'DocumentsProfile', 'Orchard-Identity-Id': 'aksjKJASD66340ooOHSDA)D!d1s', 'Orchard-Roles': 'payee_management,vat_api_override', } @pytest.fixture def mock_jwt_auth(test_app): """Return mocked JWTAuth client.""" mock_jwtauth = MockJWTAuth() test_app.jwt_auth_client = mock_jwtauth return mock_jwtauth