Skip to content

Commit 73ab48a

Browse files
authored
Merge pull request #1034 from MridulS/hydroshare_break
2 parents 0eb7260 + a833c39 commit 73ab48a

File tree

3 files changed

+7
-20
lines changed

3 files changed

+7
-20
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ jobs:
110110
pip freeze
111111
# hg-evolve pinned to 9.2 because hg-evolve dropped support for
112112
# hg 4.5, installed with apt in Ubuntu 18.04
113+
$(hg debuginstall --template "{pythonexe}") -m pip install setuptools --user
113114
$(hg debuginstall --template "{pythonexe}") -m pip install hg-evolve==9.2 --user
114115
115116
- name: "Run tests"

repo2docker/contentproviders/hydroshare.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def fetch(self, spec, output_dir, yield_output=False, timeout=120):
6767
conn = self.urlopen(bag_url)
6868
total_wait_time = 0
6969
while (
70-
conn.getcode() == 200
71-
and conn.info().get_content_type() != "application/zip"
70+
conn.status_code == 200
71+
and conn.headers["content-type"] != "application/zip"
7272
):
7373
wait_time = 10
7474
total_wait_time += wait_time
@@ -81,8 +81,8 @@ def fetch(self, spec, output_dir, yield_output=False, timeout=120):
8181
)
8282
time.sleep(wait_time)
8383
conn = self.urlopen(bag_url)
84-
if conn.getcode() != 200:
85-
msg = "Failed to download bag. status code {}.\n".format(conn.getcode())
84+
if conn.status_code != 200:
85+
msg = "Failed to download bag. status code {}.\n".format(conn.status_code)
8686
yield msg
8787
raise ContentProviderException(msg)
8888
# Bag creation seems to need a small time buffer after it says it's ready.

tests/unit/contentproviders/test_hydroshare.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,11 @@ def hydroshare_archive(prefix="b8f6eae9d89241cf8b5904033460af61/data/contents"):
109109
yield zfile
110110

111111

112-
class MockInfo:
113-
def __init__(self, content_type):
114-
self.content_type = content_type
115-
116-
def get_content_type(self):
117-
return self.content_type
118-
119-
120112
class MockResponse:
121113
def __init__(self, content_type, status_code):
122-
self.content_type = content_type
123114
self.status_code = status_code
124-
self.mock_info = MockInfo(self.content_type)
125-
126-
def getcode(self):
127-
return self.status_code
128-
129-
def info(self):
130-
return self.mock_info
115+
self.headers = dict()
116+
self.headers["content-type"] = content_type
131117

132118

133119
def test_fetch_bag():

0 commit comments

Comments
 (0)