Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
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
Container 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
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
ae90aae5
Verified
Commit
ae90aae5
authored
7 months ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
Move conftest that disallows external HTTP calls to parent module
parent
5418d156
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!239
Feature/send validation emails
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/conftest.py
+24
-0
24 additions, 0 deletions
test/conftest.py
test/workflows/conftest.py
+0
-25
0 additions, 25 deletions
test/workflows/conftest.py
with
24 additions
and
25 deletions
test/conftest.py
+
24
−
0
View file @
ae90aae5
...
...
@@ -30,6 +30,7 @@ from sqlalchemy import create_engine, select, text
from
sqlalchemy.engine
import
make_url
from
sqlalchemy.orm
import
scoped_session
,
sessionmaker
from
starlette.testclient
import
TestClient
from
urllib3_mock
import
Responses
from
gso.db.models
import
PartnerType
from
gso.main
import
init_gso_app
...
...
@@ -516,3 +517,26 @@ def product_type_1_subscriptions_factory(product_type_1_subscription_factory):
@pytest.fixture
()
def
generic_subscription_1
(
product_type_1_subscription_factory
):
return
product_type_1_subscription_factory
()
@pytest.fixture
(
autouse
=
True
)
def
responses
():
responses_mock
=
Responses
(
"
requests.packages.urllib3
"
)
def
_find_request
(
call
):
mock_url
=
responses_mock
.
_find_match
(
call
.
request
)
# noqa: SLF001
if
not
mock_url
:
pytest
.
fail
(
f
"
Call not mocked:
{
call
.
request
}
"
)
return
mock_url
def
_to_tuple
(
url_mock
):
return
url_mock
[
"
url
"
],
url_mock
[
"
method
"
],
url_mock
[
"
match_querystring
"
]
with
responses_mock
:
yield
responses_mock
mocked_urls
=
map
(
_to_tuple
,
responses_mock
.
_urls
)
# noqa: SLF001
used_urls
=
map
(
_to_tuple
,
map
(
_find_request
,
responses_mock
.
calls
))
not_used
=
set
(
mocked_urls
)
-
set
(
used_urls
)
if
not_used
:
pytest
.
fail
(
f
"
Found unused responses mocks:
{
not_used
}
"
,
pytrace
=
False
)
This diff is collapsed.
Click to expand it.
test/workflows/conftest.py
deleted
100644 → 0
+
0
−
25
View file @
5418d156
import
pytest
from
urllib3_mock
import
Responses
@pytest.fixture
(
autouse
=
True
)
def
responses
():
responses_mock
=
Responses
(
"
requests.packages.urllib3
"
)
def
_find_request
(
call
):
mock_url
=
responses_mock
.
_find_match
(
call
.
request
)
# noqa: SLF001
if
not
mock_url
:
pytest
.
fail
(
f
"
Call not mocked:
{
call
.
request
}
"
)
return
mock_url
def
_to_tuple
(
url_mock
):
return
url_mock
[
"
url
"
],
url_mock
[
"
method
"
],
url_mock
[
"
match_querystring
"
]
with
responses_mock
:
yield
responses_mock
mocked_urls
=
map
(
_to_tuple
,
responses_mock
.
_urls
)
# noqa: SLF001
used_urls
=
map
(
_to_tuple
,
map
(
_find_request
,
responses_mock
.
calls
))
not_used
=
set
(
mocked_urls
)
-
set
(
used_urls
)
if
not_used
:
pytest
.
fail
(
f
"
Found unused responses mocks:
{
not_used
}
"
,
pytrace
=
False
)
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