-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed print_short in add_token.py (#4546)
- Loading branch information
1 parent
dff3627
commit 0a11d61
Showing
2 changed files
with
28 additions
and
2 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,26 @@ | ||
from unittest import mock | ||
from add_token import print_short | ||
|
||
|
||
def test_single(capsys): | ||
with mock.patch( | ||
"add_token.get_network_info", return_value=["10.23.53.54", ["10.23.53.54"], "32"] | ||
): | ||
print_short("t", "c") | ||
captured = capsys.readouterr() | ||
output = captured.out.strip() | ||
assert output == "microk8s join 10.23.53.54:32/t/c" | ||
|
||
|
||
def test_multiple(capsys): | ||
with mock.patch( | ||
"add_token.get_network_info", return_value=["d_ip", ["ip1", "ip2", "d_ip"], "4"] | ||
): | ||
print_short("t", "c") | ||
captured = capsys.readouterr() | ||
all_outputs = captured.out.strip().split("\n") | ||
assert all_outputs == [ | ||
"microk8s join d_ip:4/t/c", | ||
"microk8s join ip1:4/t/c", | ||
"microk8s join ip2:4/t/c", | ||
] |