Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@ class TestFunctions1(CoreTestFunctions):
get_inputs = functions.get_inputs
validate_inputs = functions.validate_inputs
run_model = functions.run_model
# ok_meta_param_dict is optional.
ok_meta_param_dict = {"full_data": False}
ok_adjustment={"matchup": {"pitcher": [{"value": "Max Scherzer"}]}}
bad_adjustment={"matchup": {"pitcher": [{"value": "Not a pitcher"}]}}

```

- If `ok_meta_param_dict` is set, then it will be used in the `run_model` test
along with `ok_adjustment`.

## Run your cs-config tests

```bash
Expand Down
13 changes: 13 additions & 0 deletions cs_kit/tests/test_FunctionsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,16 @@ class TestFunctions(TestFunctions1):
tf = TestFunctions()
with pytest.raises(CSKitError):
tf.test_run_model()


def test_specify_meta_param_dict():
def run_model_test_mp(meta_param_dict, adjustment):
assert meta_param_dict == {"hello_world": [{"value": "hello, there!"}]}
return run_model(meta_param_dict, adjustment)

class TestFunctions(TestFunctions1):
ok_meta_param_dict = {"hello_world": "hello, there!"}
run_model = run_model_test_mp

tf = TestFunctions()
tf.test_run_model()
5 changes: 4 additions & 1 deletion cs_kit/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ def test_run_model(self):
class MetaParams(Parameters):
defaults = inputs["meta_parameters"]

mp_spec = MetaParams().specification(serializable=True)
if getattr(self, "ok_meta_param_dict", None) is not None:
mp_spec = MetaParams().adjust(self.ok_meta_param_dict)
else:
mp_spec = MetaParams().specification(serializable=True)

result = self.run_model(mp_spec, self.ok_adjustment)

Expand Down