feat: websockets
CI / test (push) Successful in 1m56s
CI / build (push) Successful in 48s

This commit is contained in:
2026-07-31 14:27:50 +02:00
parent 125c9dd186
commit 393b39cacd
13 changed files with 626 additions and 2 deletions
+14
View File
@@ -29,3 +29,17 @@ class TestBackofficeAccess(TestCase):
response = self.client.get(reverse('backoffice:product_list'))
assert response.status_code == 403
def test_non_staff_user_gets_forbidden_on_ws_demo(self):
user = User.objects.create_user('leia', 'leia@rebels.com', 'ihatesand', is_staff=False)
self.client.force_login(user)
response = self.client.get(reverse('backoffice:ws_demo'))
assert response.status_code == 403
def test_superuser_can_access_ws_demo(self):
user = User.objects.create_superuser('vader2', 'vader2@empire.com', 'ihatesand')
self.client.force_login(user)
response = self.client.get(reverse('backoffice:ws_demo'))
assert response.status_code == 200
+27
View File
@@ -140,6 +140,33 @@ class TestBackofficeProducts(TestCase, CreateProductsMixin):
assert variant.product == self.product
assert size_m in variant.attribute_values.all()
def test_create_variant_with_initial_price_in_one_submit(self):
# El staff introduce el precio CON impuestos; se guarda sin impuestos,
# igual que en la creación de producto (ver ProductInitialPriceForm).
tax, created = Tax.objects.get_or_create(code='IVA', value=21)
size_m = self.create_attribute_value('Talla', 'M')
response = self.client.post(
reverse('backoffice:product_variant_create', args=[self.product.pk]),
{'sku': 'V-M', 'stock': '5', 'attribute_values': [size_m.pk], 'price': '19.99', 'tax': tax.pk},
)
assert response.status_code == 302
variant = ProductVariant.objects.get(sku='V-M')
price = ProductPrice.objects.get(variant=variant)
assert price.price == Decimal('16.52')
assert price.price_with_tax == Decimal('19.99')
assert price.current is True
def test_create_variant_with_price_missing_tax_shows_error(self):
size_m = self.create_attribute_value('Talla', 'M')
response = self.client.post(
reverse('backoffice:product_variant_create', args=[self.product.pk]),
{'sku': 'V-M', 'stock': '5', 'attribute_values': [size_m.pk], 'price': '19.99'},
)
assert response.status_code == 200
assert not ProductVariant.objects.filter(sku='V-M').exists()
def test_create_duplicated_variant_combination_fails(self):
size_m = self.create_attribute_value('Talla', 'M')
self.create_product_variant(self.product, sku='V-M1', attribute_values=[size_m])