"""Integration tests for payment hold history.""" import pytest import requests from tests.integration.conftest import ows_abacus_account_api_client @pytest.mark.jira('ACC-3921', 'PLATFORM-4339') def test_get_account_tax_info(basic_headers, clean_db): """GET /account_tax_info endpoints.""" account_id = 123456 ows_account_client = ows_abacus_account_api_client(basic_headers) post_account = { 'account_name': 'Test Account', 'account_id': account_id, 'country_of_tax_residence': 'USA' } response_post = ows_account_client.post_account(post_account) assert response_post.status_code == 201 response_get = ows_account_client.get_tax_info_by_account_id(account_id) assert response_get.status_code == 200 assert response_get.json()['account_id'] == account_id account_tax_info_id = response_get.json()['account_tax_info_id'] response_get = ows_account_client.get_account_tax_info(account_tax_info_id) assert response_get.status_code == 200 assert response_get.json()['country_of_tax_residence'] == \ post_account['country_of_tax_residence'] assert response_get.json()['account_id'] == account_id @pytest.mark.jira('PLATFORM-4339') def test_get_account_tax_info_by_account_id_unauthorized( unauthorized_headers, clean_db): """Test GET payment terms by account id with unauthorized headers.""" account_id = 123455 ows_account_client = ows_abacus_account_api_client(unauthorized_headers) response_get_by_acc_id = ows_account_client.get_tax_info_by_account_id( account_id ) assert response_get_by_acc_id.status_code == 403 expected = { 'code': 'authorization_error', 'message': 'Unauthorized' } assert response_get_by_acc_id.json() == expected @pytest.mark.jira('PLATFORM-4339') def test_get_account_tax_info_by_id_unauthorized( basic_headers, unauthorized_headers, clean_db): """Test GET payment terms by account tax info id with unauthorized headers.""" account_id = 123456 ows_account_client = ows_abacus_account_api_client(basic_headers) post_account = { 'account_name': 'Test Account', 'account_id': account_id, 'country_of_tax_residence': 'USA' } response_post = ows_account_client.post_account(post_account) assert response_post.status_code == 201 response_get = ows_account_client.get_tax_info_by_account_id(account_id) assert response_get.status_code == 200 assert response_get.json()['account_id'] == account_id account_tax_info_id = response_get.json()['account_tax_info_id'] response_get_by_acc_tax_info_id = requests.get( f'{ows_account_client.base_url}/account-tax-info/{account_tax_info_id}', headers=unauthorized_headers ) assert response_get_by_acc_tax_info_id.status_code == 403 expected = { 'code': 'authorization_error', 'message': 'Unauthorized' } assert response_get_by_acc_tax_info_id.json() == expected @pytest.mark.jira('ACC-3921', 'PLATFORM-4339') def test_put_account_tax_info(basic_headers, clean_db): """PUT /account_tax_info endpoint.""" account_id = 123456 ows_account_client = ows_abacus_account_api_client(basic_headers) post_account = { 'account_name': 'Test Account', 'account_id': account_id, } response_post = ows_account_client.post_account(post_account) assert response_post.status_code == 201 response_get = ows_account_client.get_tax_info_by_account_id(account_id) assert response_get.status_code == 200 assert response_get.json()['account_id'] == account_id account_tax_info_id = response_get.json()['account_tax_info_id'] tax_info_update = { 'is_sba_signed': True } response_put = ows_account_client.put_account_tax_info( account_tax_info_id, tax_info_update ) assert response_put.status_code == 201 assert response_put.json()['account_id'] == account_id assert response_put.json()['is_sba_signed'] \ == tax_info_update['is_sba_signed']