Modified tests to work with the bug fix
This commit is contained in:
parent
ae66934bf9
commit
689aa54d50
|
@ -11,9 +11,10 @@ class TestGitService(BaseTest):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setup_mock_repo(mock_repo):
|
def setup_mock_repo(mock_repo):
|
||||||
mock_repo.return_value.untracked_files = ['a_file.txt', 'b_file.txt']
|
mock_repo.return_value.untracked_files = ['a_file.txt', 'b_file.txt']
|
||||||
diff_1 = Mock(a_path='c_file.txt')
|
diff_1 = Mock(a_path='c_file.txt', change_type='M')
|
||||||
diff_2 = Mock(a_path='d_file.txt')
|
diff_2 = Mock(a_path='d_file.txt', change_type='M')
|
||||||
mock_repo.return_value.index.diff = Mock(return_value=[diff_1, diff_2])
|
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.active_branch.name = 'my_active_branch'
|
||||||
mock_repo.return_value.working_dir = 'working_dir_path'
|
mock_repo.return_value.working_dir = 'working_dir_path'
|
||||||
|
|
||||||
|
@ -26,7 +27,8 @@ class TestGitService(BaseTest):
|
||||||
self.setup_mock_repo(mock_repo)
|
self.setup_mock_repo(mock_repo)
|
||||||
repo = GitService().get_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.untracked, ['a_file.txt', 'b_file.txt'])
|
||||||
self.assertEqual(repo.branch, 'my_active_branch')
|
self.assertEqual(repo.branch, 'my_active_branch')
|
||||||
self.assertEqual(repo.directory, 'working_dir_path')
|
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.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)[0].a_path, 'c_file.txt')
|
||||||
self.assertEqual(repo.index.diff(None)[1].a_path, 'd_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.assertTrue(repo.display_push)
|
||||||
self.assertFalse(repo.display_merge)
|
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.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(['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.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.index.commit('This is my comment'), method_calls)
|
||||||
self.assertIn(call.remotes.origin.push(), method_calls)
|
self.assertIn(call.remotes.origin.push(), method_calls)
|
||||||
|
|
||||||
|
@ -72,7 +76,7 @@ class TestGitService(BaseTest):
|
||||||
|
|
||||||
repo = GitService().push_to_remote()
|
repo = GitService().push_to_remote()
|
||||||
method_calls = repo.method_calls
|
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')
|
@patch('crc.services.git_service.Repo')
|
||||||
def test_push_empty_comment(self, mock_repo):
|
def test_push_empty_comment(self, mock_repo):
|
||||||
|
@ -83,7 +87,7 @@ class TestGitService(BaseTest):
|
||||||
|
|
||||||
repo = GitService().push_to_remote(comment=' ')
|
repo = GitService().push_to_remote(comment=' ')
|
||||||
method_calls = repo.method_calls
|
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):
|
def test_get_remote_url(self):
|
||||||
app.config['GIT_REMOTE_SERVER'] = 'test_server.com'
|
app.config['GIT_REMOTE_SERVER'] = 'test_server.com'
|
||||||
|
|
Loading…
Reference in New Issue