vendor refactoring
This commit is contained in:
@@ -19,7 +19,7 @@ from models.schemas.product import ProductCreate
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.vendors
|
||||
class TestVendorService:
|
||||
"""Test suite for ShopService following the application's exception patterns"""
|
||||
"""Test suite for VendorService following the application's exception patterns"""
|
||||
|
||||
def setup_method(self):
|
||||
"""Setup method following the same pattern as admin service tests"""
|
||||
@@ -29,7 +29,7 @@ class TestVendorService:
|
||||
"""Test successful vendor creation"""
|
||||
vendor_data = VendorCreate(
|
||||
vendor_code="NEWVENDOR",
|
||||
vendor_name="New Test Shop",
|
||||
vendor_name="New Test Vendor",
|
||||
description="A new test vendor ",
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ class TestVendorService:
|
||||
|
||||
def test_create_vendor_admin_auto_verify(self, db, test_admin, vendor_factory):
|
||||
"""Test admin creates verified vendor automatically"""
|
||||
vendor_data = VendorCreate(vendor_code="ADMINSHOP", vendor_name="Admin Test Shop")
|
||||
vendor_data = VendorCreate(vendor_code="ADMINVENDOR", vendor_name="Admin Test Vendor")
|
||||
|
||||
vendor = self.service.create_vendor(db, vendor_data, test_admin)
|
||||
|
||||
@@ -65,7 +65,7 @@ class TestVendorService:
|
||||
|
||||
def test_create_vendor_invalid_data_empty_code(self, db, test_user):
|
||||
"""Test vendor creation fails with empty vendor code"""
|
||||
vendor_data = VendorCreate(vendor_code="", vendor_name="Test Shop")
|
||||
vendor_data = VendorCreate(vendor_code="", vendor_name="Test Vendor")
|
||||
|
||||
with pytest.raises(InvalidVendorDataException) as exc_info:
|
||||
self.service.create_vendor(db, vendor_data, test_user)
|
||||
@@ -88,7 +88,7 @@ class TestVendorService:
|
||||
|
||||
def test_create_vendor_invalid_code_format(self, db, test_user):
|
||||
"""Test vendor creation fails with invalid vendor code format"""
|
||||
vendor_data = VendorCreate(vendor_code="INVALID@CODE!", vendor_name="Test Shop")
|
||||
vendor_data = VendorCreate(vendor_code="INVALID@CODE!", vendor_name="Test Vendor")
|
||||
|
||||
with pytest.raises(InvalidVendorDataException) as exc_info:
|
||||
self.service.create_vendor(db, vendor_data, test_user)
|
||||
@@ -163,7 +163,7 @@ class TestVendorService:
|
||||
exception = exc_info.value
|
||||
assert exception.status_code == 404
|
||||
assert exception.error_code == "VENDOR_NOT_FOUND"
|
||||
assert exception.details["resource_type"] == "Shop"
|
||||
assert exception.details["resource_type"] == "Vendor"
|
||||
assert exception.details["identifier"] == "NONEXISTENT"
|
||||
|
||||
def test_get_vendor_by_code_access_denied(self, db, test_user, inactive_vendor):
|
||||
@@ -266,7 +266,7 @@ class TestVendorService:
|
||||
|
||||
monkeypatch.setattr(db, "commit", mock_commit)
|
||||
|
||||
vendor_data = VendorCreate(vendor_code="NEWVENDOR", vendor_name="Test Shop")
|
||||
vendor_data = VendorCreate(vendor_code="NEWVENDOR", vendor_name="Test Vendor")
|
||||
|
||||
with pytest.raises(ValidationException) as exc_info:
|
||||
self.service.create_vendor(db, vendor_data, test_user)
|
||||
|
||||
Reference in New Issue
Block a user