Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Domain Data Mgmt Services
Wellbore
Wellbore Domain Services
Commits
de736158
Commit
de736158
authored
Jul 09, 2021
by
Alexandre Vincent
Browse files
test middleware forward correlation_id to storage and search
parent
0baf8e13
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/middleware/client_test.py
0 → 100644
View file @
de736158
import
pytest
from
pytest_httpx
import
HTTPXMock
from
app.clients
import
make_storage_record_client
,
make_search_client
from
app.utils
import
Context
,
get_or_create_ctx
from
tests.unit.test_utils
import
ctx_fixture
,
nope_logger_fixture
@
pytest
.
mark
.
asyncio
async
def
test_fwd_correlation_id_to_outgoing_request_to_storage
(
ctx_fixture
,
httpx_mock
:
HTTPXMock
):
storage_url
=
"http://example.com"
# well formed url required
expected_correlation_id
=
'some-correlation-id'
storage_client
=
make_storage_record_client
(
storage_url
)
httpx_mock
.
add_response
(
match_headers
=
{
'correlation-id'
:
expected_correlation_id
})
ctx
=
ctx_fixture
.
with_correlation_id
(
expected_correlation_id
).
with_auth
(
"foobar"
)
Context
.
set_current
(
ctx
)
# force to use endpoint which does not return a response to skip model validation
response
=
await
storage_client
.
delete_record
(
id
=
"123"
,
data_partition_id
=
"test"
)
assert
response
is
not
None
@
pytest
.
mark
.
asyncio
async
def
test_fwd_correlation_id_to_outgoing_request_to_search
(
httpx_mock
:
HTTPXMock
):
storage_url
=
"http://example.com"
# well formed url required
expected_correlation_id
=
'some-correlation-id'
search_client
=
make_search_client
(
storage_url
)
httpx_mock
.
add_response
(
match_headers
=
{
'correlation-id'
:
expected_correlation_id
})
ctx
=
get_or_create_ctx
().
with_correlation_id
(
expected_correlation_id
).
with_auth
(
"foobar"
)
Context
.
set_current
(
ctx
)
# force to use endpoint which does not return a response to skip model validation
response
=
await
search_client
.
delete_index
(
kind
=
"kind"
,
data_partition_id
=
"test"
)
assert
response
is
not
None
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment