Пример #1
0
def test_listings_when_every_option_is_given_and_countries_is_empty(capsys, mocker):
    servers_ = get_servers_stub()

    mocked_servers = mocker.patch("connord.listings.servers")
    mocked_servers.get_servers.return_value = servers_

    listings.list_servers(list(), None, None, None, True, 10, "max", 10)
    captured = capsys.readouterr()

    mocked_servers.get_servers.assert_called_once()
    mocked_servers.to_string.assert_called_once()
    assert captured.out == ""
    assert captured.err == ""
Пример #2
0
def test_listings_when_every_option_is_given_with_categories_features(capsys, mocker):
    servers_ = get_servers_stub()

    mocked_servers = mocker.patch("connord.listings.servers")
    mocked_servers.get_servers.return_value = servers_

    categories_ = ["standard"]
    features_ = ["openvpn_udp"]
    listings.list_servers(list(), None, categories_, features_, True, 10, "max", 10)
    captured = capsys.readouterr()

    mocked_servers.get_servers.assert_called_once()
    mocked_servers.to_string.assert_called_once()
    assert captured.out == ""
    assert captured.err == ""
Пример #3
0
def process_list_cmd(args):
    """
    Process arguments when command is 'list'

    :param args: Command-line arguments
    :returns: True if processing was successful
    """

    if args.list_sub == "iptables":
        process_list_ipt_cmd(args)
    elif args.list_sub == "servers":
        process_list_servers_cmd(args)
    elif args.list_sub == "countries":
        listings.list_countries()
    elif args.list_sub == "areas":
        listings.list_areas()
    elif args.list_sub == "features":
        listings.list_features()
    elif args.list_sub == "categories":
        listings.list_categories()
    else:
        # default: list all servers
        listings.list_servers(None, None, None, None, None, 100, "max", None)
Пример #4
0
def process_list_servers_cmd(args):
    countries_ = args.country
    area_ = args.area
    categories_ = args.category
    features_ = args.feature
    netflix = args.netflix
    top = args.top

    if args.max_load:
        load_ = args.max_load
        match = "max"
    elif args.min_load:
        load_ = args.min_load
        match = "min"
    elif args.load:
        load_ = args.load
        match = "exact"
    else:  # apply defaults
        load_ = 100
        match = "max"

    return listings.list_servers(countries_, area_, categories_, features_,
                                 netflix, load_, match, top)