-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tested with unittest (test_addtoken.py) tested with unittest (test_addtoken.py) changed and tested add_token.py #4526 changed and tested add_token.py checked test_multiple for all outputs changed assertion in test_multiple() checked lint and cla checking for lint and cla checking for cla checking for cla checking for cla checking final checking final final push
- Loading branch information
1 parent
a2acc08
commit d13ec4b
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", | ||
] |