From 8fb8189fb51ebd357ca9a617458bbd379a0a73ae Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Tue, 8 Oct 2024 09:43:53 -0700 Subject: [PATCH] fix linting --- .../src/auth_api/resources/v1/org_products.py | 10 +++--- auth-api/src/auth_api/services/products.py | 2 +- auth-api/tests/unit/api/test_org_products.py | 32 +++++++++++-------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/auth-api/src/auth_api/resources/v1/org_products.py b/auth-api/src/auth_api/resources/v1/org_products.py index 6142bd3d3d..0e2483bb8f 100644 --- a/auth-api/src/auth_api/resources/v1/org_products.py +++ b/auth-api/src/auth_api/resources/v1/org_products.py @@ -63,12 +63,12 @@ def post_org_product_subscription(org_id): return {"message": schema_utils.serialize(errors)}, HTTPStatus.BAD_REQUEST try: - roles = g.jwt_oidc_token_info.get('realm_access').get('roles') - subscriptions = ProductService.create_product_subscription(int(org_id), request_json, - skip_auth=Role.SYSTEM.value in roles, - auto_approve=Role.SYSTEM.value in roles) + roles = g.jwt_oidc_token_info.get("realm_access").get("roles") + subscriptions = ProductService.create_product_subscription( + int(org_id), request_json, skip_auth=Role.SYSTEM.value in roles, auto_approve=Role.SYSTEM.value in roles + ) ProductService.update_org_product_keycloak_groups(int(org_id)) - response, status = {'subscriptions': subscriptions}, HTTPStatus.CREATED + response, status = {"subscriptions": subscriptions}, HTTPStatus.CREATED except BusinessException as exception: response, status = {"code": exception.code, "message": exception.message}, exception.status_code return response, status diff --git a/auth-api/src/auth_api/services/products.py b/auth-api/src/auth_api/services/products.py index dac26ec484..8824f78eee 100644 --- a/auth-api/src/auth_api/services/products.py +++ b/auth-api/src/auth_api/services/products.py @@ -148,7 +148,7 @@ def create_product_subscription( subscription_data: Dict[str, Any], # pylint: disable=too-many-locals is_new_transaction: bool = True, skip_auth=False, - auto_approve=False + auto_approve=False, ): """Create product subscription for the user. diff --git a/auth-api/tests/unit/api/test_org_products.py b/auth-api/tests/unit/api/test_org_products.py index f7921bb0fd..8757f130e5 100644 --- a/auth-api/tests/unit/api/test_org_products.py +++ b/auth-api/tests/unit/api/test_org_products.py @@ -154,14 +154,18 @@ def assert_product_parent_and_child_statuses(client, jwt, org_id, parent_code, p assert parent_mhr_product.get("subscriptionStatus") == parent_status -@pytest.mark.parametrize('test_name, org_product_info', [ - ('lawyer_notary', TestOrgProductsInfo.mhr_qs_lawyer_and_notaries), - ('home_manufacturers', TestOrgProductsInfo.mhr_qs_home_manufacturers), - ('home_dealers', TestOrgProductsInfo.mhr_qs_home_dealers), - ('system_no_approval', TestOrgProductsInfo.mhr_qs_home_manufacturers) -]) -def test_add_single_org_product_mhr_qualified_supplier_approve(client, jwt, session, keycloak_mock, - test_name, org_product_info): +@pytest.mark.parametrize( + "test_name, org_product_info", + [ + ("lawyer_notary", TestOrgProductsInfo.mhr_qs_lawyer_and_notaries), + ("home_manufacturers", TestOrgProductsInfo.mhr_qs_home_manufacturers), + ("home_dealers", TestOrgProductsInfo.mhr_qs_home_dealers), + ("system_no_approval", TestOrgProductsInfo.mhr_qs_home_manufacturers), + ], +) +def test_add_single_org_product_mhr_qualified_supplier_approve( + client, jwt, session, keycloak_mock, test_name, org_product_info +): """Assert that MHR sub products subscriptions can be created and approved.""" # setup user and org staff_headers = factory_auth_header(jwt=jwt, claims=TestJwtClaims.staff_role) @@ -173,8 +177,8 @@ def test_add_single_org_product_mhr_qualified_supplier_approve(client, jwt, sess assert rv.status_code == HTTPStatus.CREATED dictionary = json.loads(rv.data) - if test_name == 'system_no_approval': - user_headers = factory_auth_header(jwt=jwt, claims=TestJwtClaims.system_role) + if test_name == "system_no_approval": + user_headers = factory_auth_header(jwt=jwt, claims=TestJwtClaims.system_role) rv_products = client.post( f"/api/v1/orgs/{dictionary.get('id')}/products", data=json.dumps(org_product_info), @@ -184,7 +188,7 @@ def test_add_single_org_product_mhr_qualified_supplier_approve(client, jwt, sess assert rv_products.status_code == HTTPStatus.CREATED assert schema_utils.validate(rv_products.json, "org_product_subscriptions_response")[0] - subscription_status = 'ACTIVE' if test_name == 'system_no_approval' else 'PENDING_STAFF_REVIEW' + subscription_status = "ACTIVE" if test_name == "system_no_approval" else "PENDING_STAFF_REVIEW" assert_product_parent_and_child_statuses( client, jwt, @@ -195,9 +199,9 @@ def test_add_single_org_product_mhr_qualified_supplier_approve(client, jwt, sess subscription_status, ) - if test_name == 'system_no_approval': - return - + if test_name == "system_no_approval": + return + rv = client.get("/api/v1/tasks", headers=staff_headers, content_type="application/json") item_list = rv.json assert schema_utils.validate(item_list, "paged_response")[0]