-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstractions for reasoning about steps outside of converted code.
- Loading branch information
Showing
3 changed files
with
187 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from gxformat2.model import ( | ||
pop_connect_from_step_dict, | ||
setup_connected_values, | ||
) | ||
|
||
|
||
def test_pop_connect(): | ||
raw_step = { | ||
"in": { | ||
"bar": { | ||
"source": "foo/moo", | ||
}, | ||
}, | ||
} | ||
connect = pop_connect_from_step_dict(raw_step) | ||
assert connect["bar"] == ["foo/moo"] | ||
assert "in" not in raw_step | ||
|
||
|
||
def test_pop_connect_preserves_defaults(): | ||
raw_step = { | ||
"in": { | ||
"bar": { | ||
"default": 7, | ||
}, | ||
}, | ||
} | ||
connect = pop_connect_from_step_dict(raw_step) | ||
assert "bar" not in connect | ||
assert "in" in raw_step | ||
|
||
|
||
def test_setup_connected_values(): | ||
raw_state = { | ||
"input": {"$link": "moo/cow"}, | ||
} | ||
connect = {} | ||
setup_connected_values(raw_state, append_to=connect) | ||
assert connect["input"][0] == "moo/cow" | ||
|
||
|
||
def test_setup_connected_values_in_array(): | ||
raw_state = { | ||
"input": [{"$link": "moo/cow"}, {"$link": "moo/cow2"}], | ||
} | ||
connect = {} | ||
setup_connected_values(raw_state, append_to=connect) | ||
assert connect["input"][0] == "moo/cow" | ||
assert connect["input"][1] == "moo/cow2" |