Ejemplo n.º 1
0
def test_get_all_hostname():
    hnf = HnF(context_wrap(HOSTNAME_FULL))
    hns = HnS(context_wrap(HOSTNAME_SHORT))
    hnd = HnD(context_wrap(HOSTNAME_DEF))
    sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    expected = (HOSTNAME_FULL, HOSTNAME_SHORT, 'example.com')
    result = Hostname(hnf, hnd, hns, sid)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
Ejemplo n.º 2
0
def test_hostname_function():
    # can be removed once the function being removed
    hnf = HnF(context_wrap(HOSTNAME_FULL))
    hns = HnS(context_wrap(HOSTNAME_SHORT))
    hnd = HnD(context_wrap(HOSTNAME_DEF))
    sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    expected = (HOSTNAME_FULL, HOSTNAME_SHORT, 'example.com')
    result = hn_func(hnf, hnd, hns, sid)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
Ejemplo n.º 3
0
def test_hostname_doc():
    hnf = HnF(context_wrap(HOSTNAME_FULL))
    hns = HnS(context_wrap(HOSTNAME_SHORT))
    hnd = HnD(context_wrap(HOSTNAME_DEF))
    sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    env = {
            'hostname': Hostname(hnf, hnd, hns, sid),
            'hn': hn_func(hnf, hnd, hns, sid)
          }
    failed, total = doctest.testmod(hostname, globs=env)
    assert failed == 0
Ejemplo n.º 4
0
def test_get_hostname():
    hnf = HnF(context_wrap(HOSTNAME_FULL))
    expected = (HOSTNAME_FULL, HOSTNAME_SHORT, 'example.com')
    result = Hostname(hnf, None, None, None)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]

    hns = HnS(context_wrap(HOSTNAME_SHORT))
    expected = (HOSTNAME_SHORT, HOSTNAME_SHORT, '')
    result = Hostname(None, None, hns, None)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]

    hnd = HnD(context_wrap(HOSTNAME_DEF))
    expected = (HOSTNAME_DEF, HOSTNAME_DEF, '')
    result = Hostname(None, hnd, None, None)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]