Skip to content

Commit

Permalink
Don't delete user, simplify thread request unsetting test steps
Browse files Browse the repository at this point in the history
  • Loading branch information
macro1 committed Mar 18, 2016
1 parent 7622c84 commit 3daa6a9
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions simple_history/tests/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,31 +218,26 @@ def test_rolled_back_user_does_not_lead_to_foreign_key_error(self):
# happens, e.g. in test cases), and verifies that subsequently
# creating a new entry does not fail with a foreign key error.

class Rollback(Exception):
pass

overridden_settings = {
'MIDDLEWARE_CLASSES':
settings.MIDDLEWARE_CLASSES
+ ['simple_history.middleware.HistoryRequestMiddleware'],
}
with override_settings(**overridden_settings):
try:
with atomic():
user = User.objects.create_superuser(
'tmp', 't@example.com', 'pass')
self.assertTrue(self.client.login(username='tmp', password='pass'))
self.app.get(reverse('admin:tests_book_add'))
raise Rollback()
except Rollback:
pass
self.login()
self.assertEqual(
self.app.get(reverse('admin:tests_book_add')).status_code,
200,
)

book = Book.objects.create(isbn="9780147_513731")
historical_book = book.history.all()[0]
self.assertIsNone(
historical_book.history_user,
"No way to know of request, history_user should be unset.",
)

historical_book = book.history.all()[0]

self.assertIsNone(
historical_book.history_user,
"No way to know of request, history_user should be unset.",
)

def test_middleware_anonymous_user(self):
overridden_settings = {
Expand Down

0 comments on commit 3daa6a9

Please sign in to comment.