Compatibility: update tests for 21.3+

This commit is contained in:
olliemath 2021-08-14 12:24:33 +01:00
parent 1a4785d61e
commit a924f6c7e2
2 changed files with 14 additions and 4 deletions

View File

@ -296,6 +296,10 @@ class DatabaseTestCase(TestCaseWithData):
self.assertTrue(model.is_system_model()) self.assertTrue(model.is_system_model())
self.assertTrue(model.is_read_only()) self.assertTrue(model.is_read_only())
self.assertEqual(model.table_name(), row.name) self.assertEqual(model.table_name(), row.name)
if row.name == "distributed_ddl_queue":
continue # Since zookeeper is not set up in our tests
# Read a few records # Read a few records
try: try:
list(model.objects_in(self.database)[:10]) list(model.objects_in(self.database)[:10])

View File

@ -14,14 +14,17 @@ class DictionaryTestMixin:
def tearDown(self): def tearDown(self):
self.database.drop_database() self.database.drop_database()
def _test_func(self, func, expected_value): def _call_func(self, func):
sql = "SELECT %s AS value" % func.to_sql() sql = "SELECT %s AS value" % func.to_sql()
logging.info(sql) logging.info(sql)
result = list(self.database.select(sql)) result = list(self.database.select(sql))
logging.info("\t==> %s", result[0].value if result else "<empty>") logging.info("\t==> %s", result[0].value if result else "<empty>")
return result
def _test_func(self, func, expected_value):
result = self._call_func(func)
print("Comparing %s to %s" % (result[0].value, expected_value)) print("Comparing %s to %s" % (result[0].value, expected_value))
self.assertEqual(result[0].value, expected_value) assert result[0].value == expected_value
return result[0].value if result else None
class SimpleDictionaryTest(DictionaryTestMixin, unittest.TestCase): class SimpleDictionaryTest(DictionaryTestMixin, unittest.TestCase):
@ -114,7 +117,10 @@ class HierarchicalDictionaryTest(DictionaryTestMixin, unittest.TestCase):
def test_dictgethierarchy(self): def test_dictgethierarchy(self):
self._test_func(F.dictGetHierarchy(self.dict_name, F.toUInt64(3)), [3, 2, 1]) self._test_func(F.dictGetHierarchy(self.dict_name, F.toUInt64(3)), [3, 2, 1])
self._test_func(F.dictGetHierarchy(self.dict_name, F.toUInt64(99)), [99]) # Default behaviour changed in CH, but we're not really testing that
default = self._call_func(F.dictGetHierarchy(self.dict_name, F.toUInt64(99)))
assert isinstance(default, list)
assert len(default) <= 1 # either [] or [99]
def test_dictisin(self): def test_dictisin(self):
self._test_func(F.dictIsIn(self.dict_name, F.toUInt64(3), F.toUInt64(1)), 1) self._test_func(F.dictIsIn(self.dict_name, F.toUInt64(3), F.toUInt64(1)), 1)