Support for model constraints

This commit is contained in:
Itai Shirav 2020-06-06 11:37:25 +03:00
parent ffd9bab0ef
commit 22cd908a49

View File

@ -4,10 +4,12 @@ from infi.clickhouse_orm import *
from .base_test_with_data import Person from .base_test_with_data import Person
class ArrayFieldsTest(unittest.TestCase): class ConstraintsTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.database = Database('test-db', log_statements=True) self.database = Database('test-db', log_statements=True)
if self.database.server_version < (19, 14, 3, 3):
raise unittest.SkipTest('ClickHouse version too old')
self.database.create_table(PersonWithConstraints) self.database.create_table(PersonWithConstraints)
def tearDown(self): def tearDown(self):
@ -19,9 +21,6 @@ class ArrayFieldsTest(unittest.TestCase):
]) ])
def test_insert_invalid_values(self): def test_insert_invalid_values(self):
if self.database.server_version < (19, 14, 3, 3):
raise unittest.SkipTest('ClickHouse version too old')
with self.assertRaises(ServerError) as e: with self.assertRaises(ServerError) as e:
self.database.insert([ self.database.insert([
PersonWithConstraints(first_name="Mike", last_name="Caruzo", birthday="2100-01-01", height=1.66) PersonWithConstraints(first_name="Mike", last_name="Caruzo", birthday="2100-01-01", height=1.66)