Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-deposit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Lambert
swh-deposit
Commits
c61cb817
Commit
c61cb817
authored
11 months ago
by
Antoine Lambert
Browse files
Options
Downloads
Patches
Plain Diff
test_gunicorn_config: Fix test after swh-core v3.0.1 release
parent
2d68abb1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/deposit/tests/test_gunicorn_config.py
+41
-33
41 additions, 33 deletions
swh/deposit/tests/test_gunicorn_config.py
with
41 additions
and
33 deletions
swh/deposit/tests/test_gunicorn_config.py
+
41
−
33
View file @
c61cb817
# Copyright (C) 2019-202
0
The Software Heritage developers
# Copyright (C) 2019-202
4
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
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment