Skip to content

Commit

Permalink
fix: handle updated edge case in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
UsamaSadiq committed Jul 29, 2024
1 parent edcc78a commit 96eaf9d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tubular/tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
result = self.api._run() # 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(
(
Expand Down

0 comments on commit 96eaf9d

Please sign in to comment.