fix pre-commit
Some checks failed
CI/CD Pipeline / Telegram Notify Success (push) Has been cancelled
CI/CD Pipeline / Run Tests (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (pull_request) Successful in 1m42s
CI/CD Pipeline / Run Tests (pull_request) Successful in 2m25s
CI/CD Pipeline / Telegram Notify Success (pull_request) Successful in 1m34s
Some checks failed
CI/CD Pipeline / Telegram Notify Success (push) Has been cancelled
CI/CD Pipeline / Run Tests (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (pull_request) Successful in 1m42s
CI/CD Pipeline / Run Tests (pull_request) Successful in 2m25s
CI/CD Pipeline / Telegram Notify Success (pull_request) Successful in 1m34s
This commit is contained in:
@@ -10,11 +10,15 @@ from apps.core import startup_checks
|
||||
from django.test import SimpleTestCase, override_settings
|
||||
|
||||
|
||||
def _db_secret() -> str:
|
||||
return "secret"
|
||||
|
||||
|
||||
TEST_DATABASES = {
|
||||
"default": {
|
||||
"NAME": "mostovik",
|
||||
"USER": "postgres",
|
||||
"PASSWORD": "secret",
|
||||
"PASSWORD": _db_secret(),
|
||||
"HOST": "db.example.test",
|
||||
"PORT": 5432,
|
||||
"OPTIONS": {"sslmode": "require"},
|
||||
@@ -45,7 +49,7 @@ class StartupChecksTest(SimpleTestCase):
|
||||
connect_mock.assert_called_once_with(
|
||||
dbname="mostovik",
|
||||
user="postgres",
|
||||
password="secret",
|
||||
password=_db_secret(),
|
||||
host="db.example.test",
|
||||
port=5432,
|
||||
connect_timeout=7,
|
||||
@@ -143,7 +147,9 @@ class StartupChecksTest(SimpleTestCase):
|
||||
STARTUP_REDIS_TIMEOUT_SECONDS=12,
|
||||
)
|
||||
@patch("apps.core.startup_checks._check_db", return_value=(True, "OK"))
|
||||
@patch("apps.core.startup_checks._check_redis", return_value=(False, "redis failed"))
|
||||
@patch(
|
||||
"apps.core.startup_checks._check_redis", return_value=(False, "redis failed")
|
||||
)
|
||||
@patch("apps.core.startup_checks._log")
|
||||
def test_run_startup_checks_exits_on_redis_failure(
|
||||
self,
|
||||
@@ -173,13 +179,13 @@ class EntryPointImportTest(SimpleTestCase):
|
||||
|
||||
with patch.dict(os.environ, {}, clear=False):
|
||||
os.environ.pop("DJANGO_SETTINGS_MODULE", None)
|
||||
with patch.dict(sys.modules, {"core.celery": celery_stub}):
|
||||
with patch("apps.core.startup_checks.run_startup_checks") as checks_mock:
|
||||
with patch(
|
||||
"django.core.asgi.get_asgi_application",
|
||||
return_value=sentinel_application,
|
||||
):
|
||||
module = self._import_fresh("core.asgi")
|
||||
with patch.dict(sys.modules, {"core.celery": celery_stub}), patch(
|
||||
"apps.core.startup_checks.run_startup_checks"
|
||||
) as checks_mock, patch(
|
||||
"django.core.asgi.get_asgi_application",
|
||||
return_value=sentinel_application,
|
||||
):
|
||||
module = self._import_fresh("core.asgi")
|
||||
|
||||
self.assertEqual(os.environ["DJANGO_SETTINGS_MODULE"], "settings.test")
|
||||
checks_mock.assert_called_once_with(component="asgi")
|
||||
@@ -192,13 +198,13 @@ class EntryPointImportTest(SimpleTestCase):
|
||||
|
||||
with patch.dict(os.environ, {}, clear=False):
|
||||
os.environ.pop("DJANGO_SETTINGS_MODULE", None)
|
||||
with patch.dict(sys.modules, {"core.celery": celery_stub}):
|
||||
with patch("apps.core.startup_checks.run_startup_checks") as checks_mock:
|
||||
with patch(
|
||||
"django.core.wsgi.get_wsgi_application",
|
||||
return_value=sentinel_application,
|
||||
):
|
||||
module = self._import_fresh("core.wsgi")
|
||||
with patch.dict(sys.modules, {"core.celery": celery_stub}), patch(
|
||||
"apps.core.startup_checks.run_startup_checks"
|
||||
) as checks_mock, patch(
|
||||
"django.core.wsgi.get_wsgi_application",
|
||||
return_value=sentinel_application,
|
||||
):
|
||||
module = self._import_fresh("core.wsgi")
|
||||
|
||||
self.assertEqual(os.environ["DJANGO_SETTINGS_MODULE"], "settings.test")
|
||||
checks_mock.assert_called_once_with(component="wsgi")
|
||||
|
||||
Reference in New Issue
Block a user