21 lines
1.0 KiB
Python
21 lines
1.0 KiB
Python
from django.contrib.auth import get_user_model
|
|
from django.test import TestCase
|
|
|
|
from filament import services
|
|
|
|
|
|
class InventoryTests(TestCase):
|
|
def test_identical_variant_increments_single_private_position(self):
|
|
self.assertTrue(callable(getattr(services, "add_quantity", None)), "Bestandszugang fehlt")
|
|
from filament.models import Color, InventoryItem, Manufacturer, ProductType, Variant
|
|
|
|
user = get_user_model().objects.create_user("michael")
|
|
manufacturer = Manufacturer.objects.create(name="Bambu Lab")
|
|
product = ProductType.objects.create(manufacturer=manufacturer, name="PLA Matte")
|
|
color = Color.objects.create(name="Rot")
|
|
variant = Variant.objects.create(product_type=product, color=color, spool_type="spool")
|
|
services.add_quantity(InventoryItem, user, variant, 2)
|
|
services.add_quantity(InventoryItem, user, variant, 1)
|
|
self.assertEqual(InventoryItem.objects.count(), 1)
|
|
self.assertEqual(InventoryItem.objects.get(owner=user, variant=variant).quantity, 3)
|