|
| 1 | +# pylint: disable=redefined-outer-name |
| 2 | +# pylint: disable=unused-argument |
| 3 | +# pylint: disable=unused-variable |
| 4 | +# pylint: disable=too-many-arguments |
| 5 | + |
| 6 | + |
| 7 | +from pathlib import Path |
| 8 | +from typing import List |
| 9 | + |
| 10 | +import osparc |
| 11 | +import pytest |
| 12 | +from osparc import ( |
| 13 | + CreditsApi, |
| 14 | + FilesApi, |
| 15 | + JobInputs, |
| 16 | + JobOutputs, |
| 17 | + JobStatus, |
| 18 | + Solver, |
| 19 | + SolversApi, |
| 20 | + UsersApi, |
| 21 | + WalletsApi, |
| 22 | +) |
| 23 | + |
| 24 | + |
| 25 | +@pytest.fixture |
| 26 | +def users_api(api_client: osparc.ApiClient) -> UsersApi: |
| 27 | + return UsersApi(api_client) |
| 28 | + |
| 29 | + |
| 30 | +@pytest.fixture |
| 31 | +def wallets_api(api_client: osparc.ApiClient) -> WalletsApi: |
| 32 | + return WalletsApi(api_client) |
| 33 | + |
| 34 | + |
| 35 | +@pytest.fixture |
| 36 | +def credits_api(api_client: osparc.ApiClient) -> CreditsApi: |
| 37 | + return CreditsApi(api_client) |
| 38 | + |
| 39 | + |
| 40 | +@pytest.fixture |
| 41 | +def files_api(api_client: osparc.ApiClient) -> FilesApi: |
| 42 | + return FilesApi(api_client) |
| 43 | + |
| 44 | + |
| 45 | +@pytest.fixture |
| 46 | +def solvers_api(api_client: osparc.ApiClient) -> SolversApi: |
| 47 | + return SolversApi(api_client) |
| 48 | + |
| 49 | + |
| 50 | +def test_initialize_solvers(solvers_api: SolversApi): |
| 51 | + # TODO: search a solver and give me all its releases! |
| 52 | + |
| 53 | + # -> "/{solver_key:path}/releases:search?title='{title}'? or add filter? in list? |
| 54 | + |
| 55 | + include = {"Sim4Life Python Runner 8.0"} # titles!? |
| 56 | + # Why not key and we can add a search by release? |
| 57 | + result = [] |
| 58 | + |
| 59 | + # TODO: expose iter_solvers |
| 60 | + for solver in solvers_api.iter_solvers(): |
| 61 | + if solver.title in include: |
| 62 | + temp_solver = solvers_api.get_solver_release( |
| 63 | + solver_key=solver.id, version=solver.version |
| 64 | + ) |
| 65 | + result[solver.title] = temp_solver |
| 66 | + |
| 67 | + assert result |
| 68 | + |
| 69 | + |
| 70 | +def test_upload(files_api: FilesApi, tmp_path: Path): |
| 71 | + p = (tmp_path / "foo.txt").write_text("hi") |
| 72 | + files_api.upload_file(file=p) |
| 73 | + |
| 74 | + |
| 75 | +# def test_create_run(solvers_api: SolversApi): |
| 76 | + |
| 77 | +# solvers_api.create_job( |
| 78 | +# self.solvers_in_use[SolverTitle.S4LPYRUN.value].version, |
| 79 | +# JobInputs(payloads), |
| 80 | +# ) |
0 commit comments