class BuildNIC(BuildCnfVar):
def __init__(self, data='', instance=0, line_no=1):
- BuildCnfVar.__init__(self, 'NIC', instance, data, line_no)
+ BuildCnfVar.__init__(self, 'NIC', instance, '', line_no)
# the bare defaults the UI adds upon
# creation of new groups
defaults = {
+ 'NIC_COMMENT': data,
'NIC_DRIVER': 'virtio_net',
'NIC_LAN_DNS_RELAYING_ALLOWED': "0",
'NIC_LAN_EMAIL_RELAYING_ALLOWED': "0",
self.add_defaults(defaults)
+ def comment(self, comment):
+ self.update_cnf('NIC_COMMENT', 0, comment)
+ return self
+
def nic_type(self, nic_type):
self.update_cnf('NIC_TYPE', 0, nic_type)
return self
import unittest
from src.cnfline.cnfline import CnfLine
+from src.cnfline.build_nic import BuildNIC
class CnfLineTest(unittest.TestCase):
line = CnfLine('MY_NAME', 123, 'my_data', 10, 456)
self.assertEqual('10 (456) MY_NAME,123: "my_data"', str(line))
+
+class BuildNICTest(unittest.TestCase):
+ def test_nic_comment(self):
+ nic = BuildNIC('my comment', 10, 100)
+
+ cnf_text = str(nic)
+ self.assertTrue('NIC_COMMENT,0: "my comment"' in cnf_text)
+ self.assertEqual('', nic.data)
+
+ def test_change_comment(self):
+ nic = BuildNIC('initial comment', 10, 100)
+ nic.comment('new comment')
+
+ cnf_text = str(nic)
+ self.assertTrue('NIC_COMMENT,0: "new comment"' in cnf_text)
+ self.assertTrue('initial comment"' not in cnf_text)
+ self.assertEqual('', nic.data)
+
+
if __name__ == '__main__':
unittest.main()