Exemplo n.º 1
0
def test_facter():
    fc = Facter(context_wrap(FACTS))
    assert fc.uptime_days == "42"
    assert fc.fqdn == 'plin-w1rhns01.example.com'
    assert fc.uuid == '4230648E-9C94-235F-1074-907C43387172'
    assert hasattr(fc, 'no_test') is False
    assert hasattr(fc, 'swapfree') is True
    assert fc.get('uptime') == "42 days"
    assert fc.get('dummy') is None
Exemplo n.º 2
0
def test_get_facter_hostname():
    hn = Facter(context_wrap(FACTS_FQDN))
    expected = ('ewa-satellite.example.com', 'ewa-satellite', 'example.com')
    result = hostname(None, hn, None)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
Exemplo n.º 3
0
def test_get_facter_uptime():
    ft = Facter(context_wrap(UPTIME3))
    upt = uptime(None, ft)
    assert upt.updays == "21"
    assert upt.uphhmm == '21:59'
    assert upt.loadavg is None
    c = datetime.timedelta(days=0, hours=0, minutes=0, seconds=1893598)
    assert total_seconds(upt.uptime) == total_seconds(c)
Exemplo n.º 4
0
def test_get_all_hostname():
    hn = Hostname(context_wrap(HOSTNAME))
    fhn = Facter(context_wrap(FACTS_FQDN))
    shn = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    expected = (HOSTNAME, HOSTNAME_SHORT, 'example.com')
    result = hostname(hn, fhn, shn)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
Exemplo n.º 5
0
def test_get_both_uptime():
    ut = Uptime(context_wrap(UPTIME2))
    ft = Facter(context_wrap(UPTIME3))
    upt = uptime(ut, ft)
    assert upt.currtime == '10:55:22'
    assert upt.updays == '40'
    assert upt.uphhmm == '00:03'
    assert upt.users == '1'
    assert upt.loadavg == ['0.49', '0.12', '0.04']
    c = datetime.timedelta(days=40, hours=0, minutes=3)
    assert total_seconds(upt.uptime) == total_seconds(c)
Exemplo n.º 6
0
def test_get_all_hostname():
    hnf = HnF(context_wrap(HOSTNAME_FULL))
    hns = HnS(context_wrap(HOSTNAME_SHORT))
    hnd = HnD(context_wrap(HOSTNAME_DEF))
    ft = Facter(context_wrap(FACTS_FQDN))
    sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    expected = (HOSTNAME_FULL, HOSTNAME_SHORT, 'example.com')
    result = Hostname(hnf, hnd, hns, ft, sid)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
Exemplo n.º 7
0
def test_hostname_doc():
    hnf = HnF(context_wrap(HOSTNAME_FULL))
    hns = HnS(context_wrap(HOSTNAME_SHORT))
    hnd = HnD(context_wrap(HOSTNAME_DEF))
    ft = Facter(context_wrap(FACTS_FQDN))
    sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    env = {
            'hostname': Hostname(hnf, hnd, hns, ft, sid),
            'hn': hn_func(hnf, hnd, hns, ft, sid)
          }
    failed, total = doctest.testmod(hostname, globs=env)
    assert failed == 0
Exemplo n.º 8
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))
    ft = Facter(context_wrap(FACTS_FQDN))
    sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    expected = (HOSTNAME_FULL, HOSTNAME_SHORT, 'example.com')
    result = hn_func(hnf, hnd, hns, ft, sid)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]