示例#1
0
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
示例#2
0
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
示例#3
0
文件: join.py 项目: shayanb/two1
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"))
示例#4
0
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()]