Skip to content

Commit

Permalink
more tests to ensure that queries on historical models in separate db…
Browse files Browse the repository at this point in the history
…s are still possible
  • Loading branch information
dopatraman committed Apr 12, 2019
1 parent 4125522 commit 6f116c7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions simple_history/tests/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,10 +1493,15 @@ def setUp(self):
self.user = get_user_model().objects.create(
username="username", email="[email protected]", password="top_secret"
)
self.model_ = ModelWithHistoryInDifferentDb(name="test")

def tearDown(self):
self.model_ = None

def test_using_separate_db(self):
self.assertEqual("other", self.model_.history.db)
self.model_ = ModelWithHistoryInDifferentDb(name="test")
self.model_.save()
self.assertEqual("other", self.model_.history.using('other').db)
self.assertEqual(1, self.model_.history.using('other').count())
self.assertEqual("+", self.model_.history.using('other').first().history_type)
self.model_.name = "test1"
self.model_.save()
self.assertEqual("other", self.model_.history.using('other').db)
self.assertEqual(2, self.model_.history.using('other').count())
self.assertEqual("~", self.model_.history.using('other').first().history_type)

0 comments on commit 6f116c7

Please sign in to comment.