diff --git a/tubular/tests/test_github.py b/tubular/tests/test_github.py index 5f3d1701..b7be4460 100644 --- a/tubular/tests/test_github.py +++ b/tubular/tests/test_github.py @@ -303,21 +303,22 @@ def test_check_combined_status_commit( self.repo_mock.get_commit.assert_called_with(sha) @ddt.data( - ('passed', True), - ('failed', False) + ('pending', 'success', None, 1), # Case where no actions are found + ('passed', 'passed', True, 2), # Case where actions are found and succeed + ('failed', 'failed', False, 2), # Case where actions are found and fail ) @ddt.unpack - def test_poll_commit(self, end_status, successful): + def test_poll_commit(self, initial_status, end_status, successful, expected_call_count): url_dict = {'TravisCI': 'some url'} with patch.object(self.api, '_is_commit_successful', side_effect=[ - (False, url_dict, 'pending'), + (False, url_dict, initial_status) if initial_status == 'pending' else (True, url_dict, initial_status), (successful, url_dict, end_status), ]): result = self.api._poll_commit('some sha') # pylint: disable=protected-access - assert self.api._is_commit_successful.call_count == 2 # pylint: disable=protected-access - assert result[0] == end_status - assert result[1] == url_dict + assert self.api._is_commit_successful.call_count == expected_call_count # pylint: disable=protected-access + assert result[0] == end_status if initial_status != 'pending' else 'success' + assert result[1] == url_dict if initial_status != 'pending' else None @ddt.data( (