~cloud-init-dev/cloud-init/trunk

« back to all changes in this revision

Viewing changes to tests/unittests/test_distros/test_sysconfig.py

Enable flake8 and fix a large amount of reported issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import re
2
2
 
3
3
from cloudinit.distros.parsers.sys_conf import SysConf
 
4
 
4
5
from ..helpers import TestCase
5
6
 
6
7
 
27
28
ETHTOOL_OPTS="-K ${DEVICE} tso on; -G ${DEVICE} rx 256 tx 256"
28
29
USEMD5=no'''
29
30
        conf = SysConf(contents.splitlines())
30
 
        self.assertEquals(conf['HOSTNAME'], 'blahblah')
31
 
        self.assertEquals(conf['SHORTDATE'], '$(date +%y:%m:%d:%H:%M)')
 
31
        self.assertEqual(conf['HOSTNAME'], 'blahblah')
 
32
        self.assertEqual(conf['SHORTDATE'], '$(date +%y:%m:%d:%H:%M)')
32
33
        # Should be unquoted
33
 
        self.assertEquals(conf['ETHTOOL_OPTS'], ('-K ${DEVICE} tso on; '
34
 
                                                 '-G ${DEVICE} rx 256 tx 256'))
35
 
        self.assertEquals(contents, str(conf))
 
34
        self.assertEqual(conf['ETHTOOL_OPTS'], ('-K ${DEVICE} tso on; '
 
35
                                                '-G ${DEVICE} rx 256 tx 256'))
 
36
        self.assertEqual(contents, str(conf))
36
37
 
37
38
    def test_parse_shell_vars(self):
38
39
        contents = 'USESMBAUTH=$XYZ'
39
40
        conf = SysConf(contents.splitlines())
40
 
        self.assertEquals(contents, str(conf))
 
41
        self.assertEqual(contents, str(conf))
41
42
        conf = SysConf('')
42
43
        conf['B'] = '${ZZ}d apples'
43
44
        # Should be quoted
44
 
        self.assertEquals('B="${ZZ}d apples"', str(conf))
 
45
        self.assertEqual('B="${ZZ}d apples"', str(conf))
45
46
        conf = SysConf('')
46
47
        conf['B'] = '$? d apples'
47
 
        self.assertEquals('B="$? d apples"', str(conf))
 
48
        self.assertEqual('B="$? d apples"', str(conf))
48
49
        contents = 'IPMI_WATCHDOG_OPTIONS="timeout=60"'
49
50
        conf = SysConf(contents.splitlines())
50
 
        self.assertEquals('IPMI_WATCHDOG_OPTIONS=timeout=60', str(conf))
 
51
        self.assertEqual('IPMI_WATCHDOG_OPTIONS=timeout=60', str(conf))
51
52
 
52
53
    def test_parse_adjust(self):
53
54
        contents = 'IPV6TO4_ROUTING="eth0-:0004::1/64 eth1-:0005::1/64"'
54
55
        conf = SysConf(contents.splitlines())
55
56
        # Should be unquoted
56
 
        self.assertEquals('eth0-:0004::1/64 eth1-:0005::1/64',
57
 
                          conf['IPV6TO4_ROUTING'])
 
57
        self.assertEqual('eth0-:0004::1/64 eth1-:0005::1/64',
 
58
                         conf['IPV6TO4_ROUTING'])
58
59
        conf['IPV6TO4_ROUTING'] = "blah \tblah"
59
60
        contents2 = str(conf).strip()
60
61
        # Should be requoted due to whitespace
65
66
        conf = SysConf(''.splitlines())
66
67
        conf['B'] = ' $(time)'
67
68
        contents = str(conf)
68
 
        self.assertEquals('B= $(time)', contents)
 
69
        self.assertEqual('B= $(time)', contents)
69
70
 
70
71
    def test_parse_empty(self):
71
72
        contents = ''
72
73
        conf = SysConf(contents.splitlines())
73
 
        self.assertEquals('', str(conf).strip())
 
74
        self.assertEqual('', str(conf).strip())
74
75
 
75
76
    def test_parse_add_new(self):
76
77
        contents = 'BLAH=b'