"""Functional tests for account_payment_term_template.""" from abacus_common_logic.test_utils.helpers import get_json_body from tests.utils.factories import AccountFactory from tests.utils.factories import AccountPaymentTermTemplateFactory def test_create_account_payment_term_from_template(fixture_client): """Test to create an account payment term from template.""" account = AccountFactory.create() template = AccountPaymentTermTemplateFactory.create() template_id = template.account_payment_term_template_id post_body = {'account_id': account.account_id} uri = f'/account-payment-term-template/{template_id}/account-payment-term' res = fixture_client.post(uri, json=post_body) assert res.status_code == 201 response_data = get_json_body(res) assert response_data == { 'account_id': account.account_id, 'payment_minimum': template.payment_terms.get('payment_minimum'), 'account_payment_term_id': 1, 'payment_entity_id': template.payment_terms.get('payment_entity_id'), 'payment_schedule': template.payment_terms.get('payment_schedule'), 'currency_code': template.currency_code, 'agreement_type_id': template.payment_terms.get('agreement_type_id') }