Skip to content

Commit 0ea416d

Browse files
albertsolaCopilot
andcommitted
MPT-19908: add e2e tests for /public/v1/integration/installations
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b698df7 commit 0ea416d

File tree

6 files changed

+168
-1
lines changed

6 files changed

+168
-1
lines changed

e2e_config.test.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@
6767
"notifications.category.id": "NTC-6157-0397",
6868
"notifications.message.id": "MSG-0000-6215-1019-0139",
6969
"notifications.subscriber.id": "NTS-0829-7123-7123",
70-
"integration.extension.id": "EXT-4401-0953"
70+
"integration.extension.id": "EXT-4401-0953",
71+
"integration.installation.id": "INS-0000-0000"
7172
}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ per-file-ignores = [
145145
"tests/unit/resources/catalog/test_products.py: WPS202 WPS210",
146146
"tests/e2e/integration/*.py: WPS453",
147147
"tests/e2e/integration/extensions/*.py: WPS453 WPS202",
148+
"tests/e2e/integration/installations/*.py: WPS453 WPS202",
148149
"tests/unit/resources/integration/*.py: WPS202 WPS210 WPS218 WPS453",
149150
"tests/unit/resources/integration/mixins/*.py: WPS453 WPS202",
150151
"tests/unit/resources/commerce/*.py: WPS202 WPS204",

tests/e2e/integration/installations/__init__.py

Whitespace-only changes.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import pytest
2+
3+
from mpt_api_client.exceptions import MPTAPIError
4+
5+
6+
@pytest.fixture
7+
def installations_service(mpt_ops):
8+
return mpt_ops.integration.installations
9+
10+
11+
@pytest.fixture
12+
def async_installations_service(async_mpt_ops):
13+
return async_mpt_ops.integration.installations
14+
15+
16+
@pytest.fixture(scope="session")
17+
def installation_id(e2e_config):
18+
return e2e_config["integration.installation.id"]
19+
20+
21+
@pytest.fixture
22+
def installation_data():
23+
return {
24+
"extension": {"id": "EXT-0000-0000"},
25+
"account": {"id": "ACC-0000-0000"},
26+
"modules": [],
27+
}
28+
29+
30+
@pytest.fixture
31+
def created_installation(installations_service, installation_data):
32+
installation = installations_service.create(installation_data)
33+
34+
yield installation
35+
36+
try:
37+
installations_service.delete(installation.id)
38+
except MPTAPIError as error:
39+
print(f"TEARDOWN - Unable to delete installation {installation.id}: {error.title}") # noqa: WPS421
40+
41+
42+
@pytest.fixture
43+
async def async_created_installation(async_installations_service, installation_data):
44+
installation = await async_installations_service.create(installation_data)
45+
46+
yield installation
47+
48+
try:
49+
await async_installations_service.delete(installation.id)
50+
except MPTAPIError as error:
51+
print(f"TEARDOWN - Unable to delete installation {installation.id}: {error.title}") # noqa: WPS421
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import pytest
2+
3+
from tests.e2e.helper import assert_async_service_filter_with_iterate
4+
5+
pytestmark = [pytest.mark.flaky]
6+
7+
8+
@pytest.mark.skip(reason="creates real resources; run manually only")
9+
def test_create_installation(async_created_installation, installation_data):
10+
result = async_created_installation.extension
11+
12+
assert result.id == installation_data["extension"]["id"]
13+
14+
15+
async def test_get_installation(async_installations_service, installation_id):
16+
result = await async_installations_service.get(installation_id)
17+
18+
assert result.id == installation_id
19+
20+
21+
async def test_filter_installations(async_installations_service, installation_id):
22+
await assert_async_service_filter_with_iterate(
23+
async_installations_service, installation_id, None
24+
) # act
25+
26+
27+
@pytest.mark.skip(reason="modifies real resources; run manually only")
28+
async def test_invite_installation(async_installations_service, async_created_installation):
29+
result = await async_installations_service.invite(async_created_installation.id)
30+
31+
assert result.status == "Invited"
32+
33+
34+
@pytest.mark.skip(reason="modifies real resources; run manually only")
35+
async def test_install_installation(async_installations_service, async_created_installation):
36+
result = await async_installations_service.install(async_created_installation.id)
37+
38+
assert result.status == "Installed"
39+
40+
41+
@pytest.mark.skip(reason="modifies real resources; run manually only")
42+
async def test_uninstall_installation(async_installations_service, async_created_installation):
43+
result = await async_installations_service.uninstall(async_created_installation.id)
44+
45+
assert result.status == "Uninstalled"
46+
47+
48+
@pytest.mark.skip(reason="modifies real resources; run manually only")
49+
async def test_expire_installation(async_installations_service, async_created_installation):
50+
result = await async_installations_service.expire(async_created_installation.id)
51+
52+
assert result.status == "Expired"
53+
54+
55+
@pytest.mark.skip(reason="deletes real resources; run manually only")
56+
async def test_delete_installation(async_installations_service, async_created_installation):
57+
await async_installations_service.delete(async_created_installation.id) # act
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import pytest
2+
3+
from tests.e2e.helper import assert_service_filter_with_iterate
4+
5+
pytestmark = [
6+
pytest.mark.flaky,
7+
]
8+
9+
10+
def test_get_installation(installations_service, installation_id):
11+
result = installations_service.get(installation_id)
12+
13+
assert result.id == installation_id
14+
15+
16+
def test_filter_installations(installations_service, installation_id):
17+
assert_service_filter_with_iterate(installations_service, installation_id, None) # act
18+
19+
20+
@pytest.mark.skip(reason="creates real resources; run manually only")
21+
def test_create_installation(created_installation, installation_data):
22+
result = created_installation.extension
23+
24+
assert result.id == installation_data["extension"]["id"]
25+
26+
27+
@pytest.mark.skip(reason="modifies real resources; run manually only")
28+
def test_invite_installation(installations_service, created_installation):
29+
result = installations_service.invite(created_installation.id)
30+
31+
assert result.status == "Invited"
32+
33+
34+
@pytest.mark.skip(reason="modifies real resources; run manually only")
35+
def test_install_installation(installations_service, created_installation):
36+
result = installations_service.install(created_installation.id)
37+
38+
assert result.status == "Installed"
39+
40+
41+
@pytest.mark.skip(reason="modifies real resources; run manually only")
42+
def test_uninstall_installation(installations_service, created_installation):
43+
result = installations_service.uninstall(created_installation.id)
44+
45+
assert result.status == "Uninstalled"
46+
47+
48+
@pytest.mark.skip(reason="modifies real resources; run manually only")
49+
def test_expire_installation(installations_service, created_installation):
50+
result = installations_service.expire(created_installation.id)
51+
52+
assert result.status == "Expired"
53+
54+
55+
@pytest.mark.skip(reason="deletes real resources; run manually only")
56+
def test_delete_installation(installations_service, created_installation):
57+
installations_service.delete(created_installation.id) # act

0 commit comments

Comments
 (0)