Skip to content

Commit

Permalink
feat(biosimulations): update tests to correctly refer to test file
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayankur31 committed Apr 23, 2024
1 parent 811f0e9 commit c796130
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
6 changes: 4 additions & 2 deletions pyneuroml/biosimulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,17 @@ 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[
str,
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}")
Expand Down
15 changes: 6 additions & 9 deletions tests/test_biosimulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import logging
import os
import pathlib

from pyneuroml.biosimulations import (
get_simulator_versions,
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit c796130

Please sign in to comment.