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.

37 lines
1.4 KiB

from rest_framework.test import APITestCase
from rest_framework import status
from .models import GoodsReception
from product_directory.models import Product
class GoodsReceptionAPITestCase(APITestCase):
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.goods_reception_data = {
"product": self.product.id,
"quantity": 10,
"quality_check": True,
"shelf_life_valid": True,
"is_accepted": True,
"rejection_reason": None
}
def test_create_goods_reception(self):
response = self.client.post('/goods-reception/api/goods-receptions/', self.goods_reception_data)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
def test_list_goods_receptions(self):
GoodsReception.objects.create(**self.goods_reception_data)
response = self.client.get('/goods-reception/api/goods-receptions/')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response.data), 1)