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

test_gunicorn_config: Fix test after swh-core v3.0.1 release

parent 2d68abb1
No related branches found
No related tags found
No related merge requests found
# 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.deposit.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.deposit.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,
integrations=[django_integration],
environment=None,
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.deposit.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_ENVIRONMENT": "test",
},
):
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_ENVIRONMENT": "test",
},
)
gunicorn_config.post_fork(None, None)
sentry_sdk_init.assert_called_once_with(
dsn="test_dsn",
......@@ -40,21 +49,20 @@ 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.deposit.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",
"SWH_SENTRY_ENVIRONMENT": "test",
},
):
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",
"SWH_SENTRY_ENVIRONMENT": "test",
},
)
gunicorn_config.post_fork(None, None)
sentry_sdk_init.assert_called_once_with(
dsn="test_dsn",
......
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