|
10 | 10 | from django.utils import timezone |
11 | 11 |
|
12 | 12 | from simple_history.exceptions import AlternativeManagerError, NotHistoricalModelError |
13 | | -from simple_history.tests.models import ( |
| 13 | +from simple_history.utils import ( |
| 14 | + bulk_create_with_history, |
| 15 | + bulk_update_with_history, |
| 16 | + get_history_manager_for_model, |
| 17 | + get_history_model_for_model, |
| 18 | + get_m2m_field_name, |
| 19 | + get_m2m_reverse_field_name, |
| 20 | + update_change_reason, |
| 21 | +) |
| 22 | + |
| 23 | +from ..models import ( |
14 | 24 | BulkCreateManyToManyModel, |
15 | 25 | Document, |
16 | 26 | Place, |
|
28 | 38 | PollWithUniqueQuestion, |
29 | 39 | Street, |
30 | 40 | ) |
31 | | -from simple_history.utils import ( |
32 | | - bulk_create_with_history, |
33 | | - bulk_update_with_history, |
34 | | - get_history_manager_for_model, |
35 | | - get_history_model_for_model, |
36 | | - get_m2m_field_name, |
37 | | - get_m2m_reverse_field_name, |
38 | | - update_change_reason, |
39 | | -) |
40 | 41 |
|
41 | 42 | User = get_user_model() |
42 | 43 |
|
43 | 44 |
|
| 45 | +class UpdateChangeReasonTestCase(TestCase): |
| 46 | + def test_update_change_reason_with_excluded_fields(self): |
| 47 | + poll = PollWithExcludeFields( |
| 48 | + question="what's up?", pub_date=timezone.now(), place="The Pub" |
| 49 | + ) |
| 50 | + poll.save() |
| 51 | + update_change_reason(poll, "Test change reason.") |
| 52 | + most_recent = poll.history.order_by("-history_date").first() |
| 53 | + self.assertEqual(most_recent.history_change_reason, "Test change reason.") |
| 54 | + |
| 55 | + |
44 | 56 | class GetM2MFieldNamesTestCase(unittest.TestCase): |
45 | 57 | def test__get_m2m_field_name__returns_expected_value(self): |
46 | 58 | def field_names(model): |
@@ -629,14 +641,3 @@ def test_bulk_manager_with_custom_model_attributes(self): |
629 | 641 | PollWithHistoricalSessionAttr.history.filter(session="co-op").count(), |
630 | 642 | 5, |
631 | 643 | ) |
632 | | - |
633 | | - |
634 | | -class UpdateChangeReasonTestCase(TestCase): |
635 | | - def test_update_change_reason_with_excluded_fields(self): |
636 | | - poll = PollWithExcludeFields( |
637 | | - question="what's up?", pub_date=timezone.now(), place="The Pub" |
638 | | - ) |
639 | | - poll.save() |
640 | | - update_change_reason(poll, "Test change reason.") |
641 | | - most_recent = poll.history.order_by("-history_date").first() |
642 | | - self.assertEqual(most_recent.history_change_reason, "Test change reason.") |
|
0 commit comments