fix: improved UI
CI / test (push) Failing after 1m8s
CI / build (push) Has been skipped

This commit is contained in:
2026-07-23 16:53:16 +02:00
parent d0a4cabb3b
commit 332e0fc5f4
6 changed files with 264 additions and 6 deletions
+68
View File
@@ -58,6 +58,74 @@ class TestBackofficeProducts(TestCase, CreateProductsMixin):
assert set(product.categories.all()) == {cat1, cat2}
assert set(product.tags.all()) == {tag1}
def test_create_product_with_initial_price(self):
tax, created = Tax.objects.get_or_create(code='IVA', value=21)
response = self.client.post(
reverse('backoffice:product_create'),
{
'sku': 'NEW-3',
'name': 'Producto con precio',
'description': '',
'stock': '0',
'price': '12.50',
'tax': tax.pk,
},
)
assert response.status_code == 302
product = Product.objects.get(sku='NEW-3')
price = ProductPrice.objects.get(product=product)
assert price.price == Decimal('12.50')
assert price.current is True
def test_create_product_with_price_missing_tax_shows_error(self):
response = self.client.post(
reverse('backoffice:product_create'),
{'sku': 'NEW-4', 'name': 'Producto incompleto', 'description': '', 'stock': '0', 'price': '9.99'},
)
assert response.status_code == 200
assert not Product.objects.filter(sku='NEW-4').exists()
def test_create_product_with_images(self):
image = Image.new('RGB', (64, 64), '#ACACAC')
buffer = BytesIO()
image.save(fp=buffer, format='WEBP')
file1 = ContentFile(buffer.getvalue(), name='one.webp')
buffer2 = BytesIO()
image.save(fp=buffer2, format='WEBP')
file2 = ContentFile(buffer2.getvalue(), name='two.webp')
response = self.client.post(
reverse('backoffice:product_create'),
{
'sku': 'NEW-5',
'name': 'Producto con imagenes',
'description': '',
'stock': '0',
'images': [file1, file2],
},
format='multipart',
)
assert response.status_code == 302
product = Product.objects.get(sku='NEW-5')
assert ProductImage.objects.filter(product=product).count() == 2
def test_new_current_price_unmarks_previous_current_price(self):
tax, created = Tax.objects.get_or_create(code='IVA', value=21)
old_price = self.product.price
assert old_price.current is True
response = self.client.post(
reverse('backoffice:product_price_create', args=[self.product.pk]),
{'price': '25.00', 'tax': tax.pk, 'current': 'on'},
)
assert response.status_code == 302
old_price.refresh_from_db()
assert old_price.current is False
new_price = self.product.prices.get(price=Decimal('25.00'))
assert new_price.current is True
def test_create_variant_for_product(self):
size_m = self.create_attribute_value('Talla', 'M')