Отказ от CoreTestCase
This commit is contained in:
@@ -10,4 +10,3 @@
|
|||||||
|
|
||||||
from .core_enum import CoreEnum
|
from .core_enum import CoreEnum
|
||||||
from .core_exception import CoreException
|
from .core_exception import CoreException
|
||||||
from .core_test_case import CoreTestCase
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
# DRF Rack
|
|
||||||
# Библиотека классов расширений для Django REST Framework
|
|
||||||
#
|
|
||||||
# Автор: Николай В. Анохин <n.anokhin@xeaf.net>
|
|
||||||
# Все права защищены. Лицензия: MIT
|
|
||||||
|
|
||||||
"""
|
|
||||||
Описание класса CoreTestCase
|
|
||||||
"""
|
|
||||||
|
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
|
|
||||||
class CoreTestCase(TestCase):
|
|
||||||
"""
|
|
||||||
Расширяет функции кейса тестирования
|
|
||||||
"""
|
|
||||||
|
|
||||||
def assertLowerHex(self, value: str):
|
|
||||||
"""
|
|
||||||
Проверяет, что строка состоит из символов в нижнем регистре и шестнадцатеричных цифр
|
|
||||||
|
|
||||||
:param value: Проверяемая строка
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.assertRegex(value, r'^[0-9a-f]+$')
|
|
||||||
@@ -8,8 +8,9 @@
|
|||||||
Описание класса CoreEnumTests
|
Описание класса CoreEnumTests
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from django.test import SimpleTestCase
|
||||||
|
|
||||||
from net.xeaf.rack.core import CoreEnum
|
from net.xeaf.rack.core import CoreEnum
|
||||||
from net.xeaf.rack.core import CoreTestCase
|
|
||||||
|
|
||||||
|
|
||||||
class TestColorEnum(CoreEnum):
|
class TestColorEnum(CoreEnum):
|
||||||
@@ -40,7 +41,7 @@ class TestEmptyEnum(CoreEnum):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CoreEnumTests(CoreTestCase):
|
class CoreEnumTests(SimpleTestCase):
|
||||||
"""
|
"""
|
||||||
Тесты для класса CoreEnum
|
Тесты для класса CoreEnum
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -8,11 +8,12 @@
|
|||||||
Описание класса CryptoTests
|
Описание класса CryptoTests
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from net.xeaf.rack.core import CoreTestCase
|
from django.test import SimpleTestCase
|
||||||
|
|
||||||
from net.xeaf.rack.managers import CryptoManager
|
from net.xeaf.rack.managers import CryptoManager
|
||||||
|
|
||||||
|
|
||||||
class CryptoManagerTests(CoreTestCase):
|
class CryptoManagerTests(SimpleTestCase):
|
||||||
"""
|
"""
|
||||||
Тесты для класса CryptoManager
|
Тесты для класса CryptoManager
|
||||||
"""
|
"""
|
||||||
@@ -24,7 +25,7 @@ class CryptoManagerTests(CoreTestCase):
|
|||||||
|
|
||||||
token = CryptoManager.gen_token()
|
token = CryptoManager.gen_token()
|
||||||
self.assertEqual(len(token), CryptoManager.DEFAULT_TOKEN_LENGTH)
|
self.assertEqual(len(token), CryptoManager.DEFAULT_TOKEN_LENGTH)
|
||||||
self.assertLowerHex(token)
|
self._assert_lower_hex(token)
|
||||||
|
|
||||||
def test_gen_token_length(self):
|
def test_gen_token_length(self):
|
||||||
"""
|
"""
|
||||||
@@ -89,7 +90,7 @@ class CryptoManagerTests(CoreTestCase):
|
|||||||
slug = CryptoManager.gen_slug(pfx)
|
slug = CryptoManager.gen_slug(pfx)
|
||||||
self.assertEqual(len(slug), CryptoManager.DEFAULT_SLUG_LENGTH)
|
self.assertEqual(len(slug), CryptoManager.DEFAULT_SLUG_LENGTH)
|
||||||
self.assertEqual(slug[:len(pfx)], pfx)
|
self.assertEqual(slug[:len(pfx)], pfx)
|
||||||
self.assertLowerHex(slug[len(pfx):])
|
self._assert_lower_hex(slug[len(pfx):])
|
||||||
|
|
||||||
def test_gen_slug_length(self):
|
def test_gen_slug_length(self):
|
||||||
"""
|
"""
|
||||||
@@ -117,3 +118,12 @@ class CryptoManagerTests(CoreTestCase):
|
|||||||
slug_1 = CryptoManager.gen_slug('test')
|
slug_1 = CryptoManager.gen_slug('test')
|
||||||
slug_2 = CryptoManager.gen_slug('test')
|
slug_2 = CryptoManager.gen_slug('test')
|
||||||
self.assertNotEqual(slug_1, slug_2)
|
self.assertNotEqual(slug_1, slug_2)
|
||||||
|
|
||||||
|
def _assert_lower_hex(self, value: str):
|
||||||
|
"""
|
||||||
|
Проверяет, что строка состоит из символов в нижнем регистре и шестнадцатеричных цифр
|
||||||
|
|
||||||
|
:param value: Проверяемая строка
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.assertRegex(value, r'^[0-9a-f]+$')
|
||||||
|
|||||||
Reference in New Issue
Block a user