Skip to content

Commit

Permalink
changed print_short in add_token.py
Browse files Browse the repository at this point in the history
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
ShrishtiKarkera committed Jun 26, 2024
1 parent a2acc08 commit d13ec4b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/wrappers/add_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def print_yaml(token, check):

def print_short(token, check):
default_ip, all_ips, port = get_network_info()

print(f"microk8s join {default_ip}:{port}/{token}/{check}")
for ip in all_ips:
print(f"microk8s join {ip}:{port}/{token}/{check}")
if ip != default_ip:
print(f"microk8s join {ip}:{port}/{token}/{check}")


if __name__ == "__main__":
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/test_addtoken.py
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",
]

0 comments on commit d13ec4b

Please sign in to comment.