mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2025-08-02 19:20:14 +03:00
Chore: fix linting on tests
This commit is contained in:
parent
bec70d15db
commit
a3b822899f
|
@ -59,7 +59,7 @@ class AliasFieldsTest(unittest.TestCase):
|
|||
# Check that NO_VALUE can be assigned to a field
|
||||
instance.str_field = NO_VALUE
|
||||
# Check that NO_VALUE can be assigned when creating a new instance
|
||||
instance2 = ModelWithAliasFields(**instance.to_dict())
|
||||
ModelWithAliasFields(**instance.to_dict())
|
||||
|
||||
|
||||
class ModelWithAliasFields(Model):
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
|
||||
from clickhouse_orm.engines import *
|
||||
from clickhouse_orm.models import BufferModel
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class CompressedFieldsTestCase(unittest.TestCase):
|
|||
)
|
||||
instance = CompressedModel(**kwargs)
|
||||
self.database.insert([instance])
|
||||
for name, value in kwargs.items():
|
||||
for name in kwargs:
|
||||
self.assertEqual(kwargs[name], getattr(instance, name))
|
||||
|
||||
def test_string_conversion(self):
|
||||
|
@ -106,8 +106,8 @@ class CompressedFieldsTestCase(unittest.TestCase):
|
|||
)
|
||||
)
|
||||
lines = r.splitlines()
|
||||
field_names = parse_tsv(lines[0])
|
||||
field_types = parse_tsv(lines[1])
|
||||
parse_tsv(lines[0])
|
||||
parse_tsv(lines[1])
|
||||
data = [tuple(parse_tsv(line)) for line in lines[2:]]
|
||||
self.assertListEqual(
|
||||
data,
|
||||
|
|
|
@ -26,14 +26,14 @@ class ConstraintsTest(unittest.TestCase):
|
|||
[PersonWithConstraints(first_name="Mike", last_name="Caruzo", birthday="2100-01-01", height=1.66)]
|
||||
)
|
||||
self.assertEqual(e.code, 469)
|
||||
self.assertTrue("Constraint `birthday_in_the_past`" in e.message)
|
||||
self.assertTrue("Constraint `birthday_in_the_past`" in str(e))
|
||||
|
||||
with self.assertRaises(ServerError) as e:
|
||||
self.database.insert(
|
||||
[PersonWithConstraints(first_name="Mike", last_name="Caruzo", birthday="1970-01-01", height=3)]
|
||||
)
|
||||
self.assertEqual(e.code, 469)
|
||||
self.assertTrue("Constraint `max_height`" in e.message)
|
||||
self.assertTrue("Constraint `max_height`" in str(e))
|
||||
|
||||
|
||||
class PersonWithConstraints(Person):
|
||||
|
|
|
@ -199,7 +199,7 @@ class DatabaseTestCase(TestCaseWithData):
|
|||
self.assertEqual(exc.code, 81)
|
||||
self.assertTrue(exc.message.startswith("Database db_not_here doesn't exist"))
|
||||
# Create and delete the db twice, to ensure db_exists gets updated
|
||||
for i in range(2):
|
||||
for _ in range(2):
|
||||
# Now create the database - should succeed
|
||||
db.create_database()
|
||||
self.assertTrue(db.db_exists)
|
||||
|
@ -284,7 +284,7 @@ class DatabaseTestCase(TestCaseWithData):
|
|||
try:
|
||||
list(model.objects_in(self.database)[:10])
|
||||
except ServerError as e:
|
||||
if "Not enough privileges" in e.message:
|
||||
if "Not enough privileges" in str(e):
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
|
|
|
@ -15,7 +15,7 @@ class DecimalFieldsTest(unittest.TestCase):
|
|||
self.database.create_table(DecimalModel)
|
||||
except ServerError as e:
|
||||
# This ClickHouse version does not support decimals yet
|
||||
raise unittest.SkipTest(e.message)
|
||||
raise unittest.SkipTest(str(e))
|
||||
|
||||
def tearDown(self):
|
||||
self.database.drop_database()
|
||||
|
@ -78,11 +78,11 @@ class DecimalFieldsTest(unittest.TestCase):
|
|||
# Go over all valid combinations
|
||||
for precision in range(1, 39):
|
||||
for scale in range(0, precision + 1):
|
||||
f = DecimalField(precision, scale)
|
||||
DecimalField(precision, scale)
|
||||
# Some invalid combinations
|
||||
for precision, scale in [(0, 0), (-1, 7), (7, -1), (39, 5), (20, 21)]:
|
||||
with self.assertRaises(AssertionError):
|
||||
f = DecimalField(precision, scale)
|
||||
DecimalField(precision, scale)
|
||||
|
||||
def test_min_max(self):
|
||||
# In range
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import logging
|
||||
import unittest
|
||||
from datetime import date, datetime, timedelta, tzinfo
|
||||
from datetime import date, datetime, timedelta
|
||||
from decimal import Decimal
|
||||
from ipaddress import IPv4Address, IPv6Address
|
||||
|
||||
|
@ -39,8 +39,8 @@ class FuncsTestCase(TestCaseWithData):
|
|||
self.assertEqual(result[0].value, expected_value)
|
||||
return result[0].value if result else None
|
||||
except ServerError as e:
|
||||
if "Unknown function" in e.message:
|
||||
logging.warning(e.message)
|
||||
if "Unknown function" in str(e):
|
||||
logging.warning(str(e))
|
||||
return # ignore functions that don't exist in the used ClickHouse version
|
||||
raise
|
||||
|
||||
|
@ -54,8 +54,8 @@ class FuncsTestCase(TestCaseWithData):
|
|||
self.assertEqual(result[0].value, expected_value)
|
||||
return result[0].value if result else None
|
||||
except ServerError as e:
|
||||
if "Unknown function" in e.message:
|
||||
logging.warning(e.message)
|
||||
if "Unknown function" in str(e):
|
||||
logging.warning(str(e))
|
||||
return # ignore functions that don't exist in the used ClickHouse version
|
||||
raise
|
||||
|
||||
|
@ -449,7 +449,7 @@ class FuncsTestCase(TestCaseWithData):
|
|||
self._test_func(F.tryBase64Decode(":-)"))
|
||||
except ServerError as e:
|
||||
# ClickHouse version that doesn't support these functions
|
||||
raise unittest.SkipTest(e.message)
|
||||
raise unittest.SkipTest(str(e))
|
||||
|
||||
def test_replace_functions(self):
|
||||
haystack = "hello"
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
import datetime
|
||||
import unittest
|
||||
|
||||
import pytz
|
||||
|
||||
from clickhouse_orm.database import Database
|
||||
from clickhouse_orm.engines import *
|
||||
from clickhouse_orm.fields import *
|
||||
|
|
|
@ -17,6 +17,7 @@ class IPFieldsTest(unittest.TestCase):
|
|||
def test_ipv4_field(self):
|
||||
if self.database.server_version < (19, 17):
|
||||
raise unittest.SkipTest("ClickHouse version too old")
|
||||
|
||||
# Create a model
|
||||
class TestModel(Model):
|
||||
i = Int16Field()
|
||||
|
@ -39,6 +40,7 @@ class IPFieldsTest(unittest.TestCase):
|
|||
def test_ipv6_field(self):
|
||||
if self.database.server_version < (19, 17):
|
||||
raise unittest.SkipTest("ClickHouse version too old")
|
||||
|
||||
# Create a model
|
||||
class TestModel(Model):
|
||||
i = Int16Field()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
|
||||
# Add tests to path so that migrations will be importable
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from enum import Enum
|
||||
|
@ -13,9 +13,6 @@ from clickhouse_orm.models import BufferModel, Constraint, Index, Model
|
|||
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG, format="%(message)s")
|
||||
logging.getLogger("requests").setLevel(logging.WARNING)
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class ModelTestCase(unittest.TestCase):
|
|||
float_field=3.14,
|
||||
)
|
||||
instance = SimpleModel(**kwargs)
|
||||
for name, value in kwargs.items():
|
||||
for name in kwargs:
|
||||
self.assertEqual(kwargs[name], getattr(instance, name))
|
||||
|
||||
def test_assignment_error(self):
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
from datetime import date, datetime
|
||||
from decimal import Decimal
|
||||
from enum import Enum
|
||||
from logging import getLogger
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ class ReadonlyTestCase(TestCaseWithData):
|
|||
self.database.drop_database()
|
||||
self._check_db_readonly_err(cm.exception, drop_table=True)
|
||||
except ServerError as e:
|
||||
if e.code == 192 and e.message.startswith("Unknown user"): # ClickHouse version < 20.3
|
||||
if e.code == 192 and str(e).startswith("Unknown user"): # ClickHouse version < 20.3
|
||||
raise unittest.SkipTest('Database user "%s" is not defined' % username)
|
||||
elif e.code == 516 and e.message.startswith(
|
||||
elif e.code == 516 and str(e).startswith(
|
||||
"readonly: Authentication failed"
|
||||
): # ClickHouse version >= 20.3
|
||||
raise unittest.SkipTest('Database user "%s" is not defined' % username)
|
||||
|
@ -66,7 +66,7 @@ class ReadonlyTestCase(TestCaseWithData):
|
|||
|
||||
def test_nonexisting_readonly_database(self):
|
||||
with self.assertRaises(DatabaseException) as cm:
|
||||
db = Database("dummy", readonly=True)
|
||||
Database("dummy", readonly=True)
|
||||
self.assertEqual(str(cm.exception), "Database does not exist, and cannot be created under readonly connection")
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class UUIDFieldsTest(unittest.TestCase):
|
|||
def test_uuid_field(self):
|
||||
if self.database.server_version < (18, 1):
|
||||
raise unittest.SkipTest("ClickHouse version too old")
|
||||
|
||||
# Create a model
|
||||
class TestModel(Model):
|
||||
i = Int16Field()
|
||||
|
|
Loading…
Reference in New Issue
Block a user