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')
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')
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)
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)
def setUp(self): self.problems = Problems() self.tool = Puppet(self.problems)
def test_has_fixer__enabled(self): tool = Puppet(self.problems, {'fixer': True}, root_dir) self.assertEqual(True, tool.has_fixer())
def test_has_fixer__not_enabled(self): tool = Puppet(self.problems, {}, root_dir) self.assertEqual(False, tool.has_fixer())
def setUp(self): self.problems = Problems() self.tool = Puppet(self.problems, {}, root_dir)