Skip to content

Commit

Permalink
Initial refactoring of catalogue category repo unit tests #305
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Jun 25, 2024
1 parent 17c1397 commit f2c5e2e
Show file tree
Hide file tree
Showing 5 changed files with 1,149 additions and 1,369 deletions.
40 changes: 40 additions & 0 deletions test/mock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,50 @@

from unittest.mock import ANY

from inventory_management_system_api.models.catalogue_category import CatalogueCategoryPropertyIn

# Used for _GET_DATA's as when comparing these will not be possible to know
# at runtime
CREATED_MODIFIED_GET_DATA_EXPECTED = {"created_time": ANY, "modified_time": ANY}

# --------------------------------- CATALOGUE CATEGORIES ---------------------------------

CATALOGUE_CATEGORY_IN_DATA_NON_LEAF_NO_PARENT_A = {
"name": "Category A",
"code": "category-a",
"is_leaf": False,
"parent_id": None,
"properties": [],
}

CATALOGUE_CATEGORY_IN_DATA_NON_LEAF_NO_PARENT_B = {
"name": "Category B",
"code": "catagory-b",
"is_leaf": False,
"parent_id": None,
"properties": [],
}

CATALOGUE_CATEGORY_IN_DATA_LEAF_NO_PARENT_NO_PROPERTIES = {
"name": "Leaf Category No Parent No Properties",
"code": "leaf-category-no-parent-no-properties",
"is_leaf": True,
"parent_id": None,
"properties": [],
}

CATALOGUE_CATEGORY_IN_DATA_LEAF_NO_PARENT_WITH_PROPERTIES = {
"name": "Leaf Category No Parent With Properties",
"code": "leaf-category-no-parent-with-properties",
"is_leaf": True,
"parent_id": None,
"properties": [
CatalogueCategoryPropertyIn(name="Property A", type="number", unit="mm", mandatory=False),
CatalogueCategoryPropertyIn(name="Property B", type="boolean", mandatory=True),
],
}

# --------------------------------- SYSTEMS ---------------------------------

SYSTEM_POST_DATA_NO_PARENT_A = {
"parent_id": None,
Expand Down
12 changes: 0 additions & 12 deletions test/unit/repositories/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from pymongo.database import Database
from pymongo.results import DeleteResult, InsertOneResult, UpdateResult

from inventory_management_system_api.repositories.catalogue_category import CatalogueCategoryRepo
from inventory_management_system_api.repositories.catalogue_item import CatalogueItemRepo
from inventory_management_system_api.repositories.item import ItemRepo
from inventory_management_system_api.repositories.manufacturer import ManufacturerRepo
Expand All @@ -38,17 +37,6 @@ def fixture_database_mock() -> Mock:
return database_mock


@pytest.fixture(name="catalogue_category_repository")
def fixture_catalogue_category_repository(database_mock: Mock) -> CatalogueCategoryRepo:
"""
Fixture to create a `CatalogueCategoryRepo` instance with a mocked Database dependency.
:param database_mock: Mocked MongoDB database instance.
:return: `CatalogueCategoryRepo` instance with the mocked dependency.
"""
return CatalogueCategoryRepo(database_mock)


@pytest.fixture(name="catalogue_item_repository")
def fixture_catalogue_item_repository(database_mock: Mock) -> CatalogueItemRepo:
"""
Expand Down
Loading

0 comments on commit f2c5e2e

Please sign in to comment.