1
from mocker import MockerTestCase
3
from cloudinit.distros.parsers import hostname
7
# My super-duper-hostname
12
BASE_HOSTNAME = BASE_HOSTNAME.strip()
15
class TestHostnameHelper(MockerTestCase):
16
def test_parse_same(self):
17
hn = hostname.HostnameConf(BASE_HOSTNAME)
18
self.assertEquals(str(hn).strip(), BASE_HOSTNAME)
19
self.assertEquals(hn.hostname, 'blahblah')
21
def test_no_adjust_hostname(self):
22
hn = hostname.HostnameConf(BASE_HOSTNAME)
23
prev_name = hn.hostname
25
self.assertEquals(hn.hostname, prev_name)
27
def test_adjust_hostname(self):
28
hn = hostname.HostnameConf(BASE_HOSTNAME)
29
prev_name = hn.hostname
30
self.assertEquals(prev_name, 'blahblah')
31
hn.set_hostname("bbbbd")
32
self.assertEquals(hn.hostname, 'bbbbd')
34
# My super-duper-hostname
38
self.assertEquals(str(hn).strip(), expected_out.strip())