Skip to content

Commit

Permalink
add unit test and throw exception on timeout
Browse files Browse the repository at this point in the history
Signed-off-by: zliu3 <[email protected]>
  • Loading branch information
zliu3 committed May 22, 2024
1 parent 795c6b1 commit e6478a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions gordian/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def _get_repo_contents(self, path):
logger.info(f'Error fetching repo contents: {e}')
except TimeoutError as e:
logger.info(f'Error fetching repo contents: {e}')
raise e

@retry(GithubException, tries=3, delay=1, backoff=2)
def _make_branch(self):
Expand Down
9 changes: 9 additions & 0 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,12 @@ 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):
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)

0 comments on commit e6478a9

Please sign in to comment.