From c79613069139cf80604b3c99515c79bbfc3b42b5 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Tue, 23 Apr 2024 12:01:17 +0100 Subject: [PATCH] feat(biosimulations): update tests to correctly refer to test file --- pyneuroml/biosimulations.py | 6 ++++-- tests/test_biosimulations.py | 15 ++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pyneuroml/biosimulations.py b/pyneuroml/biosimulations.py index 18aa74a1..ce9bad50 100644 --- a/pyneuroml/biosimulations.py +++ b/pyneuroml/biosimulations.py @@ -203,7 +203,9 @@ def submit_simulation_archive( logger.debug(f"Sim dict is: {sim_dict}") simulation_run_request = _SimulationRunApiRequest(**sim_dict) - logger.debug(f"simulation_run_request is {simulation_run_request.json()}") + logger.debug( + f"simulation_run_request is {simulation_run_request.model_dump_json()}" + ) with open(archive_file, "rb") as archive_file_handle: multipart_form_data: dict[ @@ -211,7 +213,7 @@ def submit_simulation_archive( typing.Union[typing.Tuple[str, typing.BinaryIO], typing.Tuple[None, str]], ] = { "file": (archive_file, archive_file_handle), - "simulationRun": (None, simulation_run_request.json()), + "simulationRun": (None, simulation_run_request.model_dump_json()), } logger.debug(f"data is:\n{multipart_form_data}") diff --git a/tests/test_biosimulations.py b/tests/test_biosimulations.py index ac404d5e..8443afc1 100644 --- a/tests/test_biosimulations.py +++ b/tests/test_biosimulations.py @@ -10,6 +10,7 @@ import logging import os +import pathlib from pyneuroml.biosimulations import ( get_simulator_versions, @@ -46,21 +47,16 @@ def test_get_simulator_versions(self): versions = simulators[s] self.assertGreater(len(versions), 0) - def test_submit_simulation(self): - """Test submit_simulation""" - os.chdir("examples") - response = submit_simulation( - "LEMS_NML2_Ex5_DetCell.xml", sim_dict={}, dry_run=True - ) - self.assertTrue(response) - def test_submit_simulation_archive(self): """Test submit_simulation_archive""" # TODO: we don't want to use the prod instance for testing, so currently # disabled. We'll point it at a dev instance for testingo # Manually set to False to test. dry_run = True - os.chdir("examples") + thispath = pathlib.Path(__file__) + dirname = str(thispath.parent.parent) + cwd = os.getcwd() + os.chdir(dirname + "/examples") sim_dict = { "name": "PyNeuroML test simulation", "simulator": "neuron", @@ -71,6 +67,7 @@ def test_submit_simulation_archive(self): response = submit_simulation( "LEMS_NML2_Ex5_DetCell.xml", sim_dict=sim_dict, dry_run=dry_run ) + os.chdir(cwd) if dry_run: pass