def test_get_systemid_hostname(): sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME)) expected = ('example_profile', 'example_profile', '') result = Hostname(None, None, None, sid) assert result.fqdn == expected[0] assert result.hostname == expected[1] assert result.domain == expected[2]
def test_get_systemid_hostname(): hn = SystemID(context_wrap(SYSTEMID_PROFILE_NAME)) expected = ('usorla7hr0107x', 'usorla7hr0107x', '') result = hostname(None, None, hn) assert result.fqdn == expected[0] assert result.hostname == expected[1] assert result.domain == expected[2]
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]
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]
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]
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
def test_hostname_raise(): with pytest.raises(Exception): sid = SystemID(context_wrap(SYSTEMID_NO_PROFILE_NAME)) Hostname(None, None, None, None, sid)
def test_systemid(): info = SystemID(context_wrap(SYSTEMID, path='etc/sysconfig/rhn/systemid')) assert info.get("username") == 'testuser' assert info.get("operating_system") == 'redhat-release-workstation' assert info.get("description") == 'Initial Registration Parameters: OS: redhat-release-workstation Release: 6Workstation CPU Arch: x86_64' assert info.get("checksum") == 'b493da72be7cfb7e54c1d58c6aa140c9' assert info.get("profile_name") == 'example_profile' assert info.get("system_id") == 'ID-example' assert info.get("architecture") == 'x86_64' assert info.get("os_release") == '6Workstation' assert info.get("type") == 'REAL' assert info.file_name == 'systemid' assert info.file_path == 'etc/sysconfig/rhn/systemid'