Commit Graph

164 Commits

Author SHA1 Message Date
e5cebc2fa5 fix: correct inventory service and test for product model changes
- Fix inventory_service.py: use product.vendor_sku instead of non-existent product.product_id
- Fix test: create MarketplaceProductTranslation for title (now in translations table)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 14:54:56 +01:00
2f770709fd refactor: reorganize tests into admin and vendor subdirectories
Split integration tests into logical admin/ and vendor/ subdirectories
for better organization. Updated fixture imports and test structure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 14:51:05 +01:00
c2f42c2913 feat: add import error tracking and translation tabs
Import Error Tracking:
- Add MarketplaceImportError model to store detailed error information
- Store row number, identifier, error type, message, and row data for each error
- Add API endpoint GET /admin/marketplace-import-jobs/{job_id}/errors
- Add UI to view and browse import errors in job details modal
- Support pagination and error type filtering

Translation Tabs:
- Replace flat translation list with tabbed interface on product detail page
- Add language tabs with full language names
- Add copy-to-clipboard functionality for translation content
- Improved UX with better visual separation of translations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 13:33:03 +01:00
448f01f82b feat: add Letzshop bidirectional order integration
Add complete Letzshop marketplace integration with:
- GraphQL client for order import and fulfillment operations
- Encrypted credential storage per vendor (Fernet encryption)
- Admin and vendor API endpoints for credentials management
- Order import, confirmation, rejection, and tracking
- Fulfillment queue and sync logging
- Comprehensive documentation and test coverage

New files:
- app/services/letzshop/ - GraphQL client and services
- app/utils/encryption.py - Fernet encryption utility
- models/database/letzshop.py - Database models
- models/schema/letzshop.py - Pydantic schemas
- app/api/v1/admin/letzshop.py - Admin API endpoints
- app/api/v1/vendor/letzshop.py - Vendor API endpoints
- docs/guides/letzshop-order-integration.md - Documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 12:19:54 +01:00
9c60989f1d feat: add marketplace products admin UI with copy-to-vendor functionality
- Add admin marketplace products page to browse imported products
- Add admin vendor products page to manage vendor catalog
- Add product detail pages for both marketplace and vendor products
- Implement copy-to-vendor API to copy marketplace products to vendor catalogs
- Add vendor product service with CRUD operations
- Update sidebar navigation with new product management links
- Add integration and unit tests for new endpoints and services

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 22:36:04 +01:00
2ecc2a9785 test: update tests for multi-language translation support
- Update marketplace_product_fixtures to create translations
- Update test_marketplace_product.py for translation-based titles
- Update test_product.py for effective property tests
- Update test_order.py to use get_title() method
- Add comprehensive CSV processor tests for translations
- Update stats service tests for new flat response structure
- Fix product schema tests with required marketplace_product_id field
- Add helper function create_marketplace_product_with_translation()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 17:29:50 +01:00
e98a3efe57 fix: correct failing unit tests for product and import job services
- test_create_import_job_database_error: Monkeypatch db.flush instead
  of db.commit since service uses flush() per architecture rules
- test_create_product_already_exists: Store product_id before exception
  and rollback session to clear PendingRollbackError state
- test_delete_product_success: Add db.flush() to delete_product service
  method to ensure deletion is applied before verification

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 18:28:59 +01:00
0bfdf331d6 refactor: remove legacy user registration from auth_service
- Remove unused register_user() method and helper methods
- Remove legacy UserRegister schema (customer registration uses CustomerService)
- Remove wrapper methods that just delegated to auth_manager
- Simplify auth_service to focus on login and vendor access control
- Clean up tests to match simplified service

The only registration path is now /api/v1/shop/auth/register for customers,
which uses CustomerService.register_customer().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 19:55:23 +01:00
120d8196fe test: update service tests for fixture and API changes
Updates to work with refactored fixtures (no expunge):
- Re-query entities when modifying state in tests
- Remove assertions on expunged object properties

Auth service tests:
- Update to use email_or_username field instead of username

Admin service tests:
- Fix statistics test to use stats_service module
- Remove vendor_name filter test (field removed)
- Update import job assertions

Inventory/Marketplace/Stats/Vendor service tests:
- Refactor to work with attached session objects
- Update assertions for changed response formats
- Improve test isolation and cleanup

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 21:42:52 +01:00
ca9f17fc37 refactor: split database model tests into organized modules
Split the monolithic test_database_models.py into focused test modules:

Database model tests (tests/unit/models/database/):
- test_customer.py: Customer model and authentication tests
- test_inventory.py: Inventory model tests
- test_marketplace_import_job.py: Import job model tests
- test_marketplace_product.py: Marketplace product model tests
- test_order.py: Order and OrderItem model tests
- test_product.py: Product model tests
- test_team.py: Team invitation and membership tests
- test_user.py: User model tests
- test_vendor.py: Vendor model tests

Schema validation tests (tests/unit/models/schema/):
- test_auth.py: Auth schema validation tests
- test_customer.py: Customer schema validation tests
- test_inventory.py: Inventory schema validation tests
- test_marketplace_import_job.py: Import job schema tests
- test_order.py: Order schema validation tests
- test_product.py: Product schema validation tests

This improves test organization and makes it easier to find
and maintain tests for specific models.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 21:42:26 +01:00
aaff799b5e refactor: remove db.expunge() anti-pattern from test fixtures
Remove db.expunge() calls that were causing DetachedInstanceError
when accessing lazy-loaded relationships in tests.

Changes:
- conftest.py: Add documentation about fixture best practices
- auth_fixtures: Remove expunge, keep objects attached to session
- customer_fixtures: Remove expunge, add proper relationship loading
- vendor_fixtures: Remove expunge, add test_company and other_company
  fixtures for proper company-vendor relationship setup
- marketplace_import_job_fixtures: Remove expunge calls
- marketplace_product_fixtures: Remove expunge calls

The db fixture already provides test isolation by dropping/recreating
tables after each test, so expunge is unnecessary and harmful.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 21:41:50 +01:00
1bbbd5d4d7 test: add missing vendor context middleware tests and fix exception type
- Fix test_require_vendor_context_failure to expect VendorNotFoundException
  instead of HTTPException (aligning with actual implementation)
- Add tests for is_shop_api_request() method (5 tests)
- Add tests for extract_vendor_from_referer() method (10 tests)
  - Path-based extraction (/vendors/ and /vendor/)
  - Subdomain extraction from referer
  - Custom domain extraction
  - Missing referer/origin header handling
- Add middleware tests for shop API request handling (3 tests)
- Add middleware tests for system path skipping (5 parametrized tests)

Total: 23 new tests added, bringing test count from 61 to 84

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 21:39:33 +01:00
b8a46e1746 fix: protect critical re-export imports from linter removal
Problem:
- Ruff removed 'from app.core.database import Base' from models/database/base.py
- Import appeared "unused" (F401) but was actually a critical re-export
- Caused ImportError: cannot import name 'Base' at runtime
- Re-export pattern: import in one file to export from package

Solution:
1. Added F401 ignore for models/database/base.py in pyproject.toml
2. Created scripts/verify_critical_imports.py verification script
3. Integrated verification into make check and CI pipeline
4. Updated documentation with explanation

New Verification Script:
- Checks all critical re-export imports exist
- Detects import variations (parentheses, 'as' clauses)
- Handles SQLAlchemy declarative_base alternatives
- Runs as part of make check automatically

Protected Files:
- models/database/base.py - Re-exports Base for all models
- models/__init__.py - Exports Base for Alembic
- models/database/__init__.py - Exports Base from package
- All __init__.py files (already protected)

Makefile Changes:
- make verify-imports - Run import verification
- make check - Now includes verify-imports
- make ci - Includes verify-imports in pipeline

Documentation Updated:
- Code quality guide explains re-export protection
- Pre-commit workflow includes verification
- Examples of why re-exports matter

This prevents future issues where linters remove seemingly
"unused" imports that are actually critical for application structure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 20:10:22 +01:00
238c1ec9b8 refactor: modernize code quality tooling with Ruff
- Replace black, isort, and flake8 with Ruff (all-in-one linter and formatter)
- Add comprehensive pyproject.toml configuration
- Simplify Makefile code quality targets
- Configure exclusions for venv/.venv in pyproject.toml
- Auto-fix 1,359 linting issues across codebase

Benefits:
- Much faster builds (Ruff is written in Rust)
- Single tool replaces multiple tools
- More comprehensive rule set (UP, B, C4, SIM, PIE, RET, Q)
- All configuration centralized in pyproject.toml
- Better import sorting and formatting consistency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 19:37:38 +01:00
21c13ca39b style: apply black and isort formatting across entire codebase
- Standardize quote style (single to double quotes)
- Reorder and group imports alphabetically
- Fix line breaks and indentation for consistency
- Apply PEP 8 formatting standards

Also updated Makefile to exclude both venv and .venv from code quality checks.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 19:30:17 +01:00
2532a977c1 Adding vendor api tests 2025-11-21 23:16:21 +01:00
86f1e16ef2 Fixing vendor dashboard area 2025-11-21 23:15:25 +01:00
96803c2708 adding integration tests for the middleware layer 2025-11-19 22:52:43 +01:00
23cf568c82 reaching 100% test coverage for the middleware unit tests 2025-11-19 22:26:45 +01:00
92a2610b70 renaming properly all middleware test cases and fixing bugs 2025-11-19 21:21:29 +01:00
21bd390685 unit test bug fixes 2025-11-19 20:21:11 +01:00
c38da2780a fixed connection closing issues in fixtures 2025-11-18 23:57:18 +01:00
d947fa5ca0 removing legacy code on path_rewrite_middleware 2025-11-18 23:32:07 +01:00
b3009e3795 Fixed middleware authentication issues 2025-11-18 22:50:55 +01:00
3a65a800bc gitignore improvement 2025-11-17 23:05:37 +01:00
807033be16 revamping documentation 2025-11-17 22:59:42 +01:00
5c80ba17c5 Main exception renamed to WizamartException 2025-10-27 21:55:05 +01:00
c88775134d Multitenant implementation with custom Domain, theme per vendor 2025-10-26 20:05:02 +01:00
c80e47134c Stats management revamping 2025-10-25 07:29:03 +02:00
7b8e31a198 Fix bug in vendor fixture 2025-10-19 16:09:00 +02:00
1e2f211057 Renamed schemas to schema as per naming conventions 2025-10-11 12:14:11 +02:00
dd16198276 major refactoring adding vendor and customer features 2025-10-11 09:09:25 +02:00
f569995883 vendor refactoring 2025-10-05 19:49:03 +02:00
0114b6c46e shop product refactoring 2025-10-04 23:38:53 +02:00
4d2866af5e shop product refactoring 2025-10-04 21:27:48 +02:00
c971674ec2 marketplace refactoring 2025-10-04 13:38:10 +02:00
6b9817f179 test updates to take into account exception management 2025-09-27 13:47:36 +02:00
3e720212d9 Product tests update 2025-09-25 20:00:50 +02:00
cea88a46c5 Marketplace tests update 2025-09-24 22:28:44 +02:00
f9879126c8 Auth service tests update 2025-09-24 21:44:48 +02:00
8b86b3225a Admin service tests update 2025-09-24 21:02:17 +02:00
98285aa8aa Exception handling enhancement 2025-09-23 22:42:26 +02:00
e348476b65 Moved utils folder to app/utils folder 2025-09-21 21:11:12 +02:00
6c4310a594 Makefile for test merged with the main one 2025-09-21 21:08:37 +02:00
2db03b20c5 Renaming models/api/ folder to models/schemas/ 2025-09-21 21:02:05 +02:00
bca894afc2 Removed unnecessary commands 2025-09-21 16:21:59 +02:00
c2a1056db7 QC check 2025-09-21 13:00:10 +02:00
a26f8086f8 Enhancing documentation 2025-09-20 22:39:12 +02:00
5996cecc42 workflows testing 2025-09-20 21:29:02 +02:00
b7b98def35 Fixed test_download_csv_failure test 2025-09-20 20:21:25 +02:00