Skip to content

Commit

Permalink
Merge pull request #1034 from MridulS/hydroshare_break
Browse files Browse the repository at this point in the history
  • Loading branch information
betatim authored Apr 20, 2021
2 parents 0eb7260 + a833c39 commit 73ab48a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ jobs:
pip freeze
# hg-evolve pinned to 9.2 because hg-evolve dropped support for
# hg 4.5, installed with apt in Ubuntu 18.04
$(hg debuginstall --template "{pythonexe}") -m pip install setuptools --user
$(hg debuginstall --template "{pythonexe}") -m pip install hg-evolve==9.2 --user
- name: "Run tests"
Expand Down
8 changes: 4 additions & 4 deletions repo2docker/contentproviders/hydroshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def fetch(self, spec, output_dir, yield_output=False, timeout=120):
conn = self.urlopen(bag_url)
total_wait_time = 0
while (
conn.getcode() == 200
and conn.info().get_content_type() != "application/zip"
conn.status_code == 200
and conn.headers["content-type"] != "application/zip"
):
wait_time = 10
total_wait_time += wait_time
Expand All @@ -81,8 +81,8 @@ def fetch(self, spec, output_dir, yield_output=False, timeout=120):
)
time.sleep(wait_time)
conn = self.urlopen(bag_url)
if conn.getcode() != 200:
msg = "Failed to download bag. status code {}.\n".format(conn.getcode())
if conn.status_code != 200:
msg = "Failed to download bag. status code {}.\n".format(conn.status_code)
yield msg
raise ContentProviderException(msg)
# Bag creation seems to need a small time buffer after it says it's ready.
Expand Down
18 changes: 2 additions & 16 deletions tests/unit/contentproviders/test_hydroshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,11 @@ def hydroshare_archive(prefix="b8f6eae9d89241cf8b5904033460af61/data/contents"):
yield zfile


class MockInfo:
def __init__(self, content_type):
self.content_type = content_type

def get_content_type(self):
return self.content_type


class MockResponse:
def __init__(self, content_type, status_code):
self.content_type = content_type
self.status_code = status_code
self.mock_info = MockInfo(self.content_type)

def getcode(self):
return self.status_code

def info(self):
return self.mock_info
self.headers = dict()
self.headers["content-type"] = content_type


def test_fetch_bag():
Expand Down

0 comments on commit 73ab48a

Please sign in to comment.