"""Integration tests for account tax info history endpoint.""" from datetime import datetime import pytest import requests from tests.integration.conftest import ows_abacus_account_api_client @pytest.mark.jira('ACC-4139', 'PLATFORM-4339') def test_get_account_tax_info_history(basic_headers, clean_db): """GET for /account//account-tax-info-history 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_account = ows_account_client.post_account(post_account) assert response_post_account.status_code == 201 response_get = ows_account_client.get_account_tax_info_history(account_id) assert response_get.status_code == 200 assert response_get.json() == [] 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_history(account_id) assert response_get.status_code == 200 assert response_get.json() == [] # Updating account tax info will add new record for history table tax_info_update = { 'is_sba_signed': False } response_put = ows_account_client.put_account_tax_info( account_tax_info_id, tax_info_update ) assert response_put.status_code == 201 response_get = ows_account_client.get_account_tax_info_history(account_id) assert response_get.status_code == 200 assert response_get.json()[0]['account_tax_info_history_id'] == 1 assert response_get.json()[0]['account_id'] == account_id assert response_get.json()[0]['created_at'] == datetime.today().strftime('%Y-%m-%d') assert response_get.json()[0]['last_modified'] == \ datetime.today().strftime('%Y-%m-%d') @pytest.mark.jira('PLATFORM-4339') def test_get_payment_hold_history_unauthorized( clean_db, unauthorized_headers, basic_headers): """GET /account//account-tax-info-history.""" account_id = 123455 ows_account_client = ows_abacus_account_api_client(basic_headers) post_account = { 'account_name': 'Test Account', 'account_id': account_id, } response_post_account = ows_account_client.post_account(post_account) assert response_post_account.status_code == 201 response = requests.get( f'{ows_account_client.base_url}/account/{account_id}/account-tax-info-history', headers=unauthorized_headers ) assert response.status_code == 403 expected = { 'code': 'authorization_error', 'message': 'Unauthorized' } assert response.json() == expected