changeset 18ff0e067a0a in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=18ff0e067a0a
description:
Test unique pyson domain validation with greater IN_MAX
issue8474
review257701002
diffstat:
trytond/tests/test_modelstorage.py | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diffs (33 lines):
diff -r 4f54d7c7dc50 -r 18ff0e067a0a trytond/tests/test_modelstorage.py
--- a/trytond/tests/test_modelstorage.py Sat Jul 13 00:08:30 2019 +0200
+++ b/trytond/tests/test_modelstorage.py Sat Jul 13 00:08:56 2019 +0200
@@ -196,6 +196,29 @@
self.assertTrue(cm.exception.domain[1]['value'])
@with_transaction()
+ def test_pyson_domain_unique_in_max(self):
+ "Test unique pyson domain validation with greater IN_MAX"
+ pool = Pool()
+ Model = pool.get('test.modelstorage.pyson_domain')
+
+ in_max = Transaction().database.IN_MAX
+ self.addCleanup(setattr, Transaction().database, 'IN_MAX', in_max)
+ Transaction().database.IN_MAX = 1
+
+ # Use modulo 6 so len(domains) is greater then len(records) * 0.5
+ # and more than 1 (IN_MAX) have the same domain
+ Model.create(
+ [{'constraint': str(i % 6), 'value': str(i % 6)}
+ for i in range(10)])
+
+ with self.assertRaises(DomainValidationError) as cm:
+ Model.create(
+ [{'constraint': str(i % 6), 'value': str(i)}
+ for i in range(10)])
+ self.assertTrue(cm.exception.domain[0])
+ self.assertTrue(cm.exception.domain[1]['value'])
+
+ @with_transaction()
def test_pyson_domain_single(self):
"Test pyson domain validation for 1 record"
pool = Pool()