Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 committed Oct 8, 2024
1 parent 636edcd commit 8fb8189
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
10 changes: 5 additions & 5 deletions auth-api/src/auth_api/resources/v1/org_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion auth-api/src/auth_api/services/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 18 additions & 14 deletions auth-api/tests/unit/api/test_org_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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),
Expand All @@ -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,
Expand All @@ -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]
Expand Down

0 comments on commit 8fb8189

Please sign in to comment.