Add upper limit on positions in an order (#3806)

* Add upper limit on positions in an order

* Fix form validation
This commit is contained in:
Raphael Michel
2024-01-19 18:14:45 +01:00
committed by GitHub
parent 1f465ddddb
commit 4fb49820af
10 changed files with 97 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ from decimal import Decimal
from zoneinfo import ZoneInfo
import pytest
from django.conf import settings
from django.core import mail as djmail
from django.db.models import F, Sum
from django.test import TestCase
@@ -1829,6 +1830,13 @@ class OrderChangeManagerTests(TestCase):
with self.assertRaises(OrderError):
self.ocm.add_position(self.shirt, None, None, None)
@classscope(attr='o')
def test_add_item_limit(self):
for i in range(settings.PRETIX_MAX_ORDER_SIZE):
self.ocm.add_position(self.shirt, None, None, None)
with self.assertRaises(OrderError):
self.ocm.commit()
@classscope(attr='o')
def test_add_item_success(self):
self.ocm.add_position(self.shirt, None, None, None)