You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.0 KiB

from django.test import TestCase
from product_directory.models import Product
from .models import Stock, Warehouse, StorageLocation, StockOperation
class StockTestCase(TestCase):
def setUp(self):
self.product = Product.objects.create(
name="Тестовый товар",
barcode="1234567890123",
shelf_life_days=365,
dimensions="10x10x10",
unit_of_measure="шт.",
manufacturer="Производитель",
category="Food",
storage_temperature="+4C",
promotion="1+1"
)
self.stock = Stock.objects.create(
product=self.product,
quantity=100,
location="Основной склад"
)
def test_stock_creation(self):
self.assertEqual(self.stock.quantity, 100)
def test_stock_update(self):
self.stock.quantity += 50
self.stock.save()
self.assertEqual(self.stock.quantity, 150)
class StockOperationTestCase(TestCase):
def setUp(self):
self.warehouse = Warehouse.objects.create(name="Основной склад", location="Москва")
self.storage = StorageLocation.objects.create(warehouse=self.warehouse, name="Холодильник", temperature_control=True)
self.product = Product.objects.create(
name="Тестовый товар",
barcode="1234567890123",
shelf_life_days=365,
dimensions="10x10x10",
unit_of_measure="шт.",
manufacturer="Производитель",
category="Food",
storage_temperature="+4C",
promotion="1+1"
)
def test_incoming_operation(self):
operation = StockOperation.objects.create(
product=self.product,
warehouse=self.warehouse,
storage_location=self.storage,
operation_type="Incoming",
quantity=100
)
self.assertEqual(operation.quantity, 100)