Week 5#76
Conversation
Updated project title, structure, features, and setup instructions in README.md.
…p/interneers-lab into product-category-service-layer
|
|
||
| # Run tests | ||
| test: | ||
| cd $(BACKEND_DIR) && $(PYTHON) -m pytest |
There was a problem hiding this comment.
Makefile test targets use wrong Python executable path
High Severity
The test, coverage, and html-coverage targets cd into $(BACKEND_DIR) but reference $(PYTHON) without the ../../ prefix. The backend target correctly uses ../../$(PYTHON) after the same cd, but these three targets don't, so the shell will look for venv\Scripts\python relative to backend\python instead of the repo root — causing the commands to fail with "file not found."
Additional Locations (2)
| if product: | ||
| product.category = category | ||
| product.save() | ||
| return product |
There was a problem hiding this comment.
Adding category silently clears it when category missing
Medium Severity
add_category_to_product looks up the category by ID, but if category_id doesn't match any existing category, category is None. The code then assigns None to product.category and saves, silently removing the product's existing category instead of reporting an error. The service layer only validates that the product exists, not the category.
|
|
||
| # Create product | ||
| new_product = { | ||
| "id": storage.CURRENT_ID + 1, |
There was a problem hiding this comment.
Off-by-one error in warehouse product ID generation
Low Severity
CURRENT_ID starts at 1 in storage.py, but the new product ID is computed as storage.CURRENT_ID + 1 before incrementing. This means the first product gets ID 2 instead of 1, and all subsequent IDs are similarly shifted. Either CURRENT_ID needs to start at 0, or the ID assignment needs to use CURRENT_ID directly (incrementing afterward).
Additional Locations (1)
…le serializers, validators, and response helpers


Summary
This PR implements the Product Category service layer, related APIs, and comprehensive test coverage. It also improves the development workflow by introducing automation via a Makefile and updating project documentation.
Features Implemented
Implemented ProductCategory service layer.
Added CRUD APIs for Product Categories.
Modeled relationship between Products and Categories.
Implemented APIs to:
Testing
Added unit tests for:
ProductCategoryServiceProductServiceMocked repository layers in unit tests.
Added seed scripts for integration testing.
Implemented integration tests for API endpoints.
Improved overall test coverage.
Run tests using:
make testRun tests with coverage:
Note
Medium Risk
Adds new MongoEngine-backed CRUD APIs plus category assignment endpoints and a MongoDB test harness, which can affect data integrity and request handling (notably multiple
csrf_exemptviews and new DB connection config). Workflow/docs changes are low risk, but the new backend surface area and DB integration raise overall risk.Overview
Introduces new Django API surface for Products and Product Categories, including CRUD for categories and product endpoints to list, create, delete, fetch by id, list by category, and add/remove a category association.
Adds a MongoEngine data model layer (
Product,ProductCategory) with repository/service abstractions, plus amigrate_brandsmanagement command and Django wiring (INSTALLED_APPS, URL includes, MongoDBconnect()insettings.py).Builds out automated dev/test workflow via a root
Makefile,pytestconfiguration/fixtures for MongoDB-backed integration tests, coverage config (.coveragerc), and updates the rootREADME.mdto document setup/testing commands.Written by Cursor Bugbot for commit 9595f08. Configure here.