def test_no_changes_exist_with_force(self):
     tool = MockTool()
     tool._scm = Mock()
     tool._scm.has_working_directory_changes = lambda: False
     tool._scm.has_local_commits = lambda: False
     step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=True))
     step.run({})
     self.assertEqual(tool._scm.discard_local_changes.call_count, 1)
 def test_no_changes_exist_with_force(self):
     tool = MockTool()
     tool._scm = Mock()
     tool._scm.has_working_directory_changes = lambda: False
     tool._scm.has_local_commits = lambda: False
     step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=True))
     step.run({})
     self.assertEqual(tool._scm.discard_local_changes.call_count, 1)
 def test_error_local_commits_exist_without_force(self):
     tool = MockTool()
     tool._scm = Mock()
     tool._scm.has_working_directory_changes = lambda: False
     tool._scm.has_local_commits = lambda: True
     step = DiscardLocalChanges(tool, MockOptions(clean=True, force_clean=False))
     self.assertRaises(ScriptError, step.run, {})
     self.assertEqual(tool._scm.discard_local_changes.call_count, 0)
 def test_skip_on_clean(self):
     tool = MockTool()
     tool._scm = Mock()
     step = DiscardLocalChanges(tool, MockOptions(clean=False))
     step.run({})
     self.assertEqual(tool._scm.discard_local_changes.call_count, 0)
 def test_skip_on_clean(self):
     tool = MockTool()
     tool._scm = Mock()
     step = DiscardLocalChanges(tool, MockOptions(clean=False))
     step.run({})
     self.assertEqual(tool._scm.discard_local_changes.call_count, 0)