matlab-proxy 0.18.2__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 +16 -1
- 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 +5 -0
- matlab_proxy/util/mwi/exceptions.py +16 -1
- matlab_proxy/util/mwi/validators.py +33 -0
- {matlab_proxy-0.18.2.dist-info → matlab_proxy-0.19.0.dist-info}/METADATA +1 -1
- {matlab_proxy-0.18.2.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.2.dist-info → matlab_proxy-0.19.0.dist-info}/LICENSE.md +0 -0
- {matlab_proxy-0.18.2.dist-info → matlab_proxy-0.19.0.dist-info}/WHEEL +0 -0
- {matlab_proxy-0.18.2.dist-info → matlab_proxy-0.19.0.dist-info}/entry_points.txt +0 -0
- {matlab_proxy-0.18.2.dist-info → matlab_proxy-0.19.0.dist-info}/top_level.txt +0 -0
tests/unit/util/test_util.py
CHANGED
|
@@ -4,6 +4,9 @@ import asyncio
|
|
|
4
4
|
import pytest
|
|
5
5
|
import psutil
|
|
6
6
|
|
|
7
|
+
import inspect
|
|
8
|
+
|
|
9
|
+
from matlab_proxy import util
|
|
7
10
|
from matlab_proxy.util import get_child_processes, system, add_signal_handlers, prettify
|
|
8
11
|
from matlab_proxy.util import system
|
|
9
12
|
from matlab_proxy.util.mwi.exceptions import (
|
|
@@ -136,3 +139,83 @@ def test_get_child_processes_parent_not_running(mocker):
|
|
|
136
139
|
match="Can't check for child processes as the parent process is no longer running.",
|
|
137
140
|
):
|
|
138
141
|
get_child_processes(parent_process)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def test_get_caller_name():
|
|
145
|
+
"""Test to check if caller name is not empty"""
|
|
146
|
+
# Arrange
|
|
147
|
+
|
|
148
|
+
# Act
|
|
149
|
+
caller_name = util.get_caller_name()
|
|
150
|
+
|
|
151
|
+
# Assert
|
|
152
|
+
assert caller_name is not None
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@pytest.fixture
|
|
156
|
+
def tracking_lock():
|
|
157
|
+
"""Pytest fixture which returns an instance of TrackingLock for testing purposes."""
|
|
158
|
+
return util.TrackingLock("test_purpose")
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
async def test_TrackingLock(tracking_lock):
|
|
162
|
+
"""Test to check various methods of TrackingLock class
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
tracking_lock (TrackingLock): Pytest fixture
|
|
166
|
+
"""
|
|
167
|
+
name_of_current_fn = inspect.currentframe().f_code.co_name
|
|
168
|
+
|
|
169
|
+
await tracking_lock.acquire()
|
|
170
|
+
assert tracking_lock.acquired_by == name_of_current_fn
|
|
171
|
+
assert tracking_lock.locked()
|
|
172
|
+
|
|
173
|
+
await tracking_lock.release()
|
|
174
|
+
tracking_lock.acquired_by is None
|
|
175
|
+
assert not tracking_lock.locked()
|
|
176
|
+
|
|
177
|
+
assert tracking_lock.purpose is not None
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
async def test_validate_lock_for_caller_when_not_locked(tracking_lock):
|
|
181
|
+
"""Test to check if validate_lock_for_caller returns False when the lock is not acquired
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
tracking_lock (TrackingLock): Pytest fixture
|
|
185
|
+
"""
|
|
186
|
+
assert not tracking_lock.validate_lock_for_caller("some_caller")
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
async def test_validate_lock_for_caller_happy_path(tracking_lock):
|
|
190
|
+
"""Test to check if validate_lock_for_caller returns True when the lock was acquired by the
|
|
191
|
+
same function as the caller.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
tracking_lock (TrackingLock): Pytest fixture
|
|
195
|
+
"""
|
|
196
|
+
name_of_current_fn = inspect.currentframe().f_code.co_name
|
|
197
|
+
|
|
198
|
+
await tracking_lock.acquire()
|
|
199
|
+
assert tracking_lock.validate_lock_for_caller(name_of_current_fn)
|
|
200
|
+
await tracking_lock.release()
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
async def test_validate_lock_for_caller_lock_acquired_by_other_function(tracking_lock):
|
|
204
|
+
"""Test to check if validate_lock_for_caller returns False when the lock was acquired by
|
|
205
|
+
some other function
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
tracking_lock (TrackingLock): Pytest fixture
|
|
209
|
+
"""
|
|
210
|
+
# Arrange
|
|
211
|
+
name_of_current_fn = inspect.currentframe().f_code.co_name
|
|
212
|
+
|
|
213
|
+
# Acquire lock inside a nested function
|
|
214
|
+
def nested_fn():
|
|
215
|
+
tracking_lock.acquire()
|
|
216
|
+
|
|
217
|
+
# Act
|
|
218
|
+
nested_fn()
|
|
219
|
+
|
|
220
|
+
# Assert
|
|
221
|
+
assert not tracking_lock.validate_lock_for_caller(name_of_current_fn)
|