matlab-proxy 0.18.1__py3-none-any.whl → 0.19.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of matlab-proxy might be problematic. Click here for more details.
- matlab_proxy/app.py +54 -43
- matlab_proxy/app_state.py +370 -155
- matlab_proxy/constants.py +3 -0
- matlab_proxy/gui/asset-manifest.json +6 -6
- matlab_proxy/gui/index.html +1 -1
- matlab_proxy/gui/static/css/{main.47712126.css → main.da9c4eb8.css} +2 -2
- matlab_proxy/gui/static/css/main.da9c4eb8.css.map +1 -0
- matlab_proxy/gui/static/js/{main.5b5ca2f2.js → main.e07799e7.js} +3 -3
- matlab_proxy/gui/static/js/main.e07799e7.js.map +1 -0
- matlab_proxy/matlab/startup.m +0 -20
- matlab_proxy/settings.py +28 -3
- matlab_proxy/util/__init__.py +101 -1
- matlab_proxy/util/event_loop.py +28 -10
- matlab_proxy/util/mwi/embedded_connector/__init__.py +1 -1
- matlab_proxy/util/mwi/embedded_connector/helpers.py +9 -0
- matlab_proxy/util/mwi/embedded_connector/request.py +51 -21
- matlab_proxy/util/mwi/environment_variables.py +6 -1
- matlab_proxy/util/mwi/exceptions.py +16 -1
- matlab_proxy/util/mwi/validators.py +33 -0
- {matlab_proxy-0.18.1.dist-info → matlab_proxy-0.19.0.dist-info}/METADATA +1 -1
- {matlab_proxy-0.18.1.dist-info → matlab_proxy-0.19.0.dist-info}/RECORD +31 -31
- tests/unit/test_app.py +45 -22
- tests/unit/test_app_state.py +404 -111
- tests/unit/test_constants.py +1 -0
- tests/unit/util/mwi/test_validators.py +30 -1
- tests/unit/util/test_util.py +83 -0
- matlab_proxy/gui/static/css/main.47712126.css.map +0 -1
- matlab_proxy/gui/static/js/main.5b5ca2f2.js.map +0 -1
- /matlab_proxy/gui/static/js/{main.5b5ca2f2.js.LICENSE.txt → main.e07799e7.js.LICENSE.txt} +0 -0
- {matlab_proxy-0.18.1.dist-info → matlab_proxy-0.19.0.dist-info}/LICENSE.md +0 -0
- {matlab_proxy-0.18.1.dist-info → matlab_proxy-0.19.0.dist-info}/WHEEL +0 -0
- {matlab_proxy-0.18.1.dist-info → matlab_proxy-0.19.0.dist-info}/entry_points.txt +0 -0
- {matlab_proxy-0.18.1.dist-info → matlab_proxy-0.19.0.dist-info}/top_level.txt +0 -0
tests/unit/test_app.py
CHANGED
|
@@ -61,7 +61,7 @@ def test_configure_no_proxy_in_env(monkeypatch, no_proxy_user_configuration):
|
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
def test_create_app():
|
|
64
|
+
def test_create_app(loop):
|
|
65
65
|
"""Test if aiohttp server is being created successfully.
|
|
66
66
|
|
|
67
67
|
Checks if the aiohttp server is created successfully, routes, startup and cleanup
|
|
@@ -75,6 +75,7 @@ def test_create_app():
|
|
|
75
75
|
# Verify app server has a cleanup task
|
|
76
76
|
# By default there is 1 for clean up task
|
|
77
77
|
assert len(test_server.on_cleanup) > 1
|
|
78
|
+
loop.run_until_complete(test_server["state"].stop_server_tasks())
|
|
78
79
|
|
|
79
80
|
|
|
80
81
|
def get_email():
|
|
@@ -311,12 +312,13 @@ async def test_get_env_config(test_server):
|
|
|
311
312
|
"matlab": {
|
|
312
313
|
"status": "up",
|
|
313
314
|
"version": "R2023a",
|
|
314
|
-
"
|
|
315
|
+
"supportedVersions": ["R2020b", "R2023a"],
|
|
315
316
|
},
|
|
316
317
|
"doc_url": "foo",
|
|
317
318
|
"extension_name": "bar",
|
|
318
319
|
"extension_name_short_description": "foobar",
|
|
319
320
|
"isConcurrencyEnabled": "foobar",
|
|
321
|
+
"idleTimeoutDuration": 100,
|
|
320
322
|
}
|
|
321
323
|
resp = await test_server.get("/get_env_config")
|
|
322
324
|
assert resp.status == HTTPStatus.OK
|
|
@@ -336,23 +338,33 @@ async def test_start_matlab_route(test_server):
|
|
|
336
338
|
test_server (aiohttp_client): A aiohttp_client server to send GET request to.
|
|
337
339
|
"""
|
|
338
340
|
# Waiting for the matlab process to start up.
|
|
339
|
-
|
|
340
|
-
|
|
341
|
+
await wait_for_matlab_to_be_up(
|
|
342
|
+
test_server, test_constants.CHECK_MATLAB_STATUS_INTERVAL
|
|
343
|
+
)
|
|
341
344
|
|
|
342
345
|
# Send get request to end point
|
|
343
346
|
await test_server.put("/start_matlab")
|
|
344
347
|
|
|
345
348
|
# Check if Matlab restarted successfully
|
|
346
|
-
await
|
|
349
|
+
await __check_for_matlab_status(test_server, "starting")
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
async def __check_for_matlab_status(test_server, status):
|
|
353
|
+
"""Helper function to check if the status of MATLAB returned by the server is either of the values mentioned in statuses
|
|
347
354
|
|
|
355
|
+
Args:
|
|
356
|
+
test_server (aiohttp_client): A aiohttp_client server to send HTTP DELETE request.
|
|
357
|
+
statuses ([str]): Possible MATLAB statuses.
|
|
348
358
|
|
|
349
|
-
|
|
359
|
+
Raises:
|
|
360
|
+
ConnectionError: Exception raised if the test_server is not reachable.
|
|
361
|
+
"""
|
|
350
362
|
count = 0
|
|
351
363
|
while True:
|
|
352
364
|
resp = await test_server.get("/get_status")
|
|
353
365
|
assert resp.status == HTTPStatus.OK
|
|
354
366
|
resp_json = json.loads(await resp.text())
|
|
355
|
-
if resp_json["matlab"]["status"]
|
|
367
|
+
if resp_json["matlab"]["status"] == status:
|
|
356
368
|
break
|
|
357
369
|
else:
|
|
358
370
|
count += 1
|
|
@@ -365,14 +377,20 @@ async def test_stop_matlab_route(test_server):
|
|
|
365
377
|
"""Test to check endpoint : "/stop_matlab"
|
|
366
378
|
|
|
367
379
|
Sends HTTP DELETE request to stop matlab and checks if matlab status is down.
|
|
380
|
+
|
|
368
381
|
Args:
|
|
369
382
|
test_server (aiohttp_client): A aiohttp_client server to send HTTP DELETE request.
|
|
370
383
|
"""
|
|
384
|
+
# Arrange
|
|
385
|
+
# Nothing to arrange
|
|
386
|
+
|
|
387
|
+
# Act
|
|
371
388
|
resp = await test_server.delete("/stop_matlab")
|
|
372
389
|
assert resp.status == HTTPStatus.OK
|
|
373
390
|
|
|
374
|
-
|
|
375
|
-
|
|
391
|
+
# Assert
|
|
392
|
+
# Check if Matlab restarted successfully
|
|
393
|
+
await __check_for_matlab_status(test_server, "stopping")
|
|
376
394
|
|
|
377
395
|
|
|
378
396
|
async def test_root_redirect(test_server):
|
|
@@ -643,8 +661,7 @@ async def test_matlab_proxy_web_socket(test_server, headers):
|
|
|
643
661
|
test_server (aiohttp_client): Test Server to send HTTP Requests.
|
|
644
662
|
"""
|
|
645
663
|
|
|
646
|
-
|
|
647
|
-
await wait_for_matlab_to_be_up(test_server, sleep_interval)
|
|
664
|
+
await wait_for_matlab_to_be_up(test_server, test_constants.ONE_SECOND_DELAY)
|
|
648
665
|
resp = await test_server.ws_connect("/http_ws_request.html/", headers=headers)
|
|
649
666
|
text = await resp.receive()
|
|
650
667
|
websocket_response_string = (
|
|
@@ -703,19 +720,21 @@ async def test_set_licensing_info_delete(test_server):
|
|
|
703
720
|
|
|
704
721
|
|
|
705
722
|
async def test_set_termination_integration_delete(test_server):
|
|
706
|
-
"""Test to check endpoint : "/
|
|
723
|
+
"""Test to check endpoint : "/shutdown_integration"
|
|
707
724
|
|
|
708
|
-
Test which sends HTTP DELETE request to
|
|
725
|
+
Test which sends HTTP DELETE request to shutdown integration. Checks if integration is shutdown
|
|
709
726
|
successfully.
|
|
710
727
|
Args:
|
|
711
728
|
test_server (aiohttp_client): A aiohttp_client server to send HTTP GET request.
|
|
712
729
|
"""
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
730
|
+
# Not awaiting the response here explicitly as the event loop is stopped in the
|
|
731
|
+
# handler function.
|
|
732
|
+
test_server.delete("/shutdown_integration")
|
|
733
|
+
|
|
734
|
+
resp = await test_server.get("/")
|
|
735
|
+
|
|
736
|
+
# Assert that the service is unavailable
|
|
737
|
+
assert resp.status == 503
|
|
719
738
|
|
|
720
739
|
|
|
721
740
|
def test_get_access_url(test_server):
|
|
@@ -724,6 +743,7 @@ def test_get_access_url(test_server):
|
|
|
724
743
|
Args:
|
|
725
744
|
test_server (aiohttp.web.Application): Application Server
|
|
726
745
|
"""
|
|
746
|
+
|
|
727
747
|
assert "127.0.0.1" in util.get_access_url(test_server.app)
|
|
728
748
|
|
|
729
749
|
|
|
@@ -866,6 +886,10 @@ async def set_licensing_info_fixture(
|
|
|
866
886
|
"sourceId": "abc@nlm",
|
|
867
887
|
"matlabVersion": "R2023a",
|
|
868
888
|
}
|
|
889
|
+
|
|
890
|
+
# Waiting for the matlab process to start up.
|
|
891
|
+
await wait_for_matlab_to_be_up(test_server, test_constants.ONE_SECOND_DELAY)
|
|
892
|
+
|
|
869
893
|
# Set matlab_version to None to check if the version is updated
|
|
870
894
|
# after sending a request t o /set_licensing_info endpoint
|
|
871
895
|
test_server.server.app["settings"]["matlab_version"] = None
|
|
@@ -967,7 +991,7 @@ async def test_set_licensing_mhlm_single_entitlement(
|
|
|
967
991
|
assert resp_json["licensing"]["entitlementId"] == "Entitlement3"
|
|
968
992
|
|
|
969
993
|
# validate that MATLAB has started correctly
|
|
970
|
-
await
|
|
994
|
+
await __check_for_matlab_status(test_server, "up")
|
|
971
995
|
|
|
972
996
|
# test-cleanup: unset licensing
|
|
973
997
|
# without this, we can leave test drool related to cached license file
|
|
@@ -1020,8 +1044,7 @@ async def test_set_licensing_mhlm_multi_entitlements(
|
|
|
1020
1044
|
# user hasn't selected the license yet
|
|
1021
1045
|
resp = await test_server.get("/get_status")
|
|
1022
1046
|
assert resp.status == HTTPStatus.OK
|
|
1023
|
-
|
|
1024
|
-
assert resp_json["matlab"]["status"] == "down"
|
|
1047
|
+
__check_for_matlab_status(test_server, "down")
|
|
1025
1048
|
|
|
1026
1049
|
# test-cleanup: unset licensing
|
|
1027
1050
|
resp = await test_server.delete("/set_licensing_info")
|