Skip to content

Commit

Permalink
add test to make sure retry on exception, add a good case
Browse files Browse the repository at this point in the history
Signed-off-by: zliu3 <[email protected]>
  • Loading branch information
zliu3 committed May 23, 2024
1 parent 8a9cb92 commit af4e3a3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,22 @@ def test__get_github_client(self):
self.assertIsNotNone(repo.get_github_client())
self.assertEqual(repo.get_github_client(), self.mock_git)

def test_get_repo_contents(self):
def test_get_repo_contents_timeout_error(self):
self.repo._set_target_branch('target')
self.repo.files = []
self.repo._source_repo = MagicMock()
self.repo._source_repo.get_contents.side_effect = TimeoutError('Read Timeout')
with pytest.raises(Exception) as context:
self.repo._get_repo_contents(path='test/afile.txt')
assert "Read Timeout" in str(context.value)
self.repo._source_repo.get_contents.assert_has_calls([call('test/afile.txt', 'target'), call('test/afile.txt', 'target'), call('test/afile.txt', 'target')])


def test_get_repo_contents(self):
self.repo._set_target_branch('target')
self.repo.files = []
self.repo._source_repo = MagicMock()
repository_file = MagicMock(path='test/afile.txt', type='not_dir')
self.repo._source_repo.get_contents.side_effect = [repository_file]
self.repo._get_repo_contents(path='test/afile.txt')
self.repo._source_repo.get_contents.assert_has_calls([call('test/afile.txt', 'target')])

0 comments on commit af4e3a3

Please sign in to comment.