Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion e2e_config.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
34 changes: 34 additions & 0 deletions tests/e2e/accounts/modules/test_async_modules.py
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions tests/e2e/accounts/modules/test_sync_modules.py
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]