Skip to content

Commit

Permalink
Update test_lab.py
Browse files Browse the repository at this point in the history
Revert accidental changes from another task.
  • Loading branch information
ShreyaGursal authored Oct 8, 2024
1 parent fe88e3e commit dafd646
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions tests/test_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from os import path, remove
import time

import pytest

from RPC_Test_Common import get_dir_path, reset_to_default_file
from RPC_Test_Common import reset_to_default_file


def test_model_build_lab(mc):
Expand Down Expand Up @@ -170,48 +166,3 @@ def test_external_custom_loss_functions(mc):

mc.remove_external_custom_loss(removed_name)
assert mc.get_variable("NumCustomLossesExternal_Lab") == no_external_losses + 1


def test_lab_model_export(mc):
mc.set_variable("MessageDisplayState", 2)
file_path = get_dir_path() + r"\test_files\temp_files\lab_model_export.lab"

mc.load_template("e3")

if path.exists(file_path):
remove(file_path)

assert path.exists(file_path) is False

mc.export_lab_model(file_path)

# Exporting the lab model takes a few seconds and so a delay is required before
# asserting the .lab file is present.
checks = 0

while checks < 20:
time.sleep(1)
if path.exists(file_path) is False:
checks += 1
else:
break

assert path.exists(file_path) is True

remove(file_path)

# Checks that a warning is raised if the model build speed has changed
mc.set_variable("LabModel_Saturation_StatorCurrent_Peak", 750)

with pytest.raises(Exception) as stator_current_changed_error:
mc.export_lab_model(file_path)

assert "maximum current has changed" in str(stator_current_changed_error)

# Clears lab model and checks a warning has been raised
mc.clear_model_build_lab()

with pytest.raises(Exception) as model_not_built_error:
mc.export_lab_model(file_path)

assert "model has not been built" in str(model_not_built_error)

0 comments on commit dafd646

Please sign in to comment.