From 5515863b24e2a852be11307b45405c33fb2b57ec Mon Sep 17 00:00:00 2001 From: Robert Segal Date: Mon, 17 Nov 2025 07:04:53 -0700 Subject: [PATCH] Added Accounts modules get endpoints e2e tests --- e2e_config.test.json | 4 ++- .../accounts/modules/test_async_modules.py | 34 +++++++++++++++++++ .../e2e/accounts/modules/test_sync_modules.py | 34 +++++++++++++++++++ tests/e2e/conftest.py | 15 ++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 tests/e2e/accounts/modules/test_async_modules.py create mode 100644 tests/e2e/accounts/modules/test_sync_modules.py diff --git a/e2e_config.test.json b/e2e_config.test.json index 6a8c1259..a93317cb 100644 --- a/e2e_config.test.json +++ b/e2e_config.test.json @@ -6,5 +6,7 @@ "accounts.account.id": "ACC-9042-0088", "accounts.buyer.account.id": "ACC-1086-6867", "accounts.buyer.id": "BUY-1591-2112", - "accounts.user_group.id": "UGR-6822-0561" + "accounts.user_group.id": "UGR-6822-0561", + "accounts.module.id": "MOD-1756", + "accounts.module.name": "Access Management" } diff --git a/tests/e2e/accounts/modules/test_async_modules.py b/tests/e2e/accounts/modules/test_async_modules.py new file mode 100644 index 00000000..f345f7de --- /dev/null +++ b/tests/e2e/accounts/modules/test_async_modules.py @@ -0,0 +1,34 @@ +import pytest + +from mpt_api_client.exceptions import MPTAPIError +from mpt_api_client.rql.query_builder import RQLQuery + + +async def test_get_module_by_id(async_mpt_ops, module_id): + module = await async_mpt_ops.accounts.modules.get(module_id) + assert module is not None + + +async def test_list_modules(async_mpt_ops): + limit = 10 + modules = await async_mpt_ops.accounts.modules.fetch_page(limit=limit) + assert len(modules) > 0 + + +async def test_get_module_by_id_not_found(async_mpt_ops, invalid_module_id): + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + await async_mpt_ops.accounts.modules.get(invalid_module_id) + + +async def test_filter_modules(async_mpt_ops, module_id, module_name): + select_fields = ["-description"] + + filtered_modules = ( + async_mpt_ops.accounts.modules.filter(RQLQuery(id=module_id)) + .filter(RQLQuery(name=module_name)) + .select(*select_fields) + ) + + modules = [filtered_module async for filtered_module in filtered_modules.iterate()] + + assert len(modules) == 1 diff --git a/tests/e2e/accounts/modules/test_sync_modules.py b/tests/e2e/accounts/modules/test_sync_modules.py new file mode 100644 index 00000000..dd121b95 --- /dev/null +++ b/tests/e2e/accounts/modules/test_sync_modules.py @@ -0,0 +1,34 @@ +import pytest + +from mpt_api_client.exceptions import MPTAPIError +from mpt_api_client.rql.query_builder import RQLQuery + + +def test_get_module_by_id(mpt_ops, module_id): + module = mpt_ops.accounts.modules.get(module_id) + assert module is not None + + +def test_list_modules(mpt_ops): + limit = 10 + modules = mpt_ops.accounts.modules.fetch_page(limit=limit) + assert len(modules) > 0 + + +def test_get_module_by_id_not_found(mpt_ops, invalid_module_id): + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + mpt_ops.accounts.modules.get(invalid_module_id) + + +def test_filter_modules(mpt_ops, module_id, module_name): + select_fields = ["-description"] + + filtered_modules = ( + mpt_ops.accounts.modules.filter(RQLQuery(id=module_id)) + .filter(RQLQuery(name=module_name)) + .select(*select_fields) + ) + + modules = list(filtered_modules.iterate()) + + assert len(modules) == 1 diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py index 69537e9a..a6461c4f 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/conftest.py @@ -123,3 +123,18 @@ def user_group_id(e2e_config): @pytest.fixture def invalid_user_group_id(): return "UGR-0000-0000" + + +@pytest.fixture +def module_id(e2e_config): + return e2e_config["accounts.module.id"] + + +@pytest.fixture +def invalid_module_id(): + return "MOD-0000" + + +@pytest.fixture +def module_name(e2e_config): + return e2e_config["accounts.module.name"]