-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ add test for bunch and generated parameters. #20
- Loading branch information
1 parent
206e804
commit ddc34cc
Showing
3 changed files
with
102 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pytest | ||
|
||
from takler.core import Parameter, parameter, Bunch | ||
|
||
|
||
@pytest.fixture | ||
def simple_bunch_default_port(simple_flow_objects): | ||
flow1 = simple_flow_objects["flow1"] | ||
flow1.add_parameter("ECF_HOME", "/home/johndoe") | ||
flow1.add_parameter("NODES", 4) | ||
flow1.add_parameter("TIME_INTERVAL", 0.1) | ||
|
||
container1 = simple_flow_objects["container1"] | ||
container1.add_parameter("TASKS", 32) | ||
|
||
task1 = simple_flow_objects["task1"] | ||
task1.add_parameter("FLAG", True) | ||
|
||
bunch = Bunch("nwpc_op") | ||
bunch.add_flow(flow1) | ||
|
||
simple_flow_objects["bunch"] = bunch | ||
|
||
return simple_flow_objects | ||
|
||
|
||
def test_bunch_generated_parameter(simple_bunch_default_port): | ||
bunch = simple_bunch_default_port["bunch"] | ||
assert bunch.find_generated_parameter(parameter.TAKLER_HOST) == \ | ||
Parameter(parameter.TAKLER_HOST, "localhost") | ||
assert bunch.find_generated_parameter(parameter.TAKLER_PORT) == \ | ||
Parameter(parameter.TAKLER_PORT, "33083") | ||
assert bunch.find_parent_parameter(parameter.TAKLER_HOME) == \ | ||
Parameter(parameter.TAKLER_HOME, ".") | ||
|
||
assert bunch.find_parent_parameter("NOT_EXIST") is None | ||
|
||
|
||
def test_task_find_bunch_parameter(simple_bunch_default_port): | ||
task1 = simple_bunch_default_port["task1"] | ||
assert task1.find_parent_parameter(parameter.TAKLER_PORT) == Parameter(parameter.TAKLER_PORT, "33083") | ||
assert task1.find_parameter(parameter.TAKLER_PORT) is None | ||
|
||
|
||
def test_container_find_bunch_parameter(simple_bunch_default_port): | ||
container1 = simple_bunch_default_port["container1"] | ||
assert container1.find_parent_parameter(parameter.TAKLER_HOME) == Parameter(parameter.TAKLER_HOME, ".") | ||
assert container1.find_parameter(parameter.TAKLER_HOME) is None | ||
|
||
|
||
def test_flow_find_bunch_parameter(simple_bunch_default_port): | ||
flow1 = simple_bunch_default_port["flow1"] | ||
assert flow1.find_parent_parameter(parameter.TAKLER_HOME) == Parameter(parameter.TAKLER_HOME, ".") | ||
assert flow1.find_parameter(parameter.TAKLER_HOME) is None |
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,33 @@ | ||
import pytest | ||
|
||
from takler.core import Parameter, parameter | ||
|
||
|
||
@pytest.fixture | ||
def simple_flow_objects_with_parameter(simple_flow_objects): | ||
flow1 = simple_flow_objects["flow1"] | ||
flow1.add_parameter("ECF_HOME", "/home/johndoe") | ||
flow1.add_parameter("NODES", 4) | ||
flow1.add_parameter("TIME_INTERVAL", 0.1) | ||
|
||
container1 = simple_flow_objects["container1"] | ||
container1.add_parameter("TASKS", 32) | ||
|
||
task1 = simple_flow_objects["task1"] | ||
task1.add_parameter("FLAG", True) | ||
|
||
task1.init(task_id="1001") | ||
|
||
return simple_flow_objects | ||
|
||
|
||
def test_update_generated_parameter(simple_flow_objects_with_parameter): | ||
task1 = simple_flow_objects_with_parameter["task1"] | ||
task1.update_generated_parameters() | ||
|
||
assert task1.find_generated_parameter(parameter.TASK) == \ | ||
Parameter(parameter.TASK, "task1") | ||
assert task1.find_generated_parameter(parameter.TAKLER_NAME) == \ | ||
Parameter(parameter.TAKLER_NAME, "/flow1/container1/task1") | ||
assert task1.find_generated_parameter(parameter.TAKLER_RID) == \ | ||
Parameter(parameter.TAKLER_RID, "1001") |