Skip to content

Commit 3084e0f

Browse files
authored
[MPT-14881] Added Accounts modules get endpoints e2e tests (#121)
Added Accounts modules get endpoints e2e tests https://softwareone.atlassian.net/browse/MPT-14881
2 parents acee3bf + 5515863 commit 3084e0f

4 files changed

Lines changed: 86 additions & 1 deletion

File tree

e2e_config.test.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
"accounts.account.id": "ACC-9042-0088",
77
"accounts.buyer.account.id": "ACC-1086-6867",
88
"accounts.buyer.id": "BUY-1591-2112",
9-
"accounts.user_group.id": "UGR-6822-0561"
9+
"accounts.user_group.id": "UGR-6822-0561",
10+
"accounts.module.id": "MOD-1756",
11+
"accounts.module.name": "Access Management"
1012
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pytest
2+
3+
from mpt_api_client.exceptions import MPTAPIError
4+
from mpt_api_client.rql.query_builder import RQLQuery
5+
6+
7+
async def test_get_module_by_id(async_mpt_ops, module_id):
8+
module = await async_mpt_ops.accounts.modules.get(module_id)
9+
assert module is not None
10+
11+
12+
async def test_list_modules(async_mpt_ops):
13+
limit = 10
14+
modules = await async_mpt_ops.accounts.modules.fetch_page(limit=limit)
15+
assert len(modules) > 0
16+
17+
18+
async def test_get_module_by_id_not_found(async_mpt_ops, invalid_module_id):
19+
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
20+
await async_mpt_ops.accounts.modules.get(invalid_module_id)
21+
22+
23+
async def test_filter_modules(async_mpt_ops, module_id, module_name):
24+
select_fields = ["-description"]
25+
26+
filtered_modules = (
27+
async_mpt_ops.accounts.modules.filter(RQLQuery(id=module_id))
28+
.filter(RQLQuery(name=module_name))
29+
.select(*select_fields)
30+
)
31+
32+
modules = [filtered_module async for filtered_module in filtered_modules.iterate()]
33+
34+
assert len(modules) == 1
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pytest
2+
3+
from mpt_api_client.exceptions import MPTAPIError
4+
from mpt_api_client.rql.query_builder import RQLQuery
5+
6+
7+
def test_get_module_by_id(mpt_ops, module_id):
8+
module = mpt_ops.accounts.modules.get(module_id)
9+
assert module is not None
10+
11+
12+
def test_list_modules(mpt_ops):
13+
limit = 10
14+
modules = mpt_ops.accounts.modules.fetch_page(limit=limit)
15+
assert len(modules) > 0
16+
17+
18+
def test_get_module_by_id_not_found(mpt_ops, invalid_module_id):
19+
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
20+
mpt_ops.accounts.modules.get(invalid_module_id)
21+
22+
23+
def test_filter_modules(mpt_ops, module_id, module_name):
24+
select_fields = ["-description"]
25+
26+
filtered_modules = (
27+
mpt_ops.accounts.modules.filter(RQLQuery(id=module_id))
28+
.filter(RQLQuery(name=module_name))
29+
.select(*select_fields)
30+
)
31+
32+
modules = list(filtered_modules.iterate())
33+
34+
assert len(modules) == 1

tests/e2e/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,18 @@ def user_group_id(e2e_config):
123123
@pytest.fixture
124124
def invalid_user_group_id():
125125
return "UGR-0000-0000"
126+
127+
128+
@pytest.fixture
129+
def module_id(e2e_config):
130+
return e2e_config["accounts.module.id"]
131+
132+
133+
@pytest.fixture
134+
def invalid_module_id():
135+
return "MOD-0000"
136+
137+
138+
@pytest.fixture
139+
def module_name(e2e_config):
140+
return e2e_config["accounts.module.name"]

0 commit comments

Comments
 (0)