Классы миксинов перенесены в проект
This commit is contained in:
59
net/xeaf/rack/tests/models/mixins/slug_mixin_tests.py
Normal file
59
net/xeaf/rack/tests/models/mixins/slug_mixin_tests.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# DRF Rack
|
||||
# Библиотека классов расширений для Django REST Framework
|
||||
#
|
||||
# Автор: Николай В. Анохин <n.anokhin@xeaf.net>
|
||||
# Все права защищены. Лицензия: MIT
|
||||
|
||||
"""
|
||||
Описание класса SlugMixinTests
|
||||
"""
|
||||
|
||||
from django.db import connection
|
||||
from django.db import models
|
||||
from django.test import TransactionTestCase
|
||||
|
||||
from net.xeaf.rack.models.mixins import SlugMixin
|
||||
|
||||
|
||||
class SlugMixinTests(TransactionTestCase):
|
||||
"""
|
||||
Тесты для миксина SlugMixin
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Создаем тестовую модель и таблицу для каждого теста
|
||||
"""
|
||||
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute('PRAGMA foreign_keys = OFF;')
|
||||
|
||||
class TestSlugModel(SlugMixin):
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
class Meta:
|
||||
app_label = 'test'
|
||||
db_table = 'test_slug_mixin'
|
||||
|
||||
self.TestModel = TestSlugModel
|
||||
|
||||
with connection.schema_editor() as editor:
|
||||
editor.create_model(TestSlugModel)
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
Удаляем таблицу после каждого теста
|
||||
"""
|
||||
|
||||
with connection.schema_editor() as editor:
|
||||
editor.delete_model(self.TestModel)
|
||||
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute('PRAGMA foreign_keys = ON;')
|
||||
|
||||
def test_slug_field_exists(self):
|
||||
"""
|
||||
Проверяем, что поле slug добавлено в модель
|
||||
"""
|
||||
|
||||
self.assertTrue(hasattr(self.TestModel, 'slug'))
|
||||
Reference in New Issue
Block a user