Skip to content

Commit

Permalink
Merge branch 'develop' into add-spares-definition-put-#413
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Nov 27, 2024
2 parents 6812453 + d9ed36a commit c0d8e7b
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 26 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: "3.12"
cache: "pip"
Expand All @@ -38,10 +38,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: "3.12"
cache: "pip"
Expand All @@ -59,7 +59,7 @@ jobs:

- name: Upload coverage reports to Codecov
if: success()
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -69,10 +69,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: "3.12"
cache: "pip"
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Login to Harbor
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
Expand All @@ -118,7 +118,7 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ${{ secrets.HARBOR_URL }}/ims-api

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Login to Harbor
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
Expand All @@ -24,7 +24,7 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ${{ secrets.HARBOR_URL }}/ims-api
tags: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12.7-alpine3.20@sha256:e75de178bc15e72f3f16bf75a6b484e33d39a456f03fc771a2b3abb9146b75f8
FROM python:3.12.7-alpine3.20@sha256:38e179a0f0436c97ecc76bcd378d7293ab3ee79e4b8c440fdc7113670cb6e204

WORKDIR /inventory-management-system-api-run

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12.7-alpine3.20@sha256:e75de178bc15e72f3f16bf75a6b484e33d39a456f03fc771a2b3abb9146b75f8
FROM python:3.12.7-alpine3.20@sha256:38e179a0f0436c97ecc76bcd378d7293ab3ee79e4b8c440fdc7113670cb6e204

WORKDIR /inventory-management-system-api-run

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
CatalogueCategoryPropertyPostSchema,
CatalogueCategoryPropertySchema,
CatalogueCategorySchema,
CATALOGUE_CATEGORY_WITH_CHILD_NON_EDITABLE_FIELDS,
)
from inventory_management_system_api.services.catalogue_category import CatalogueCategoryService
from inventory_management_system_api.services.catalogue_category_property import CatalogueCategoryPropertyService
Expand Down Expand Up @@ -185,7 +186,9 @@ def partial_update_catalogue_category(
logger.exception(message)
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=message) from exc
except ChildElementsExistError as exc:
message = "Catalogue category has child elements and cannot be updated"
message = "Catalogue category has child elements, so the following fields cannot be updated: " + ", ".join(
CATALOGUE_CATEGORY_WITH_CHILD_NON_EDITABLE_FIELDS
)
logger.exception(message)
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail=message) from exc
except DuplicateRecordError as exc:
Expand Down
5 changes: 4 additions & 1 deletion inventory_management_system_api/routers/v1/catalogue_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
CatalogueItemPatchSchema,
CatalogueItemPostSchema,
CatalogueItemSchema,
CATALOGUE_ITEM_WITH_CHILD_NON_EDITABLE_FIELDS,
)
from inventory_management_system_api.services.catalogue_item import CatalogueItemService

Expand Down Expand Up @@ -161,7 +162,9 @@ def partial_update_catalogue_item(
logger.exception(message)
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail=message) from exc
except ChildElementsExistError as exc:
message = "Catalogue item has child elements and cannot be updated"
message = "Catalogue item has child elements, so the following fields cannot be updated: " + ", ".join(
CATALOGUE_ITEM_WITH_CHILD_NON_EDITABLE_FIELDS
)
logger.exception(message)
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail=message) from exc
except InvalidActionError as exc:
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ version = "1.0.0"

dependencies = [
"cryptography==43.0.3",
"fastapi[all]==0.115.3",
"PyJWT==2.9.0",
"fastapi[all]==0.115.5",
"PyJWT==2.10.0",
"pymongo==4.10.1",
"uvicorn==0.32.0"
"uvicorn==0.32.1"
]

[project.urls]
Expand All @@ -29,12 +29,12 @@ code-analysis = [
test = [
"pytest==8.3.3",
"pytest-asyncio==0.24.0",
"pytest-cov==5.0.0",
"pytest-cov==6.0.0",
"pytest-env==1.1.5"
]

scripts = [
"faker==30.8.1",
"faker==33.0.0",
"requests==2.32.3"
]

Expand Down
20 changes: 16 additions & 4 deletions test/e2e/test_catalogue_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@

from inventory_management_system_api.core.consts import BREADCRUMBS_TRAIL_MAX_LENGTH

from inventory_management_system_api.schemas.catalogue_category import (
CATALOGUE_CATEGORY_WITH_CHILD_NON_EDITABLE_FIELDS,
)


class CreateDSL(UnitCreateDSL):
"""Base class for create tests."""
Expand Down Expand Up @@ -956,7 +960,9 @@ def test_partial_update_non_leaf_to_leaf_when_has_child_catalogue_category(self)
self.patch_catalogue_category(catalogue_category_id, {"is_leaf": True})

self.check_patch_catalogue_category_failed_with_detail(
409, "Catalogue category has child elements and cannot be updated"
409,
"Catalogue category has child elements, so the following fields cannot be updated: "
+ ", ".join(CATALOGUE_CATEGORY_WITH_CHILD_NON_EDITABLE_FIELDS),
)

def test_partial_update_leaf_all_valid_values_when_no_children(self):
Expand Down Expand Up @@ -1001,7 +1007,9 @@ def test_partial_update_leaf_to_non_leaf_when_has_child_catalogue_item(self):
self.patch_catalogue_category(catalogue_category_id, {"is_leaf": False})

self.check_patch_catalogue_category_failed_with_detail(
409, "Catalogue category has child elements and cannot be updated"
409,
"Catalogue category has child elements, so the following fields cannot be updated: "
+ ", ".join(CATALOGUE_CATEGORY_WITH_CHILD_NON_EDITABLE_FIELDS),
)

def test_partial_update_leaf_properties_when_has_child_catalogue_item(self):
Expand All @@ -1013,7 +1021,9 @@ def test_partial_update_leaf_properties_when_has_child_catalogue_item(self):
self.patch_catalogue_category(catalogue_category_id, {"properties": []})

self.check_patch_catalogue_category_failed_with_detail(
409, "Catalogue category has child elements and cannot be updated"
409,
"Catalogue category has child elements, so the following fields cannot be updated: "
+ ", ".join(CATALOGUE_CATEGORY_WITH_CHILD_NON_EDITABLE_FIELDS),
)

def test_partial_update_leaf_to_non_leaf_with_properties(self):
Expand Down Expand Up @@ -1056,7 +1066,9 @@ def test_partial_update_is_leaf_with_child_catalogue_category(self):

self.patch_catalogue_category(catalogue_category_id, {"is_leaf": True})
self.check_patch_catalogue_category_failed_with_detail(
409, "Catalogue category has child elements and cannot be updated"
409,
"Catalogue category has child elements, so the following fields cannot be updated: "
+ ", ".join(CATALOGUE_CATEGORY_WITH_CHILD_NON_EDITABLE_FIELDS),
)

def test_partial_update_leaf_properties(self):
Expand Down
10 changes: 8 additions & 2 deletions test/e2e/test_catalogue_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
from bson import ObjectId
from httpx import Response

from inventory_management_system_api.schemas.catalogue_item import CATALOGUE_ITEM_WITH_CHILD_NON_EDITABLE_FIELDS


class CreateDSL(CatalogueCategoryCreateDSL, ManufacturerCreateDSL):
"""Base class for create tests."""
Expand Down Expand Up @@ -1185,7 +1187,9 @@ def test_partial_update_manufacturer_id_with_children(self):

self.patch_catalogue_item(catalogue_item_id, {"manufacturer_id": new_manufacturer_id})
self.check_patch_catalogue_item_failed_with_detail(
409, "Catalogue item has child elements and cannot be updated"
409,
"Catalogue item has child elements, so the following fields cannot be updated: "
+ ", ".join(CATALOGUE_ITEM_WITH_CHILD_NON_EDITABLE_FIELDS),
)

def test_partial_update_manufacturer_id_with_non_existent_id(self):
Expand Down Expand Up @@ -1460,7 +1464,9 @@ def test_partial_update_properties_with_children(self):

self.patch_catalogue_item(catalogue_item_id, {"properties": []})
self.check_patch_catalogue_item_failed_with_detail(
409, "Catalogue item has child elements and cannot be updated"
409,
"Catalogue item has child elements, so the following fields cannot be updated: "
+ ", ".join(CATALOGUE_ITEM_WITH_CHILD_NON_EDITABLE_FIELDS),
)

def test_partial_update_obsolete_replacement_catalogue_item_id(self):
Expand Down

0 comments on commit c0d8e7b

Please sign in to comment.