From 689aa54d50b2f90af46675f515b1f8b4393b0703 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Tue, 29 Mar 2022 09:49:29 -0400 Subject: [PATCH] Modified tests to work with the bug fix --- tests/test_git_service.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/test_git_service.py b/tests/test_git_service.py index bb029ad7..9ea692c3 100644 --- a/tests/test_git_service.py +++ b/tests/test_git_service.py @@ -11,9 +11,10 @@ class TestGitService(BaseTest): @staticmethod def setup_mock_repo(mock_repo): mock_repo.return_value.untracked_files = ['a_file.txt', 'b_file.txt'] - diff_1 = Mock(a_path='c_file.txt') - diff_2 = Mock(a_path='d_file.txt') - mock_repo.return_value.index.diff = Mock(return_value=[diff_1, diff_2]) + diff_1 = Mock(a_path='c_file.txt', change_type='M') + diff_2 = Mock(a_path='d_file.txt', change_type='M') + diff_3 = Mock(a_path='e_file.txt', change_type='D') + mock_repo.return_value.index.diff = Mock(return_value=[diff_1, diff_2, diff_3]) mock_repo.return_value.active_branch.name = 'my_active_branch' mock_repo.return_value.working_dir = 'working_dir_path' @@ -26,7 +27,8 @@ class TestGitService(BaseTest): self.setup_mock_repo(mock_repo) repo = GitService().get_repo() - self.assertEqual(repo.changes, ['c_file.txt', 'd_file.txt']) + self.assertEqual(repo.modified, ['c_file.txt', 'd_file.txt']) + self.assertEqual(repo.deleted, ['e_file.txt']) self.assertEqual(repo.untracked, ['a_file.txt', 'b_file.txt']) self.assertEqual(repo.branch, 'my_active_branch') self.assertEqual(repo.directory, 'working_dir_path') @@ -46,6 +48,7 @@ class TestGitService(BaseTest): self.assertEqual(repo.untracked_files, ['a_file.txt', 'b_file.txt']) self.assertEqual(repo.index.diff(None)[0].a_path, 'c_file.txt') self.assertEqual(repo.index.diff(None)[1].a_path, 'd_file.txt') + self.assertEqual(repo.index.diff(None)[2].a_path, 'e_file.txt') self.assertTrue(repo.display_push) self.assertFalse(repo.display_merge) @@ -60,6 +63,7 @@ class TestGitService(BaseTest): self.assertIn(call.git.checkout('my_testing_branch'), method_calls) self.assertIn(call.index.add(['a_file.txt', 'b_file.txt']), method_calls) self.assertIn(call.index.add(['c_file.txt', 'd_file.txt']), method_calls) + self.assertIn(call.index.delete(['e_file.txt']), method_calls) self.assertIn(call.index.commit('This is my comment'), method_calls) self.assertIn(call.remotes.origin.push(), method_calls) @@ -72,7 +76,7 @@ class TestGitService(BaseTest): repo = GitService().push_to_remote() method_calls = repo.method_calls - self.assertIn('Git commit:', method_calls[5].args[0]) + self.assertIn('Git commit:', method_calls[7].args[0]) @patch('crc.services.git_service.Repo') def test_push_empty_comment(self, mock_repo): @@ -83,7 +87,7 @@ class TestGitService(BaseTest): repo = GitService().push_to_remote(comment=' ') method_calls = repo.method_calls - self.assertIn('Git commit:', method_calls[5].args[0]) + self.assertIn('Git commit:', method_calls[7].args[0]) def test_get_remote_url(self): app.config['GIT_REMOTE_SERVER'] = 'test_server.com'