You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
I've written some automatic tests with WebTest. During execution of testsuite test data is generated automatically (some objects are created dynamically). If I don't use simple_history.middleware.HistoryRequestMiddleware, than all tests run successfully. If I use it, than the following error occurs:
ValueError(u'Cannot assign "<django.utils.functional.SimpleLazyObject object at 0x982332c>": "HistoricalActor.history_user" must be a "User" instance.
Could you, please, tell me the direction on digging for solving such problem.
The text was updated successfully, but these errors were encountered:
ValueError: Cannot assign "<SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7f08ddb4e470>>": "HistoricalCustomUser.history_user" must be a "CustomUser" instance.
It looks like we are not handling anonymous users. Try signing in for that test and trying again. If you would like to submit a PR, the test could be written in the test_admin.py module with the other middleware test.
The fix is pretty simple... We just need to make a check for is_authenticated() when we're assigning the value in HistoricalRecords.get_history_user().
Hello!
I've written some automatic tests with WebTest. During execution of testsuite test data is generated automatically (some objects are created dynamically). If I don't use simple_history.middleware.HistoryRequestMiddleware, than all tests run successfully. If I use it, than the following error occurs:
ValueError(u'Cannot assign "<django.utils.functional.SimpleLazyObject object at 0x982332c>": "HistoricalActor.history_user" must be a "User" instance.
Could you, please, tell me the direction on digging for solving such problem.
The text was updated successfully, but these errors were encountered: