def test_get_all_addresses(list_networks_ret_val, outcome): """ Tests zerotier.get_all_addresses function """ with mock.patch("two1.commands.util.zerotier.list_networks") as mock_list_networks: if isinstance(list_networks_ret_val, list): mock_list_networks.return_value = list_networks_ret_val else: mock_list_networks.side_effect = list_networks_ret_val assert zerotier.get_all_addresses() == outcome
def test_get_all_addresses(list_networks_ret_val, outcome): """ Tests zerotier.get_all_addresses function """ with mock.patch( "two1.commands.util.zerotier.list_networks") as mock_list_networks: if isinstance(list_networks_ret_val, list): mock_list_networks.return_value = list_networks_ret_val else: mock_list_networks.side_effect = list_networks_ret_val assert zerotier.get_all_addresses() == outcome
def show_network_status(): """Print network status.""" networks_info = zerotier.get_all_addresses() if len(networks_info) == 0: logger.info(uxstring.UxString.no_network) else: headers = ["Network Name", "Your IP"] rows = [] for name, ip in networks_info.items(): rows.append([name, ip]) logger.info(tabulate(rows, headers, tablefmt="simple"))
def show_network_status(): """Print network status.""" networks_info = zerotier.get_all_addresses() if len(networks_info) == 0: logger.info(uxstring.UxString.no_network) else: headers = ["Network Name", "Your IP"] rows = [] for name, ip in networks_info.items(): rows.append([name, ip]) logger.info(tabulate(rows, headers, tablefmt="simple")) return [{ 'network_name': name, 'ip': ip } for (name, ip) in networks_info.items()]