django-model-utils/tests/test_managers/test_status_manager.py

24 lines
779 B
Python
Raw Normal View History

from __future__ import annotations
from django.core.exceptions import ImproperlyConfigured
2020-11-29 20:58:00 +00:00
from django.db import models
from django.test import TestCase
from model_utils.managers import QueryManager
from model_utils.models import StatusModel
from tests.models import StatusManagerAdded
class StatusManagerAddedTests(TestCase):
2023-03-22 17:50:18 +00:00
def test_manager_available(self) -> None:
self.assertTrue(isinstance(StatusManagerAdded.active, QueryManager))
2023-03-22 17:50:18 +00:00
def test_conflict_error(self) -> None:
with self.assertRaises(ImproperlyConfigured):
class ErrorModel(StatusModel):
STATUS = (
('active', 'Is Active'),
('deleted', 'Is Deleted'),
)
active = models.BooleanField()