Ejemplo n.º 1
0
    def test_process_files__with_config(self):
        config = {'config': 'tests/fixtures/puppet/puppetlint.rc'}
        tool = Puppet(self.problems, config)
        tool.process_files([self.fixtures[1]])

        eq_([], self.problems.all(abspath(self.fixtures[1])),
            'Config file should cause no errors on has_errors.pp')
Ejemplo n.º 2
0
    def test_execute_fixer(self):
        tool = Puppet(self.problems, {'fixer': True}, root_dir)

        original = read_file(self.fixtures[1])
        tool.execute_fixer(self.fixtures)

        updated = read_and_restore_file(self.fixtures[1], original)
        assert original != updated, 'File content should change.'
        eq_(0, len(self.problems.all()), 'No errors should be recorded')
Ejemplo n.º 3
0
    def test_execute_fixer__fewer_problems_remain(self):
        tool = Puppet(self.problems, {'fixer': True}, root_dir)

        # The fixture file should have fixable problems fixed
        original = read_file(self.fixtures[1])
        tool.execute_fixer(self.fixtures)
        tool.process_files(self.fixtures)

        read_and_restore_file(self.fixtures[1], original)
        eq_(1, len(self.problems.all()), 'Most errors should be fixed')
        assert_in('autoload module layout', self.problems.all()[0].body)
Ejemplo n.º 4
0
    def test_execute_fixer__fixer_ignore(self):
        puppet_config = {
            'fixer': True,
            'fixer_ignore': 'quoted_booleans, variable_is_lowercase',
        }
        tool = Puppet(self.problems, puppet_config, root_dir)

        original = read_file(self.fixtures[1])
        tool.execute_fixer(self.fixtures)
        tool.process_files(self.fixtures)

        read_and_restore_file(self.fixtures[1], original)
        eq_(2, len(self.problems.all()), 'Most errors should be fixed')

        problems = sorted(self.problems.all(), key=attrgetter('line'))
        assert_in('ERROR:foo not in autoload module layout', problems[0].body)
        assert_in('WARNING:quoted boolean value', problems[1].body)
Ejemplo n.º 5
0
 def setUp(self):
     self.problems = Problems()
     self.tool = Puppet(self.problems)
Ejemplo n.º 6
0
 def test_has_fixer__enabled(self):
     tool = Puppet(self.problems, {'fixer': True}, root_dir)
     self.assertEqual(True, tool.has_fixer())
Ejemplo n.º 7
0
 def test_has_fixer__not_enabled(self):
     tool = Puppet(self.problems, {}, root_dir)
     self.assertEqual(False, tool.has_fixer())
Ejemplo n.º 8
0
 def setUp(self):
     self.problems = Problems()
     self.tool = Puppet(self.problems, {}, root_dir)