mirror of https://github.com/zulip/zulip.git
Fix bad Django test suite interaction with get_client default.
authenticated_api_view and authenticated_json_view call update_user_activity with a client generated using @has_request_variables with a default of e.g. get_client("website"). Because that get_client call only happens once on importing the module, if those client objects didn't exist previously in the fixtures, then the first test will generate objects with ids 2 and 3, and then the second test will dump the database, restore from the fixtures, and then eventually generate client objects with ids 4 and 5. But since the default values were only computed at module load, we'll still end calling add_user_activity with client objects with ids 2 and 3, which don't exist in the newly restored database. Fix this madness by just making sure those two client objects exist in the database. (imported from commit d940e129d077a560d9a0f96ec3daa2e16ce21c8b)
This commit is contained in:
parent
16b1f63800
commit
bc2ace726c
|
@ -208,6 +208,12 @@ class Command(BaseCommand):
|
|||
]
|
||||
create_users(realms, internal_humbug_users_nosubs)
|
||||
|
||||
# Create the "website" and "API" clients; if we don't, the
|
||||
# default values in zephyr/decorators.py will not work
|
||||
# with the Django test suite.
|
||||
get_client("website")
|
||||
get_client("API")
|
||||
|
||||
self.stdout.write("Successfully populated test database.\n")
|
||||
if options["replay_old_messages"]:
|
||||
restore_saved_messages()
|
||||
|
|
Loading…
Reference in New Issue