Skip to content

Commit

Permalink
Add tests that ensure parameter & input orders are retained (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
akx authored Oct 1, 2024
1 parent 2916c35 commit d87f9bb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
17 changes: 17 additions & 0 deletions examples/keep-order.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- step:
name: sing a melody
image: python:3.12
command: echo {parameter:do} {parameter:re} {parameter:mi} {parameter:fa} {parameter:so} {parameter:la} {parameter:ti}
parameters:
- name: do
- name: re
- name: mi
- name: fa
- name: so
- name: la
- name: ti
inputs:
- name: drums
- name: bass
- name: guitar
- name: vocals
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
input_extras_config = config_fixture("input-extras.yaml")
timeouts_config = config_fixture("timeouts-example.yaml")
edge_merge_mode_config = config_fixture("edge-merge-mode.yaml")
keep_order_config = config_fixture("keep-order.yaml")
8 changes: 8 additions & 0 deletions tests/test_order_retention.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def test_parameter_order_is_retained(keep_order_config):
step = keep_order_config.steps["sing a melody"]
assert list(step.parameters.keys()) == ["do", "re", "mi", "fa", "so", "la", "ti"]


def test_input_order_is_retained(keep_order_config):
step = keep_order_config.steps["sing a melody"]
assert list(step.inputs.keys()) == ["drums", "bass", "guitar", "vocals"]
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _load_config(filename, roundtrip):


def config_fixture(name):
@pytest.fixture(params=[False, True], ids=["direct", "roundtrip"])
@pytest.fixture(params=[False, True], ids=[f"{name}_direct", f"{name}_roundtrip"])
def _config_fixture(request):
return _load_config(name, roundtrip=request.param)

Expand Down

0 comments on commit d87f9bb

Please sign in to comment.