Ejemplo n.º 1
0
def test_hostnames_to_components_resolve(mock_gethostbyname, ):
    hostname = 'fake-host'
    ip = '127.0.0.1'
    mock_gethostbyname.return_value = ip
    expected = [Hostname(host=hostname, ip=ip)]
    actual = hostnames_to_components([hostname], resolve=True)
    assert actual == expected
Ejemplo n.º 2
0
def test_hostnames_to_components_resolve_failure(
    mock_gethostbyname,
):
    mock_gethostbyname.side_effect = ['10.1.1.1', gaierror]
    expected = [Hostname(host='host1', ip='10.1.1.1')]
    actual = hostnames_to_components(['host1', 'host2'], resolve=True)
    assert actual == expected
Ejemplo n.º 3
0
def test_hostnames_to_components_resolve(
    mock_gethostbyname,
):
    hostname = 'fake-host'
    ip = '127.0.0.1'
    mock_gethostbyname.return_value = ip
    expected = [Hostname(host=hostname, ip=ip)]
    actual = hostnames_to_components([hostname], resolve=True)
    assert actual == expected
Ejemplo n.º 4
0
def test_hostnames_to_components_pipe():
    hostname = 'fake-host'
    ip = '127.0.0.1'
    expected = [Hostname(host=hostname, ip=ip)]
    actual = hostnames_to_components(["%s|%s" % (hostname, ip)])
    assert actual == expected
Ejemplo n.º 5
0
def test_hostnames_to_components_simple():
    hostname = 'fake-host'
    ip = None
    expected = [Hostname(host=hostname, ip=ip)]
    actual = hostnames_to_components([hostname])
    assert actual == expected
Ejemplo n.º 6
0
def test_hostnames_to_components_pipe():
    hostname = 'fake-host'
    ip = '127.0.0.1'
    expected = [Hostname(host=hostname, ip=ip)]
    actual = hostnames_to_components(["%s|%s" % (hostname, ip)])
    assert actual == expected
Ejemplo n.º 7
0
def test_hostnames_to_components_simple():
    hostname = 'fake-host'
    ip = None
    expected = [Hostname(host=hostname, ip=ip)]
    actual = hostnames_to_components([hostname])
    assert actual == expected
Ejemplo n.º 8
0
def test_hostnames_to_components_resolve_failure(mock_gethostbyname, ):
    mock_gethostbyname.side_effect = ["10.1.1.1", gaierror]
    expected = [Hostname(host="host1", ip="10.1.1.1")]
    actual = hostnames_to_components(["host1", "host2"], resolve=True)
    assert actual == expected
Ejemplo n.º 9
0
def test_hostnames_to_components_pipe():
    hostname = "fake-host"
    ip = "127.0.0.1"
    expected = [Hostname(host=hostname, ip=ip)]
    actual = hostnames_to_components([f"{hostname}|{ip}"])
    assert actual == expected