Skip to content

Commit 45155b9

Browse files
committed
MPT-14939 E2E for audit event_types
1 parent 5306629 commit 45155b9

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from typing import Any
2+
3+
import pytest
4+
5+
from mpt_api_client import AsyncMPTClient, MPTClient
6+
from mpt_api_client.resources.audit.event_types import (
7+
AsyncEventTypesService,
8+
EventType,
9+
EventTypesService,
10+
)
11+
12+
13+
@pytest.fixture
14+
def event_types_service(mpt_vendor: MPTClient) -> EventTypesService:
15+
return mpt_vendor.audit.event_types
16+
17+
18+
@pytest.fixture
19+
def async_event_types_service(async_mpt_vendor: AsyncMPTClient) -> AsyncEventTypesService:
20+
return async_mpt_vendor.audit.event_types
21+
22+
23+
@pytest.fixture
24+
def event_type(event_types_service: EventTypesService) -> EventType:
25+
event_types = list(event_types_service.iterate())
26+
return event_types[0]
27+
28+
29+
@pytest.fixture
30+
def event_type_update_data() -> dict[str, Any]:
31+
return {
32+
"description": "Updated description for e2e testing",
33+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from typing import Any
2+
3+
import pytest
4+
5+
from mpt_api_client.exceptions import MPTAPIError
6+
from mpt_api_client.resources.audit.event_types import AsyncEventTypesService, EventType
7+
from mpt_api_client.rql.query_builder import RQLQuery
8+
9+
pytestmark = [pytest.mark.flaky]
10+
11+
12+
async def test_get_event_type(
13+
async_event_types_service: AsyncEventTypesService, event_type: EventType
14+
) -> None:
15+
result = await async_event_types_service.get(event_type.id)
16+
17+
assert result.id == event_type.id
18+
19+
20+
async def test_filter_event_types(
21+
async_event_types_service: AsyncEventTypesService, event_type: EventType
22+
) -> None:
23+
iterator = async_event_types_service.filter(RQLQuery(id=event_type.id)).iterate()
24+
25+
result = [event_type async for event_type in iterator]
26+
27+
assert len(result) == 1
28+
assert result[0].id == event_type.id
29+
30+
31+
async def test_update_event_type(
32+
async_event_types_service: AsyncEventTypesService,
33+
event_type: EventType,
34+
event_type_update_data: dict[str, Any],
35+
) -> None:
36+
result = await async_event_types_service.update(event_type.id, event_type_update_data)
37+
38+
assert result.id == event_type.id
39+
40+
41+
async def test_get_event_type_not_found(async_event_types_service: AsyncEventTypesService) -> None:
42+
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
43+
await async_event_types_service.get("EVT-000-000")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from typing import Any
2+
3+
import pytest
4+
5+
from mpt_api_client.exceptions import MPTAPIError
6+
from mpt_api_client.resources.audit.event_types import EventType, EventTypesService
7+
from mpt_api_client.rql.query_builder import RQLQuery
8+
9+
pytestmark = [pytest.mark.flaky]
10+
11+
12+
def test_get_event_type(event_types_service: EventTypesService, event_type: EventType) -> None:
13+
result = event_types_service.get(event_type.id)
14+
15+
assert result.id == event_type.id
16+
assert result.key == event_type.key
17+
18+
19+
def test_filter_event_types(event_types_service: EventTypesService, event_type: EventType) -> None:
20+
result = list(event_types_service.filter(RQLQuery(id=event_type.id)).iterate())
21+
22+
assert len(result) == 1
23+
assert result[0].id == event_type.id
24+
25+
26+
def test_update_event_type(
27+
event_types_service: EventTypesService,
28+
event_type: EventType,
29+
event_type_update_data: dict[str, Any],
30+
) -> None:
31+
result = event_types_service.update(event_type.id, event_type_update_data)
32+
33+
assert result.id == event_type.id
34+
35+
36+
def test_get_event_type_not_found(event_types_service: EventTypesService) -> None:
37+
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
38+
event_types_service.get("EVT-000-000")

0 commit comments

Comments
 (0)