Skip to content

Commit dac9bbf

Browse files
Kumar Pallavkrisctl
authored andcommitted
Refactors test to use mocks instead of real endpoints.
1 parent 0c56cd4 commit dac9bbf

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

tests/unit/test_app.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,15 +734,35 @@ async def test_matlab_view_websocket_success(
734734
assert mock_ws_server.pong.call_count == 1
735735

736736

737-
async def test_set_licensing_info_put_mhlm(test_server):
737+
async def test_set_licensing_info_put_mhlm(
738+
mocker,
739+
test_server,
740+
set_licensing_info_mock_expand_token,
741+
set_licensing_info_mock_access_token,
742+
set_licensing_info_mock_fetch_multiple_entitlements,
743+
):
738744
"""Test to check endpoint : "/set_licensing_info"
739745
740746
Test which sends HTTP PUT request with MHLM licensing information.
741747
Args:
742748
test_server (aiohttp_client): A aiohttp_client server to send HTTP GET request.
743749
"""
744-
# FIXME: This test is talking to production loginws endpoint and is resulting in an exception.
745-
# TODO: Use mocks to test the mhlm workflows is working as expected
750+
751+
mocker.patch(
752+
"matlab_proxy.app_state.mw.fetch_expand_token",
753+
return_value=set_licensing_info_mock_expand_token,
754+
)
755+
756+
mocker.patch(
757+
"matlab_proxy.app_state.mw.fetch_access_token",
758+
return_value=set_licensing_info_mock_access_token,
759+
)
760+
761+
mocker.patch(
762+
"matlab_proxy.app_state.mw.fetch_entitlements",
763+
return_value=set_licensing_info_mock_fetch_multiple_entitlements,
764+
)
765+
746766
data = {
747767
"type": "mhlm",
748768
"status": "starting",

0 commit comments

Comments
 (0)