-
Notifications
You must be signed in to change notification settings - Fork 0
MPT-14895 E2E for catalog/authorizations #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def authorizations_service(mpt_ops): | ||
| return mpt_ops.catalog.authorizations | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def authorization_data(product_id, seller_id, account_id, short_uuid): | ||
| return { | ||
| "externalIds": {"operations": f"e2e-{short_uuid}"}, | ||
| "product": {"id": product_id}, | ||
| "owner": {"id": seller_id}, | ||
| "journal": {"firstInvoiceDate": "2025-12-01", "frequency": "1m"}, | ||
| "eligibility": {"client": True, "partner": True}, | ||
| "currency": "USD", | ||
| "notes": "e2e - please delete", | ||
| "name": "e2e - please delete", | ||
| "vendor": {"id": account_id}, | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,55 @@ | ||||||||||
| import pytest | ||||||||||
|
|
||||||||||
| from mpt_api_client.exceptions import MPTAPIError | ||||||||||
| from mpt_api_client.rql.query_builder import RQLQuery | ||||||||||
| from tests.e2e.helper import assert_async_update_resource, async_create_fixture_resource_and_delete | ||||||||||
|
|
||||||||||
| pytestmark = [pytest.mark.flaky] | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @pytest.fixture | ||||||||||
| def async_authorizations_service(async_mpt_ops): | ||||||||||
| return async_mpt_ops.catalog.authorizations | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @pytest.fixture | ||||||||||
| async def created_authorization(async_authorizations_service, authorization_data): | ||||||||||
| async with async_create_fixture_resource_and_delete( | ||||||||||
| async_authorizations_service, authorization_data | ||||||||||
| ) as authorization: | ||||||||||
| yield authorization | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def test_create_authorization(created_authorization, authorization_data): # noqa: AAA01 | ||||||||||
| assert created_authorization.name == authorization_data["name"] | ||||||||||
|
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused noqa directive. The Apply this diff: -def test_create_authorization(created_authorization, authorization_data): # noqa: AAA01
+def test_create_authorization(created_authorization, authorization_data):📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.14.7)23-23: Unused Remove unused (RUF100) 🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
|
|
||||||||||
| async def test_get_authorization(async_authorizations_service, authorization_id): | ||||||||||
| result = await async_authorizations_service.get(authorization_id) | ||||||||||
|
|
||||||||||
| assert result.id == authorization_id | ||||||||||
|
|
||||||||||
|
|
||||||||||
| async def test_filter_authorizations(async_authorizations_service, authorization_id): | ||||||||||
| select_fields = ["-description"] | ||||||||||
| filtered = async_authorizations_service.filter(RQLQuery(id=authorization_id)).select( | ||||||||||
| *select_fields | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| result = [auth async for auth in filtered.iterate()] | ||||||||||
|
|
||||||||||
| assert len(result) == 1 | ||||||||||
| assert result[0].id == authorization_id | ||||||||||
|
|
||||||||||
|
|
||||||||||
| async def test_get_authorization_not_found(async_authorizations_service): | ||||||||||
| bogus_id = "AUT-0000-0000" | ||||||||||
|
|
||||||||||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||||||||||
| await async_authorizations_service.get(bogus_id) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| async def test_update_authorization(async_authorizations_service, authorization_id, short_uuid): | ||||||||||
| await assert_async_update_resource( | ||||||||||
| async_authorizations_service, authorization_id, "notes", f"e2e test - {short_uuid}" | ||||||||||
| ) | ||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||
| import pytest | ||||||
|
|
||||||
| from mpt_api_client.exceptions import MPTAPIError | ||||||
| from mpt_api_client.rql.query_builder import RQLQuery | ||||||
| from tests.e2e.helper import assert_update_resource, create_fixture_resource_and_delete | ||||||
|
|
||||||
| pytestmark = [pytest.mark.flaky] | ||||||
|
|
||||||
|
|
||||||
| @pytest.fixture | ||||||
| def created_authorization(authorizations_service, authorization_data): | ||||||
| with create_fixture_resource_and_delete( | ||||||
| authorizations_service, authorization_data | ||||||
| ) as authorization: | ||||||
| yield authorization | ||||||
|
|
||||||
|
|
||||||
| def test_get_authorization(authorizations_service, authorization_id): | ||||||
| result = authorizations_service.get(authorization_id) | ||||||
|
|
||||||
| assert result.id == authorization_id | ||||||
|
|
||||||
|
|
||||||
| def test_create_authorization(created_authorization, authorization_data): # noqa: AAA01 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused noqa directive. The Apply this diff: -def test_create_authorization(created_authorization, authorization_data): # noqa: AAA01
+def test_create_authorization(created_authorization, authorization_data):📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.14.7)24-24: Unused Remove unused (RUF100) 🤖 Prompt for AI Agents |
||||||
| assert created_authorization.name == authorization_data["name"] | ||||||
|
|
||||||
|
|
||||||
| def test_filter_authorizations(authorizations_service, authorization_id): | ||||||
| select_fields = ["-description"] | ||||||
| filtered = authorizations_service.filter(RQLQuery(id=authorization_id)).select(*select_fields) | ||||||
|
|
||||||
| result = list(filtered.iterate()) | ||||||
|
|
||||||
| assert len(result) == 1 | ||||||
| assert result[0].id == authorization_id | ||||||
|
|
||||||
|
|
||||||
| def test_get_authorization_not_found(authorizations_service): | ||||||
| bogus_id = "AUT-0000-0000" | ||||||
|
|
||||||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||||||
| authorizations_service.get(bogus_id) | ||||||
|
|
||||||
|
|
||||||
| def test_update_authorization(authorizations_service, authorization_id, short_uuid): | ||||||
| assert_update_resource( | ||||||
| authorizations_service, authorization_id, "notes", f"e2e test - {short_uuid}" | ||||||
| ) # act | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n tests/e2e/catalog/authorizations/test_async_authorizations.py | head -30Repository: softwareone-platform/mpt-api-python-client
Length of output: 1285
🏁 Script executed:
Repository: softwareone-platform/mpt-api-python-client
Length of output: 316
🏁 Script executed:
rg "noqa" tests/e2e/catalog/authorizations/test_async_authorizations.py -nRepository: softwareone-platform/mpt-api-python-client
Length of output: 177
🏁 Script executed:
Repository: softwareone-platform/mpt-api-python-client
Length of output: 1373
🏁 Script executed:
Repository: softwareone-platform/mpt-api-python-client
Length of output: 1574
🏁 Script executed:
Repository: softwareone-platform/mpt-api-python-client
Length of output: 336
Remove unnecessary
noqa: AAA01directive on line 23.The imports on lines 1–6 are correctly sorted (stdlib, third-party, local with proper blank line separators). However, line 23 has
# noqa: AAA01which is unnecessary. flake8-aaa is installed as a dev dependency but not enabled in the ruff configuration ([tool.ruff.lint]does not include "AAA" in theselectlist). Remove this noqa directive.🤖 Prompt for AI Agents