コード例 #1
0
ファイル: test_zerotier.py プロジェクト: 0xDeX/two1-python
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()]