mirror of https://github.com/zulip/zulip.git
populate_db: Fix cache flushing when rebuilding test database.
This fixes a similar problem to the last commit; we don't use memcached with the test database, so we don't need to flush memcached when rebuilding it. (And if we try, we'll get exceptions trying to access the relevant settings).
This commit is contained in:
parent
571ce2f5cb
commit
0dc7542363
|
@ -50,10 +50,16 @@ def clear_database() -> None:
|
|||
# Hacky function only for use inside populate_db. Designed to
|
||||
# allow running populate_db repeatedly in series to work without
|
||||
# flushing memcached or clearing the database manually.
|
||||
pylibmc.Client(
|
||||
[default_cache['LOCATION']],
|
||||
behaviors=default_cache["OPTIONS"] # type: ignore # settings not typed properly
|
||||
).flush_all()
|
||||
|
||||
# With `zproject.test_settings`, we aren't using real memcached
|
||||
# and; we only need to flush memcached if we're populating a
|
||||
# database that would be used with it (i.e. zproject.dev_settings).
|
||||
if default_cache['BACKEND'] == 'django_pylibmc.memcached.PyLibMCCache':
|
||||
pylibmc.Client(
|
||||
[default_cache['LOCATION']],
|
||||
behaviors=default_cache["OPTIONS"] # type: ignore # settings not typed properly
|
||||
).flush_all()
|
||||
|
||||
model = None # type: Any # Hack because mypy doesn't know these are model classes
|
||||
for model in [Message, Stream, UserProfile, Recipient,
|
||||
Realm, Subscription, Huddle, UserMessage, Client,
|
||||
|
|
Loading…
Reference in New Issue