From b81d3bb6b3a743aef2f12ad7f34baa3e294bbd79 Mon Sep 17 00:00:00 2001 From: Odysseus Chiu Date: Thu, 9 Nov 2023 14:08:32 -0800 Subject: [PATCH] lint fixes --- pay-api/src/pay_api/models/eft_short_names.py | 1 - pay-api/src/pay_api/resources/v1/eft_short_names.py | 6 ++---- pay-api/src/pay_api/services/eft_service.py | 2 +- pay-api/tests/unit/api/test_eft_short_names.py | 8 ++++---- pay-api/tests/utilities/base_test.py | 5 +++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/pay-api/src/pay_api/models/eft_short_names.py b/pay-api/src/pay_api/models/eft_short_names.py index ec0640900..cb725ef4f 100644 --- a/pay-api/src/pay_api/models/eft_short_names.py +++ b/pay-api/src/pay_api/models/eft_short_names.py @@ -18,7 +18,6 @@ from .base_model import VersionedModel -from .base_schema import BaseSchema from .db import db diff --git a/pay-api/src/pay_api/resources/v1/eft_short_names.py b/pay-api/src/pay_api/resources/v1/eft_short_names.py index 19b56f768..bf2b74103 100644 --- a/pay-api/src/pay_api/resources/v1/eft_short_names.py +++ b/pay-api/src/pay_api/resources/v1/eft_short_names.py @@ -17,13 +17,11 @@ from flask import Blueprint, current_app, jsonify, request from flask_cors import cross_origin -from pay_api.exceptions import BusinessException, error_to_response -from pay_api.schemas import utils as schema_utils +from pay_api.exceptions import BusinessException from pay_api.services.eft_short_names import EFTShortnames as EFTShortnameService from pay_api.utils.auth import jwt as _jwt from pay_api.utils.endpoints_enums import EndpointEnum from pay_api.utils.enums import Role -from pay_api.utils.errors import Error from pay_api.utils.trace import tracing as _tracing bp = Blueprint('EFT_SHORT_NAMES', __name__, url_prefix=f'{EndpointEnum.API_V1.value}/eft-shortnames') @@ -74,7 +72,7 @@ def patch_eft_shortname(short_name_id: int): request_json = request.get_json() try: - if not (EFTShortnameService.find_by_short_name_id(short_name_id)): + if not EFTShortnameService.find_by_short_name_id(short_name_id): response, status = {'message': 'The requested EFT short name could not be found.'}, \ HTTPStatus.NOT_FOUND else: diff --git a/pay-api/src/pay_api/services/eft_service.py b/pay-api/src/pay_api/services/eft_service.py index 505be37e1..f7f65128c 100644 --- a/pay-api/src/pay_api/services/eft_service.py +++ b/pay-api/src/pay_api/services/eft_service.py @@ -77,7 +77,7 @@ def create_payment(self, payment_account: PaymentAccountModel, invoice: InvoiceM @staticmethod def create_invoice_reference(invoice: InvoiceModel, payment: PaymentModel) -> InvoiceReferenceModel: """Create an invoice reference record.""" - if not(invoice_reference := InvoiceReferenceModel + if not (invoice_reference := InvoiceReferenceModel .find_any_active_reference_by_invoice_number(payment.invoice_number)): invoice_reference = InvoiceReferenceModel() diff --git a/pay-api/tests/unit/api/test_eft_short_names.py b/pay-api/tests/unit/api/test_eft_short_names.py index 5ab5e968e..982a196f6 100755 --- a/pay-api/tests/unit/api/test_eft_short_names.py +++ b/pay-api/tests/unit/api/test_eft_short_names.py @@ -28,7 +28,7 @@ from pay_api.models import Receipt as ReceiptModel from pay_api.utils.enums import InvoiceReferenceStatus, InvoiceStatus, PaymentMethod, PaymentStatus, Role from tests.utilities.base_test import ( - factory_invoice, factory_payment_account, get_claims, token_header, factory_eft_shortname) + factory_eft_shortname, factory_invoice, factory_payment_account, get_claims, token_header) def test_patch_eft_short_name(session, client, jwt, app): @@ -39,7 +39,7 @@ def test_patch_eft_short_name(session, client, jwt, app): auth_account_id='1234').save() short_name = factory_eft_shortname(short_name='TESTSHORTNAME').save() - rv = client.patch(f"/api/v1/eft-shortnames/{short_name.id}", + rv = client.patch(f'/api/v1/eft-shortnames/{short_name.id}', data=json.dumps({'accountId': '1234'}), headers=headers) shortname_dict = rv.json @@ -91,7 +91,7 @@ def test_search_eft_short_names(session, client, jwt, app): # create test data factory_eft_shortname(short_name='TESTSHORTNAME1').save() - factory_eft_shortname(short_name='TESTSHORTNAME2', auth_account_id="1234").save() + factory_eft_shortname(short_name='TESTSHORTNAME2', auth_account_id='1234').save() # Assert search returns default unmapped short names rv = client.get('/api/v1/eft-shortnames', headers=headers) @@ -167,7 +167,7 @@ def test_apply_eft_short_name_credits(session, client, jwt, app): eft_credit_2.short_name_id = short_name.id eft_credit_2.save() - rv = client.patch(f"/api/v1/eft-shortnames/{short_name.id}", + rv = client.patch(f'/api/v1/eft-shortnames/{short_name.id}', data=json.dumps({'accountId': '1234'}), headers=headers) shortname_dict = rv.json diff --git a/pay-api/tests/utilities/base_test.py b/pay-api/tests/utilities/base_test.py index bdae67036..8eb6af194 100644 --- a/pay-api/tests/utilities/base_test.py +++ b/pay-api/tests/utilities/base_test.py @@ -25,13 +25,14 @@ from faker import Faker from pay_api.models import ( - CfsAccount, Comment, DistributionCode, Invoice, InvoiceReference, Payment, PaymentAccount, PaymentLineItem, - PaymentTransaction, Receipt, RoutingSlip, Statement, StatementInvoices, StatementSettings, EFTShortnames) + CfsAccount, Comment, DistributionCode, EFTShortnames, Invoice, InvoiceReference, Payment, PaymentAccount, + PaymentLineItem, PaymentTransaction, Receipt, RoutingSlip, Statement, StatementInvoices, StatementSettings) from pay_api.utils.constants import DT_SHORT_FORMAT from pay_api.utils.enums import ( CfsAccountStatus, InvoiceReferenceStatus, InvoiceStatus, LineItemStatus, PaymentMethod, PaymentStatus, PaymentSystem, Role, RoutingSlipStatus) + token_header = { 'alg': 'RS256', 'typ': 'JWT',