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
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ dependencies = [
"pydantic-settings==2.13.1",
"pytest==9.0.3",
"pytest-playwright==0.7.2",
"pytest-retry==1.6.3",
"requests==2.32.5",
"rich==14.3.3",
]

[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["."]
addopts = "--retries=1 --alluredir=allure-results"
addopts = "--alluredir=allure-results"
markers = [
"graphql: GraphQL API tests",
"e2e: end-to-end UI tests using Playwright (require a running frontend)",
Expand All @@ -42,5 +41,5 @@ exclude = ["tests*", ".venv*"]
pythonVersion = "3.13"
venvPath = "."
venv = ".venv"
include = ["core", "dataset", "gql", "page_objects", "tests", "utils"]
include = ["core", "dataset", "gql", "page_objects", "restapi", "tests", "utils"]
extraPaths = ["."]
15 changes: 9 additions & 6 deletions tests/restapi/catalog/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Catalog module fixtures — factory fixtures for catalogs, categories, products."""

import logging
import uuid
from typing import Any, Callable, Generator

Expand All @@ -8,6 +9,8 @@
from core.clients.rest import RestClient
from restapi.operations import CatalogOperations, CategoryOperations, ProductOperations

logger = logging.getLogger(__name__)


@pytest.fixture
def catalog_ops(rest_client: RestClient, backend_base_url: str) -> CatalogOperations:
Expand Down Expand Up @@ -40,8 +43,8 @@ def _make(**overrides: Any) -> dict:
for cid in reversed(created_ids):
try:
catalog_ops.delete(cid)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed for catalog %s: %s", cid, e)


@pytest.fixture
Expand All @@ -66,8 +69,8 @@ def _make(*, catalog: dict | None = None, **overrides: Any) -> dict:
for cid in reversed(created_ids):
try:
category_ops.delete(cid)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed for category %s: %s", cid, e)


@pytest.fixture
Expand Down Expand Up @@ -98,5 +101,5 @@ def _make(*, category: dict | None = None, **overrides: Any) -> dict:
for pid in reversed(created_ids):
try:
product_ops.delete(pid)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed for product %s: %s", pid, e)
11 changes: 7 additions & 4 deletions tests/restapi/catalog/test_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- DELETE /api/assets?urls={url} (delete)
"""

import logging
import uuid

import allure
Expand All @@ -16,6 +17,8 @@
from core.clients.rest import RestClient
from restapi.operations import ProductOperations

logger = logging.getLogger(__name__)

_GITHUB_SAMPLE_URL = "https://raw.githubusercontent.com/VirtoCommerce/vc-testing-module/dev/README.md"


Expand Down Expand Up @@ -114,8 +117,8 @@ def test_asset_add_to_product(
if asset_url:
rest_client.delete(f"{backend_base_url}/api/assets", params={"urls": [asset_url]})
rest_client.delete(f"{backend_base_url}/api/assets", params={"urls": [folder]})
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand Down Expand Up @@ -175,5 +178,5 @@ def test_asset_delete(rest_client: RestClient, backend_base_url: str) -> None:
with allure.step("Cleanup folder"):
try:
rest_client.delete(f"{backend_base_url}/api/assets", params={"urls": [folder]})
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)
7 changes: 5 additions & 2 deletions tests/restapi/catalog/test_product.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Product CRUD — migrated from Katalon `API Coverage/ModuleCatalog/product*`."""

import logging
import uuid

import allure
Expand All @@ -8,6 +9,8 @@

from restapi.operations import ProductOperations, SettingsOperations

logger = logging.getLogger(__name__)


@pytest.mark.restapi
@allure.feature("Catalog / Products (REST API)")
Expand Down Expand Up @@ -125,8 +128,8 @@ def test_product_create_update_with_body(make_product, product_ops: ProductOpera
with allure.step("Cleanup cloned product"):
try:
product_ops.delete(created["id"])
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand Down
34 changes: 18 additions & 16 deletions tests/restapi/catalog_personalisation/test_personalisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
test_tag_count_get — GET /api/personalization/taggeditem/{id}/tags/count
"""

import logging
import uuid

import allure
Expand All @@ -28,6 +29,7 @@

from core.clients.rest import RestClient

logger = logging.getLogger(__name__)

_TAGS_INHERITANCE_POLICY_SETTING = "CatalogPersonalization.TagsInheritancePolicy"

Expand Down Expand Up @@ -99,8 +101,8 @@ def test_tag_put_assign_product(rest_client: RestClient, backend_base_url: str,
with allure.step("Cleanup — clear tags on the tagged item row"):
try:
_put_tagged_item(rest_client, backend_base_url, product_id, "Product", tag_label, [])
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand All @@ -126,8 +128,8 @@ def test_tag_put_assign_category(rest_client: RestClient, backend_base_url: str,
with allure.step("Cleanup — clear tags on the tagged item row"):
try:
_put_tagged_item(rest_client, backend_base_url, category_id, "Category", tag_label, [])
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand Down Expand Up @@ -230,8 +232,8 @@ def test_tag_count_get(rest_client: RestClient, backend_base_url: str, dataset:
with allure.step("Cleanup: restore original tags on the row"):
try:
_put_tagged_item(rest_client, backend_base_url, product_id, "Product", tag_label, existing_tags)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand Down Expand Up @@ -272,14 +274,14 @@ def test_tag_propagation_down_tree(rest_client: RestClient, backend_base_url: st
with allure.step("Cleanup: restore original tags on category"):
try:
_put_tagged_item(rest_client, backend_base_url, category_id, "Category", tag_label, existing_tags)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)
if original_policy is not None:
with allure.step("Restore original TagsInheritancePolicy"):
try:
rest_client.post(f"{backend_base_url}/api/platform/settings", json=[original_policy])
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand Down Expand Up @@ -333,14 +335,14 @@ def test_tag_propagation_up_tree(rest_client: RestClient, backend_base_url: str,
with allure.step("Cleanup: restore original tags on category"):
try:
_put_tagged_item(rest_client, backend_base_url, category_id, "Category", tag_label, existing_tags)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)
if original_policy is not None:
with allure.step("Restore original TagsInheritancePolicy"):
try:
rest_client.post(f"{backend_base_url}/api/platform/settings", json=[original_policy])
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand Down Expand Up @@ -369,5 +371,5 @@ def test_tag_add_to_member_groups(rest_client: RestClient, backend_base_url: str
try:
restore = {**current, "allowedValues": original_values}
rest_client.post(f"{backend_base_url}/api/platform/settings", json=[restore])
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)
19 changes: 11 additions & 8 deletions tests/restapi/catalog_publishing/test_publishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
completenessChannelEvaluate → test_completeness_channel_evaluate
"""

import logging
import uuid

import allure
Expand All @@ -18,6 +19,8 @@

from core.clients.rest import RestClient

logger = logging.getLogger(__name__)


def _create_channel(rest_client: RestClient, backend_base_url: str, name: str, catalog: dict) -> dict:
return rest_client.post(
Expand Down Expand Up @@ -51,8 +54,8 @@ def test_channel_create(rest_client: RestClient, backend_base_url: str, seed_cat
if channel_id:
try:
rest_client.delete(f"{backend_base_url}/api/completeness/channels", params={"ids": [channel_id]})
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand All @@ -73,8 +76,8 @@ def test_channel_update(rest_client: RestClient, backend_base_url: str, seed_cat
finally:
try:
rest_client.delete(f"{backend_base_url}/api/completeness/channels", params={"ids": [channel_id]})
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand All @@ -93,8 +96,8 @@ def test_channel_get(rest_client: RestClient, backend_base_url: str, seed_catalo
finally:
try:
rest_client.delete(f"{backend_base_url}/api/completeness/channels", params={"ids": [channel["id"]]})
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand Down Expand Up @@ -152,5 +155,5 @@ def test_completeness_channel_evaluate(rest_client: RestClient, backend_base_url
finally:
try:
rest_client.delete(f"{backend_base_url}/api/completeness/channels", params={"ids": [channel["id"]]})
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)
19 changes: 11 additions & 8 deletions tests/restapi/contacts/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Contacts module fixtures — operations + factory fixtures for contacts, organizations, employees, members, vendors."""

import logging
import uuid
from typing import Any, Callable, Generator

Expand All @@ -14,6 +15,8 @@
VendorOperations,
)

logger = logging.getLogger(__name__)


# ---------------------------------------------------------------- ops fixtures

Expand Down Expand Up @@ -64,8 +67,8 @@ def _make(**overrides: Any) -> dict:
for cid in reversed(created_ids):
try:
contact_ops.delete(cid)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed for contact %s: %s", cid, e)


@pytest.fixture
Expand All @@ -84,8 +87,8 @@ def _make(**overrides: Any) -> dict:
for oid in reversed(created_ids):
try:
organization_ops.delete(oid)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed for organization %s: %s", oid, e)


@pytest.fixture
Expand All @@ -106,8 +109,8 @@ def _make(**overrides: Any) -> dict:
for eid in reversed(created_ids):
try:
employee_ops.delete(eid)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed for employee %s: %s", eid, e)


@pytest.fixture
Expand All @@ -126,5 +129,5 @@ def _make(*, member_type: str = "Organization", **overrides: Any) -> dict:
for mid in reversed(created_ids):
try:
member_ops.delete(mid)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed for member %s: %s", mid, e)
7 changes: 5 additions & 2 deletions tests/restapi/contacts/test_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
contactAddAddress → test_contact_add_address
"""

import logging
import uuid

import allure
import pytest
from requests.exceptions import HTTPError

logger = logging.getLogger(__name__)

from restapi.constants import ADDRESS_TEMPLATE
from restapi.operations import ContactOperations

Expand Down Expand Up @@ -121,8 +124,8 @@ def test_contact_create_bulk(contact_ops: ContactOperations) -> None:
for cid in created_ids:
try:
contact_ops.delete(cid)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand Down
7 changes: 5 additions & 2 deletions tests/restapi/contacts/test_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
MemberGetOrganizations → test_member_get_organizations
"""

import logging
import uuid

import allure
import pytest

from restapi.operations import MemberOperations

logger = logging.getLogger(__name__)


@pytest.mark.restapi
@allure.feature("Contacts / Members (REST API)")
Expand Down Expand Up @@ -56,8 +59,8 @@ def test_member_create_bulk(member_ops: MemberOperations) -> None:
for mid in created_ids:
try:
member_ops.delete(mid)
except Exception:
pass
except Exception as e:
logger.warning("Cleanup failed: %s", e)


@pytest.mark.restapi
Expand Down
Loading
Loading