Skip to content

Commit

Permalink
python tests are working
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleisch committed Dec 21, 2024
1 parent b3211a6 commit d718b2e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 32 deletions.
6 changes: 2 additions & 4 deletions .updater/clientTests/PythonTests/test/test_compounds_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import PySirius
from PySirius import PySiriusAPI, SiriusSDK, PagedModelCompound
from PySirius.models.compound import Compound
from PySirius.models.trace_set import TraceSet
from PySirius.models.page_compound import PageCompound
from PySirius.models.compound_import import CompoundImport


Expand All @@ -32,7 +30,7 @@ def setUp(self) -> None:
self.api = SiriusSDK().attach_or_start_sirius()
self.project_id = "test_compounds_api"
self.path_to_project = f"{os.environ.get('HOME')}/test_compounds_api.sirius"
self.api.projects().create_project_space(self.project_id, self.path_to_project)
self.api.projects().create_project(self.project_id, self.path_to_project)

# equals test_add_compounds
simple_peak_json = {
Expand Down Expand Up @@ -69,7 +67,7 @@ def setUp(self) -> None:
self.api.compounds().add_compounds(self.project_id, compound_import)

def tearDown(self) -> None:
self.api.projects().close_project_space(self.project_id)
self.api.projects().close_project(self.project_id)
os.remove(self.path_to_project)

def test_add_compounds(self) -> None:
Expand Down
10 changes: 5 additions & 5 deletions .updater/clientTests/PythonTests/test/test_features_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ def setUp(self) -> None:
self.project_id = "test_features_api"
self.path_to_project = f"{os.environ.get('HOME')}/tomato_small.sirius"
# check if test project already open -> allows to run tests in independent calls.
if self.api.projects().get_project_space_without_preload_content(self.project_id).status == 404:
self.api.projects().open_project_space(self.project_id, self.path_to_project)
if self.api.projects().get_project_without_preload_content(self.project_id).status == 404:
self.api.projects().open_project(self.project_id, self.path_to_project)
# the single one ID with MSNovelist results computed
self.aligned_feature_id = "586487307819356741"

self.formula_candidates = self.api.features().get_formula_candidates(self.project_id, self.aligned_feature_id)
self.formula_id = self.formula_candidates[0].formula_id

def tearDown(self) -> None:
self.api.projects().close_project_space(self.project_id)
self.api.projects().close_project(self.project_id)

def test_add_aligned_features(self) -> None:
"""Test case for add_aligned_features
Expand Down Expand Up @@ -94,7 +94,7 @@ def test_delete_aligned_feature(self) -> None:
Delete feature (aligned over runs) with the given identifier from the specified project-space.
"""
project_info = self.api.projects().create_project_space(project_id="delete-project")
project_info = self.api.projects().create_project(project_id="delete-project")
project_id = project_info.project_id
try:
path_to_demo_data = f"{os.environ.get('HOME')}/sirius-client-openAPI/.updater/clientTests/Data"
Expand All @@ -117,7 +117,7 @@ def test_delete_aligned_feature(self) -> None:

self.assertEqual(len(response_before) - len(response_after), 2)
finally:
self.api.projects().close_project_space(project_id)
self.api.projects().close_project(project_id)
os.remove(project_info.location)

def test_get_aligned_feature(self) -> None:
Expand Down
6 changes: 3 additions & 3 deletions .updater/clientTests/PythonTests/test/test_jobs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def setUp(self) -> None:
self.api = SiriusSDK().attach_or_start_sirius()
self.project_id = "test_jobs_api"
self.path_to_project = f"{os.environ.get('HOME')}/test_jobs_api.sirius"
if self.api.projects().get_project_space_without_preload_content(self.project_id).status == 404:
if self.api.projects().get_project_without_preload_content(self.project_id).status == 404:
if os.path.exists(self.path_to_project):
os.remove(self.path_to_project)
self.api.projects().create_project_space(self.project_id, self.path_to_project)
self.api.projects().create_project(self.project_id, self.path_to_project)

path_to_demo_data = f"{os.environ.get('HOME')}/sirius-client-openAPI/.updater/clientTests/Data"
preproc_ms2_file_1 = path_to_demo_data + "/Kaempferol.ms"
Expand All @@ -43,7 +43,7 @@ def setUp(self) -> None:
self.api.projects().import_preprocessed_data_as_job(self.project_id, input_files=input_files)

def tearDown(self) -> None:
self.api.projects().close_project_space(self.project_id)
self.api.projects().close_project(self.project_id)
os.remove(self.path_to_project)

def test_delete_job(self) -> None:
Expand Down
38 changes: 19 additions & 19 deletions .updater/clientTests/PythonTests/test/test_projects_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,29 @@ def setUp(self) -> None:
self.preproc_ms2_file_2 = path_to_demo_data + "/laudanosine.mgf"
self.full_ms_file = path_to_demo_data + "/SPF4_Eso3_GH6_01_22643.mzXML"

# equals test_create_project_space
# equals test_create_project
self.project_id = "test_projects_api"
self.path_to_project = f"{os.environ.get('HOME')}/test_projects_api.sirius"

if self.api.projects().get_project_space_without_preload_content(self.project_id).status == 404:
if self.api.projects().get_project_without_preload_content(self.project_id).status == 404:
if os.path.exists(self.path_to_project):
os.remove(self.path_to_project)
self.create_response = self.projects.create_project_space(self.project_id, self.path_to_project)
self.create_response = self.projects.create_project(self.project_id, self.path_to_project)

def tearDown(self) -> None:
# equals test_close_project_space
self.projects.close_project_space(self.project_id)
# equals test_close_project
self.projects.close_project(self.project_id)
os.remove(self.path_to_project)

def test_close_project_space(self) -> None:
"""Test case for close_project_space
def test_close_project(self) -> None:
"""Test case for close_project
Close project-space and remove it from application
"""
pass

def test_create_project_space(self) -> None:
"""Test case for create_project_space
def test_create_project(self) -> None:
"""Test case for create_project
Create and open a new project-space at given location and make it accessible via the given projectId.
"""
Expand Down Expand Up @@ -84,20 +84,20 @@ def test_get_finger_id_data(self) -> None:
response = self.projects.get_finger_id_data(self.project_id, 0)
self.assertIsInstance(response, str)

def test_get_project_space(self) -> None:
"""Test case for get_project_space
def test_get_project(self) -> None:
"""Test case for get_project
Get project space info by its projectId.
"""
response = self.projects.get_project_space(self.project_id)
response = self.projects.get_project(self.project_id)
self.assertIsInstance(response, ProjectInfo)

def test_get_project_spaces(self) -> None:
"""Test case for get_project_spaces
def test_get_projects(self) -> None:
"""Test case for get_projects
List opened project spaces.
"""
response = self.projects.get_project_spaces()
response = self.projects.get_projects()
self.assertIsInstance(response, list)
self.assertIsInstance(response[0], ProjectInfo)

Expand Down Expand Up @@ -139,13 +139,13 @@ def test_import_preprocessed_data_as_job(self) -> None:
response = self.projects.import_preprocessed_data_as_job(self.project_id, input_files=input_files)
self.assertIsInstance(response, Job)

def test_open_project_space(self) -> None:
"""Test case for open_project_space
def test_open_project(self) -> None:
"""Test case for open_project
Open an existing project-space and make it accessible via the given projectId.
"""
response = self.projects.open_project_space("tomato", f"{os.environ.get('HOME')}/tomato_small.sirius")
self.projects.close_project_space("tomato")
response = self.projects.open_project("tomato", f"{os.environ.get('HOME')}/tomato_small.sirius")
self.projects.close_project("tomato")
self.assertIsInstance(response, ProjectInfo)

if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_import_into_database(self) -> None:
Start import of structure and spectra files into the specified database.
"""
response = self.dbs.import_into_database_e(self.database_id, input_files=[self.test_file])
response = self.dbs.import_into_database(self.database_id, input_files=[self.test_file])
self.assertIsInstance(response, SearchableDatabase)

def test_remove_database(self) -> None:
Expand Down

0 comments on commit d718b2e

Please sign in to comment.