def test_skip_unmodified_file(self): f = 'main.js' self.git.modified_files = MagicMock(return_value={}) self.git.is_file_in_git = MagicMock(return_value=False) pl = PartialLint(self.git, self.linter) pl._file_exists = MagicMock(return_value=True) out = pl.run([f]) self.assertEqual(len(out), 0) self.linter.run.assert_not_called()
def test_error_on_old_change_in_versioned_file(self): f = 'main.js' errors = [{ 'file': f, 'linenum': 10 }] self.linter.run = MagicMock(return_value=errors) self.git.is_file_in_git = MagicMock(return_value=True) self.git.blame_file = MagicMock(return_value={}) pl = PartialLint(self.git, self.linter) pl._file_exists = MagicMock(return_value=True) out = pl.run([f]) self.assertEqual(len(out), 0)
def test_error_on_unversioned_file(self): f = 'main.js' errors = [{ 'file': f, 'linenum': 10 }] self.linter.run = MagicMock(return_value=errors) self.git.modified_files = MagicMock(return_value={f}) self.git.is_file_in_git = MagicMock(return_value=False) pl = PartialLint(self.git, self.linter) pl._file_exists = MagicMock(return_value=True) out = pl.run([f]) self.assertEqual(len(out), 1)