Skip to content

Commit

Permalink
settings: Remove settings.BACKEND_DATABASE_TEMPLATE.
Browse files Browse the repository at this point in the history
BACKEND_DATABASE_TEMPLATE was introduced in a507a47.
This setting is only available for the test cases and it is not that
necessary to have it configurable.

We define it as a global variable in zerver.lib.test_fixtures.

This avoids requiring mypy_django_plugin to know the type of
settings.BACKEND_DATABASE_TEMPLATE for type checking purposes, given the fact
that settings.test_extra_settings is not available in production/development
setup.

Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 authored and timabbott committed Aug 11, 2022
1 parent 448253c commit f994ba3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion zerver/lib/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
write_new_digest,
)

BACKEND_DATABASE_TEMPLATE = "zulip_test_template"
UUID_VAR_DIR = get_dev_uuid_var_path()

IMPORTANT_FILES = [
Expand Down Expand Up @@ -413,7 +414,7 @@ def reset_zulip_test_database() -> None:

destroy_test_databases()
# Pointing default database to test database template, so we can instantly clone it.
settings.DATABASES["default"]["NAME"] = settings.BACKEND_DATABASE_TEMPLATE
settings.DATABASES["default"]["NAME"] = BACKEND_DATABASE_TEMPLATE
connection = connections["default"]
clone_database_suffix = "clone"
connection.creation.clone_test_db(
Expand Down
3 changes: 2 additions & 1 deletion zerver/lib/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)
from zerver.lib import test_helpers
from zerver.lib.sqlalchemy_utils import get_sqlalchemy_connection
from zerver.lib.test_fixtures import BACKEND_DATABASE_TEMPLATE
from zerver.lib.test_helpers import append_instrumentation_data, write_instrumentation_reports

# We need to pick an ID for this test-backend invocation, and store it
Expand Down Expand Up @@ -289,7 +290,7 @@ def get_shallow_tested_templates(self) -> Set[str]:
return self.shallow_tested_templates

def setup_test_environment(self, *args: Any, **kwargs: Any) -> Any:
settings.DATABASES["default"]["NAME"] = settings.BACKEND_DATABASE_TEMPLATE
settings.DATABASES["default"]["NAME"] = BACKEND_DATABASE_TEMPLATE
# We create/destroy the test databases in run_tests to avoid
# duplicate work when running in parallel mode.

Expand Down
3 changes: 0 additions & 3 deletions zproject/test_extra_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
# Clear out the REALM_HOSTS set in dev_settings.py
REALM_HOSTS: Dict[str, str] = {}

# Used to clone DBs in backend tests.
BACKEND_DATABASE_TEMPLATE = "zulip_test_template"

DATABASES["default"] = {
"NAME": os.getenv("ZULIP_DB_NAME", "zulip_test"),
"USER": "zulip_test",
Expand Down

0 comments on commit f994ba3

Please sign in to comment.