-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yee Hing Tong <[email protected]>
- Loading branch information
1 parent
f25cf67
commit 0f3f468
Showing
8 changed files
with
191 additions
and
14 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
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
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,42 @@ | ||
from flyteidl.admin.signal_pb2 import Signal, SignalList | ||
from mock import MagicMock | ||
|
||
from flytekit.configuration import Config | ||
from flytekit.core.context_manager import FlyteContextManager | ||
from flytekit.core.type_engine import TypeEngine | ||
from flytekit.models.core.identifier import SignalIdentifier, WorkflowExecutionIdentifier | ||
from flytekit.remote.remote import FlyteRemote | ||
|
||
|
||
def test_remote_list_signals(): | ||
ctx = FlyteContextManager.current_context() | ||
wfeid = WorkflowExecutionIdentifier("p", "d", "execid") | ||
signal_id = SignalIdentifier(signal_id="sigid", execution_id=wfeid).to_flyte_idl() | ||
lt = TypeEngine.to_literal_type(int) | ||
signal = Signal( | ||
id=signal_id, | ||
type=lt.to_flyte_idl(), | ||
value=TypeEngine.to_literal(ctx, 3, int, lt).to_flyte_idl(), | ||
) | ||
|
||
mock_client = MagicMock() | ||
mock_client.list_signals.return_value = SignalList(signals=[signal], token="") | ||
|
||
remote = FlyteRemote(config=Config.auto(), default_project="p1", default_domain="d1") | ||
remote._client = mock_client | ||
res = remote.list_signals("execid", "p", "d", limit=10) | ||
assert len(res) == 1 | ||
|
||
|
||
def test_remote_set_signal(): | ||
mock_client = MagicMock() | ||
|
||
def checker(request): | ||
assert request.id.signal_id == "sigid" | ||
assert request.value.scalar.primitive.integer == 3 | ||
|
||
mock_client.set_signal.side_effect = checker | ||
|
||
remote = FlyteRemote(config=Config.auto(), default_project="p1", default_domain="d1") | ||
remote._client = mock_client | ||
remote.set_signal("sigid", "execid", 3) |