Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added simple retry to test_get_doc() #200

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion tests/ide/test_get_doc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os.path
import random
import time
import unittest

from idelib.dataset import Dataset
Expand Down Expand Up @@ -80,7 +82,23 @@ def test_get_doc_url(self):

def test_get_doc_gdrive(self):
""" Test getting an IDE from a Google Drive URL. """
doc = files.get_doc(IDE_GDRIVE_URL)
# There are sporadic HTTP failures getting the sample file from
# Google Drive, possibly a result of the GitHub tests suspiciously
# hammering the URL. This is a naive implementation allowing 3
# retries, with a random sleep in between.
retries = 2
doc = None
while retries:
try:
doc = files.get_doc(IDE_GDRIVE_URL)
break
except ValueError as err:
retries -= 1
if "403: Forbidden" not in str(err) or not retries:
raise
else:
time.sleep(random.random() * 3)

self.assertIsInstance(doc, Dataset,
"get_doc() did not return a Dataset")
self.assertEqual(len(self.dataset.ebmldoc), len(doc.ebmldoc),
Expand Down