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
3 changes: 2 additions & 1 deletion e2e_config.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
"notifications.batch.id": "MST-3638-2460-4825",
"notifications.category.id": "NTC-6157-0397",
"notifications.message.id": "MSG-0000-6215-1019-0139",
"notifications.subscriber.id": "NTS-0829-7123-7123"
"notifications.subscriber.id": "NTS-0829-7123-7123",
"integration.extension.id": "EXT-4401-0953"
}
16 changes: 8 additions & 8 deletions mpt_api_client/mpt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
AsyncCatalog,
AsyncCommerce,
AsyncExchange,
AsyncExtensibility,
AsyncHelpdesk,
AsyncIntegration,
AsyncNotifications,
Audit,
Billing,
Catalog,
Commerce,
Exchange,
Extensibility,
Helpdesk,
Integration,
Notifications,
)

Expand Down Expand Up @@ -93,9 +93,9 @@ def exchange(self) -> AsyncExchange:
return AsyncExchange(http_client=self.http_client)

@property
def extensibility(self) -> AsyncExtensibility:
"""Extensibility MPT API Client."""
return AsyncExtensibility(http_client=self.http_client)
def integration(self) -> AsyncIntegration:
"""Integration MPT API Client."""
return AsyncIntegration(http_client=self.http_client)

Comment thread
albertsola marked this conversation as resolved.

class MPTClient:
Expand Down Expand Up @@ -173,6 +173,6 @@ def exchange(self) -> Exchange:
return Exchange(http_client=self.http_client)

@property
def extensibility(self) -> Extensibility:
"""Extensibility MPT API Client."""
return Extensibility(http_client=self.http_client)
def integration(self) -> Integration:
"""Integration MPT API Client."""
return Integration(http_client=self.http_client)
6 changes: 3 additions & 3 deletions mpt_api_client/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from mpt_api_client.resources.catalog import AsyncCatalog, Catalog
from mpt_api_client.resources.commerce import AsyncCommerce, Commerce
from mpt_api_client.resources.exchange import AsyncExchange, Exchange
from mpt_api_client.resources.extensibility import AsyncExtensibility, Extensibility
from mpt_api_client.resources.helpdesk import AsyncHelpdesk, Helpdesk
from mpt_api_client.resources.integration import AsyncIntegration, Integration
from mpt_api_client.resources.notifications import AsyncNotifications, Notifications

__all__ = [ # noqa: WPS410
Expand All @@ -16,15 +16,15 @@
"AsyncCatalog",
"AsyncCommerce",
"AsyncExchange",
"AsyncExtensibility",
"AsyncHelpdesk",
"AsyncIntegration",
"AsyncNotifications",
"Audit",
"Billing",
"Catalog",
"Commerce",
"Exchange",
"Extensibility",
"Helpdesk",
"Integration",
"Notifications",
]
9 changes: 0 additions & 9 deletions mpt_api_client/resources/extensibility/__init__.py

This file was deleted.

9 changes: 9 additions & 0 deletions mpt_api_client/resources/integration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from mpt_api_client.resources.integration.integration import (
AsyncIntegration,
Integration,
)

__all__ = [ # noqa: WPS410
"AsyncIntegration",
"Integration",
]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)
from mpt_api_client.models import Model
from mpt_api_client.models.model import BaseModel
from mpt_api_client.resources.extensibility.mixins import (
from mpt_api_client.resources.integration.mixins import (
AsyncExtensionMixin,
ExtensionMixin,
)
Expand Down Expand Up @@ -60,7 +60,7 @@ class Extension(Model):
class ExtensionsServiceConfig:
"""Extensions service configuration."""

_endpoint = "/public/v1/extensibility/extensions"
_endpoint = "/public/v1/integration/extensions"
_model_class = Extension
_collection_key = "data"
_upload_file_key = "icon"
Expand All @@ -77,7 +77,7 @@ class ExtensionsService(
Service[Extension],
ExtensionsServiceConfig,
):
"""Sync service for the /public/v1/extensibility/extensions endpoint."""
"""Sync service for the /public/v1/integration/extensions endpoint."""


class AsyncExtensionsService(
Expand All @@ -90,4 +90,4 @@ class AsyncExtensionsService(
AsyncService[Extension],
ExtensionsServiceConfig,
):
"""Async service for the /public/v1/extensibility/extensions endpoint."""
"""Async service for the /public/v1/integration/extensions endpoint."""
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
from mpt_api_client.resources.extensibility.extensions import (
from mpt_api_client.resources.integration.extensions import (
AsyncExtensionsService,
ExtensionsService,
)


class Extensibility:
"""Extensibility MPT API Module."""
class Integration:
"""Integration MPT API Module."""
Comment thread
albertsola marked this conversation as resolved.

def __init__(self, *, http_client: HTTPClient):
self.http_client = http_client
Expand All @@ -17,8 +17,8 @@ def extensions(self) -> ExtensionsService:
return ExtensionsService(http_client=self.http_client)


class AsyncExtensibility:
"""Async Extensibility MPT API Module."""
class AsyncIntegration:
"""Async Integration MPT API Module."""

def __init__(self, *, http_client: AsyncHTTPClient):
self.http_client = http_client
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mpt_api_client.resources.extensibility.mixins.extension_mixin import (
from mpt_api_client.resources.integration.mixins.extension_mixin import (
AsyncExtensionMixin,
ExtensionMixin,
)
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ per-file-ignores = [
"mpt_api_client/resources/catalog/products.py: WPS204 WPS214 WPS215 WPS235",
"mpt_api_client/resources/commerce/*.py: WPS235 WPS215",
"mpt_api_client/resources/exchange/*.py: WPS235 WPS215",
"mpt_api_client/resources/extensibility/*.py: WPS214 WPS215 WPS235",
"mpt_api_client/resources/integration/*.py: WPS214 WPS215 WPS235",
"mpt_api_client/resources/helpdesk/*.py: WPS204 WPS215 WPS214",
"mpt_api_client/rql/query_builder.py: WPS110 WPS115 WPS210 WPS214",
"tests/e2e/accounts/*.py: WPS430 WPS202",
Expand All @@ -143,7 +143,10 @@ per-file-ignores = [
"tests/unit/http/mixins/*: WPS204 WPS202 WPS210",
"tests/unit/resources/accounts/*.py: WPS204 WPS202 WPS210",
"tests/unit/resources/catalog/test_products.py: WPS202 WPS210",
"tests/unit/resources/extensibility/*.py: WPS202 WPS210 WPS218",
"tests/e2e/integration/*.py: WPS453",
"tests/e2e/integration/extensions/*.py: WPS453 WPS202",
"tests/unit/resources/integration/*.py: WPS202 WPS210 WPS218 WPS453",
"tests/unit/resources/integration/mixins/*.py: WPS453 WPS202",
"tests/unit/resources/commerce/*.py: WPS202 WPS204",
"tests/unit/test_mpt_client.py: WPS235",
"tests/*: WPS432 WPS202",
Expand Down
52 changes: 52 additions & 0 deletions tests/e2e/integration/extensions/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import pytest

from mpt_api_client.exceptions import MPTAPIError


@pytest.fixture
def extensions_service(mpt_ops):
return mpt_ops.integration.extensions


@pytest.fixture
def async_extensions_service(async_mpt_ops):
return async_mpt_ops.integration.extensions


@pytest.fixture(scope="session")
def extension_id(e2e_config):
return e2e_config["integration.extension.id"]


@pytest.fixture
def extension_data(short_uuid):
return {
"name": f"e2e - please delete {short_uuid}",
"shortDescription": f"E2E test extension {short_uuid}",
"longDescription": "Created by automated E2E tests. Safe to delete.",
"website": "https://example.com",
}


@pytest.fixture
def created_extension(extensions_service, extension_data, logo_fd):
extension = extensions_service.create(extension_data, file=logo_fd)

yield extension

try:
extensions_service.delete(extension.id)
except MPTAPIError as error:
print(f"TEARDOWN - Unable to delete extension {extension.id}: {error.title}") # noqa: WPS421
Comment thread
albertsola marked this conversation as resolved.


@pytest.fixture
async def async_created_extension(async_extensions_service, extension_data, logo_fd):
extension = await async_extensions_service.create(extension_data, file=logo_fd)

yield extension

try:
await async_extensions_service.delete(extension.id)
except MPTAPIError as error:
print(f"TEARDOWN - Unable to delete extension {extension.id}: {error.title}") # noqa: WPS421
74 changes: 74 additions & 0 deletions tests/e2e/integration/extensions/test_async_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import pytest

from mpt_api_client.exceptions import MPTAPIError
from mpt_api_client.models import FileModel
from tests.e2e.helper import assert_async_service_filter_with_iterate

pytestmark = [pytest.mark.flaky]


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

assert result == extension_data["name"]


async def test_get_extension(async_extensions_service, extension_id):
result = await async_extensions_service.get(extension_id)

assert result.id == extension_id


async def test_get_extension_not_found(async_extensions_service):
bogus_id = "EXT-0000-0000"

with pytest.raises(MPTAPIError, match=r"404 Not Found"):
await async_extensions_service.get(bogus_id)


@pytest.mark.skip(reason="unable to create extensions for testing")
async def test_update_extension(
async_extensions_service, async_created_extension, logo_fd, short_uuid
):
update_data = {"name": f"e2e - please delete {short_uuid}"}

result = await async_extensions_service.update(
async_created_extension.id, update_data, file=logo_fd
)

assert result.name == update_data["name"]


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


async def test_filter_extensions(async_extensions_service, extension_id):
await assert_async_service_filter_with_iterate(
async_extensions_service, extension_id, None
) # act


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

assert isinstance(result, FileModel)


@pytest.mark.skip(reason="unable to create extensions for testing")
async def test_publish_extension(async_extensions_service, async_created_extension):
result = await async_extensions_service.publish(async_created_extension.id)

assert result.status == "Public"


@pytest.mark.skip(reason="unable to create extensions for testing")
async def test_unpublish_extension(async_extensions_service, async_created_extension):
await async_extensions_service.publish(async_created_extension.id)

result = await async_extensions_service.unpublish(async_created_extension.id)

assert result.status == "Private"
70 changes: 70 additions & 0 deletions tests/e2e/integration/extensions/test_sync_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import pytest

from mpt_api_client.exceptions import MPTAPIError
from mpt_api_client.models import FileModel
from tests.e2e.helper import assert_service_filter_with_iterate

pytestmark = [
pytest.mark.flaky,
]


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

assert result == extension_data["name"]


def test_get_extension(extensions_service, extension_id):
result = extensions_service.get(extension_id)

assert result.id == extension_id


def test_get_extension_not_found(extensions_service):
bogus_id = "EXT-0000-0000"

with pytest.raises(MPTAPIError, match=r"404 Not Found"):
extensions_service.get(bogus_id)


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

result = extensions_service.update(created_extension.id, update_data, file=logo_fd)

assert result.name == update_data["name"]


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


def test_filter_extensions(extensions_service, extension_id):
assert_service_filter_with_iterate(extensions_service, extension_id, None) # act


@pytest.mark.skip(reason="unable to create extensions for testing")
def test_download_icon(extensions_service, created_extension):
result = extensions_service.download_icon(created_extension.id)

assert isinstance(result, FileModel)


@pytest.mark.skip(reason="unable to create extensions for testing")
def test_publish_extension(extensions_service, created_extension):
result = extensions_service.publish(created_extension.id)

assert result.status == "Public"


@pytest.mark.skip(reason="unable to create extensions for testing")
def test_unpublish_extension(extensions_service, created_extension):
extensions_service.publish(created_extension.id)

result = extensions_service.unpublish(created_extension.id)

assert result.status == "Private"
Loading