Skip to content

Commit 7d07055

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 9fe50ab commit 7d07055

9 files changed

Lines changed: 173 additions & 12 deletions

File tree

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-6587-4477",
71+
"integration.installation.id": "EXI-0022-3978-5547"
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/extensions/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55

66
@pytest.fixture
7-
def extensions_service(mpt_ops):
8-
return mpt_ops.integration.extensions
7+
def extensions_service(mpt_vendor):
8+
return mpt_vendor.integration.extensions
99

1010

1111
@pytest.fixture
12-
def async_extensions_service(async_mpt_ops):
13-
return async_mpt_ops.integration.extensions
12+
def async_extensions_service(async_mpt_vendor):
13+
return async_mpt_vendor.integration.extensions
1414

1515

1616
@pytest.fixture(scope="session")

tests/e2e/integration/extensions/test_async_extensions.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
pytestmark = [pytest.mark.flaky]
88

99

10-
@pytest.mark.skip(reason="unable to create extensions for testing")
10+
1111
def test_create_extension(async_created_extension, extension_data):
1212
result = async_created_extension.name
1313

@@ -27,7 +27,6 @@ async def test_get_extension_not_found(async_extensions_service):
2727
await async_extensions_service.get(bogus_id)
2828

2929

30-
@pytest.mark.skip(reason="unable to create extensions for testing")
3130
async def test_update_extension(
3231
async_extensions_service, async_created_extension, logo_fd, short_uuid
3332
):
@@ -40,7 +39,6 @@ async def test_update_extension(
4039
assert result.name == update_data["name"]
4140

4241

43-
@pytest.mark.skip(reason="unable to create extensions for testing")
4442
async def test_delete_extension(async_extensions_service, async_created_extension):
4543
await async_extensions_service.delete(async_created_extension.id) # act
4644

@@ -51,7 +49,6 @@ async def test_filter_extensions(async_extensions_service, extension_id):
5149
) # act
5250

5351

54-
@pytest.mark.skip(reason="unable to create extensions for testing")
5552
async def test_download_icon(async_extensions_service, async_created_extension):
5653
result = await async_extensions_service.download_icon(async_created_extension.id)
5754

tests/e2e/integration/extensions/test_sync_extensions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
]
1010

1111

12-
@pytest.mark.skip(reason="unable to create extensions for testing")
1312
def test_create_extension(created_extension, extension_data):
1413
result = created_extension.name
1514

@@ -29,7 +28,6 @@ def test_get_extension_not_found(extensions_service):
2928
extensions_service.get(bogus_id)
3029

3130

32-
@pytest.mark.skip(reason="unable to create extensions for testing")
3331
def test_update_extension(extensions_service, created_extension, logo_fd, short_uuid):
3432
update_data = {"name": f"e2e - please delete {short_uuid}"}
3533

@@ -38,7 +36,6 @@ def test_update_extension(extensions_service, created_extension, logo_fd, short_
3836
assert result.name == update_data["name"]
3937

4038

41-
@pytest.mark.skip(reason="unable to create extensions for testing")
4239
def test_delete_extension(extensions_service, created_extension):
4340
extensions_service.delete(created_extension.id) # act
4441

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)