mirror of
https://github.com/carrotquest/django-clickhouse.git
synced 2024-11-22 00:56:37 +03:00
Added tests for utils and serializers
This commit is contained in:
parent
235b690f35
commit
cdc8a2cd26
|
@ -62,6 +62,7 @@ def lazy_class_import(obj): # type: (Union[str, Any]) -> Any
|
|||
module = import_module(module_name)
|
||||
|
||||
try:
|
||||
print(module, obj_name)
|
||||
return getattr(module, obj_name)
|
||||
except AttributeError:
|
||||
raise ImportError('Invalid import path `%s`' % obj)
|
||||
|
|
|
@ -3,7 +3,8 @@ from unittest import TestCase
|
|||
|
||||
import pytz
|
||||
|
||||
from django_clickhouse.utils import get_tz_offset, format_datetime
|
||||
from django_clickhouse.models import ClickHouseSyncModel
|
||||
from django_clickhouse.utils import get_tz_offset, format_datetime, lazy_class_import
|
||||
|
||||
|
||||
class GetTZOffsetTest(TestCase):
|
||||
|
@ -45,3 +46,11 @@ class FormatDateTimeTest(TestCase):
|
|||
self.assertEqual(format_datetime(dt, day_end=True, timezone_offset=60), '2017-01-03 03:59:59')
|
||||
dt = datetime.date(2017, 1, 2)
|
||||
self.assertEqual(format_datetime(dt, timezone_offset=60), '2017-01-02 04:00:00')
|
||||
|
||||
|
||||
class TestLazyClassImport(TestCase):
|
||||
def test_str(self):
|
||||
self.assertEqual(ClickHouseSyncModel, lazy_class_import('django_clickhouse.models.ClickHouseSyncModel'))
|
||||
|
||||
def test_cls(self):
|
||||
self.assertEqual(ClickHouseSyncModel, lazy_class_import(ClickHouseSyncModel))
|
||||
|
|
Loading…
Reference in New Issue
Block a user