Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dopatraman committed Apr 4, 2019
1 parent 0d15f2b commit c5e04e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions simple_history/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ class ModelWithHistoryInDifferentApp(models.Model):
history = HistoricalRecords(app="external")


class ModelWithHistoryInDifferentDb(models.Model):
name = models.CharField(max_length=30)
history = HistoricalRecords(using="other")


###############################################################################
#
# Inheritance examples
Expand Down
18 changes: 17 additions & 1 deletion simple_history/tests/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
from django.urls import reverse

from simple_history.models import HistoricalRecords, ModelChange
from simple_history.signals import pre_create_historical_record
from simple_history.signals import (
pre_create_historical_record,
post_create_historical_record,
)
from simple_history.tests.custom_user.models import CustomUser
from simple_history.tests.tests.utils import (
database_router_override_settings,
Expand Down Expand Up @@ -60,6 +63,7 @@
HistoricalPollWithHistoricalIPAddress,
HistoricalState,
Library,
ModelWithHistoryInDifferentDb,
MultiOneToOne,
Person,
Place,
Expand Down Expand Up @@ -1413,3 +1417,15 @@ def test_history_user_does_not_exist(self):

self.assertEqual(user_id, instance.history.first().history_user_id)
self.assertIsNone(instance.history.first().history_user)


class UsingSeparateDatabaseTestCase(TestCase):
def setUp(self):
self.model_ = ModelWithHistoryInDifferentDb(name="test")

def tearDown(self):
pass

def test_using_separate_db(self):
models_ = ModelWithHistoryInDifferentDb.objects.all()
self.assertEqual("default", self.model_.history.db)

0 comments on commit c5e04e5

Please sign in to comment.