Skip to content

Commit

Permalink
Check if kwargs will satisfy pyciemss func
Browse files Browse the repository at this point in the history
  • Loading branch information
fivegrant committed Aug 11, 2023
1 parent 098411e commit 6590195
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
import json
import os
from inspect import signature

from mock import patch
import pytest

from pyciemss.PetriNetODE.interfaces import ( # noqa: F401
load_and_calibrate_and_sample_petri_model,
load_and_sample_petri_model,
)

from pyciemss.Ensemble.interfaces import ( # noqa: F401
load_and_sample_petri_ensemble,
load_and_calibrate_and_sample_ensemble_model,
)

from service.models import Simulate, Calibrate, EnsembleSimulate, EnsembleCalibrate
from service.settings import settings

TDS_URL = settings.TDS_URL


def is_satisfactory(kwargs, f):
parameters = signature(f).parameters
for key, value in kwargs.items():
if key in parameters:
# TODO: Check types as well
# param = parameters[key]
# if param.annotation != Signature.empty and not isinstance(
# value, param.annotation
# ):
# return False
continue
return False
return True


@pytest.fixture
def operation_context(request):
ctx = {}
Expand Down Expand Up @@ -49,6 +75,7 @@ def test_example_conversion(self, operation_context, requests_mock):
kwargs = operation_request.gen_pyciemss_args(job_id)

assert kwargs.get("visual_options", False)
assert is_satisfactory(kwargs, load_and_sample_petri_model)


class TestCalibrate:
Expand Down Expand Up @@ -76,6 +103,7 @@ def test_example_conversion(self, operation_context, requests_mock):
kwargs = operation_request.gen_pyciemss_args(job_id)

assert kwargs.get("visual_options", False)
assert is_satisfactory(kwargs, load_and_calibrate_and_sample_petri_model)


class TestEnsembleSimulate:
Expand All @@ -96,6 +124,7 @@ def test_example_conversion(self, operation_context, requests_mock):
kwargs = operation_request.gen_pyciemss_args(job_id)

assert kwargs.get("visual_options", False)
assert is_satisfactory(kwargs, load_and_sample_petri_ensemble)


class TestEnsembleCalibrate:
Expand Down Expand Up @@ -126,3 +155,4 @@ def test_example_conversion(self, operation_context, requests_mock):
kwargs = operation_request.gen_pyciemss_args(job_id)

assert kwargs.get("visual_options", False)
assert is_satisfactory(kwargs, load_and_calibrate_and_sample_ensemble_model)

0 comments on commit 6590195

Please sign in to comment.