Skip to content
Snippets Groups Projects
Commit 68da90cc authored by Antoine Lambert's avatar Antoine Lambert
Browse files

test_gunicorn_config: Fix test after swh-core 3.0.1 release

parent f0191352
No related branches found
No related tags found
1 merge request!1278package.json: Bump dependencies
Pipeline #8579 passed
swh.auth[django] >= 0.6.7
swh.core >= 3.0.0
swh.core >= 3.0.1
swh.counters >= 0.5.1
swh.indexer >= 2.0.0
swh.model >= 6.3.0
......
# Copyright (C) 2019-2020 The Software Heritage developers
# Copyright (C) 2019-2024 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import os
from unittest.mock import patch
import swh.web.gunicorn_config as gunicorn_config
django_integration = object() # unique object to check for equality
def test_post_fork_default():
with patch("sentry_sdk.init") as sentry_sdk_init:
gunicorn_config.post_fork(None, None)
sentry_sdk_init.assert_not_called()
def test_post_fork_default(mocker):
mocker.patch(
"swh.web.gunicorn_config.DjangoIntegration", new=lambda: django_integration
)
sentry_sdk_init = mocker.patch("sentry_sdk.init")
gunicorn_config.post_fork(None, None)
sentry_sdk_init.assert_called_once_with(
dsn=None,
environment=None,
integrations=[django_integration],
debug=False,
release=None,
)
def test_post_fork_with_dsn_env():
django_integration = object() # unique object to check for equality
with patch(
def test_post_fork_with_dsn_env(mocker):
mocker.patch(
"swh.web.gunicorn_config.DjangoIntegration", new=lambda: django_integration
):
with patch("sentry_sdk.init") as sentry_sdk_init:
with patch.dict(os.environ, {"SWH_SENTRY_DSN": "test_dsn"}):
gunicorn_config.post_fork(None, None)
)
sentry_sdk_init = mocker.patch("sentry_sdk.init")
mocker.patch.dict(os.environ, {"SWH_SENTRY_DSN": "test_dsn"})
gunicorn_config.post_fork(None, None)
sentry_sdk_init.assert_called_once_with(
dsn="test_dsn",
environment=None,
......@@ -34,17 +41,15 @@ def test_post_fork_with_dsn_env():
)
def test_post_fork_debug():
django_integration = object() # unique object to check for equality
with patch(
def test_post_fork_debug(mocker):
mocker.patch(
"swh.web.gunicorn_config.DjangoIntegration", new=lambda: django_integration
):
with patch("sentry_sdk.init") as sentry_sdk_init:
with patch.dict(
os.environ, {"SWH_SENTRY_DSN": "test_dsn", "SWH_SENTRY_DEBUG": "1"}
):
gunicorn_config.post_fork(None, None)
)
sentry_sdk_init = mocker.patch("sentry_sdk.init")
mocker.patch.dict(
os.environ, {"SWH_SENTRY_DSN": "test_dsn", "SWH_SENTRY_DEBUG": "1"}
)
gunicorn_config.post_fork(None, None)
sentry_sdk_init.assert_called_once_with(
dsn="test_dsn",
environment=None,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment