Skip to content

Commit 7a558f0

Browse files
authored
Merge pull request #1615 from consideRatio/pr/fix-dataverse
ci: fix changed resolved ref for dataverse test, fix recent github ratelimit PR
2 parents 651ef5b + b6b96db commit 7a558f0

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

binderhub/tests/conftest.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,9 @@ def pytest_terminal_summary(terminalreporter, exitstatus):
9595
json.dump(records, f, sort_keys=True, indent=1)
9696

9797

98-
def load_mock_responses(host):
99-
fname = os.path.join(here, f"http-record.{host}.json")
100-
if not os.path.exists(fname):
101-
return {}
102-
with open(fname) as f:
98+
def load_mock_responses(file_name):
99+
file_path = os.path.join(here, file_name)
100+
with open(file_path) as f:
103101
records = json.load(f)
104102
MockAsyncHTTPClient.mocks.update(records)
105103

@@ -120,23 +118,23 @@ def mock_asynchttpclient(request):
120118
# We should use as few mocked responses as possible because it means
121119
# we won't notice changes in the responses from the host that we are
122120
# mocking and our mock responses don't simulate every and all behavior
123-
load_mock_responses("www.hydroshare.org")
121+
load_mock_responses("http-record.www.hydroshare.org.json")
124122

125123
token = os.getenv("GITHUB_ACCESS_TOKEN")
126124
if not token:
127-
load_mock_responses("api.github.com")
128-
load_mock_responses("zenodo.org")
129-
if token and token.startswith("ghs-"):
125+
load_mock_responses("http-record.api.github.com.json")
126+
load_mock_responses("http-record.zenodo.org.json")
127+
if token and token.startswith("ghs_"):
130128
# The GitHub Actions provided temporary token (secrets.github_token)
131129
# does not have access to api.github.com/gists. Due to this, we mock
132130
# such requests even if such token is provided. We recognize them by
133-
# being a server-to-server token with a ghs- prefix as compared to for
131+
# being a server-to-server token with a ghs_ prefix as compared to for
134132
# example a personal access token.
135133
#
136134
# More about github token prefixes:
137135
# https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/#identifiable-prefixes
138136
#
139-
load_mock_responses("api.github.com.gists")
137+
load_mock_responses("http-record.api.github.com.gists.json")
140138

141139

142140
@pytest.fixture

binderhub/tests/test_repoproviders.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
from unittest import TestCase
23
from urllib.parse import quote
34

@@ -166,19 +167,24 @@ async def test_hydroshare_doi():
166167

167168

168169
@pytest.mark.parametrize(
170+
# "10.7910/DVN/TJCLKP" is a DOI associated with all versions of the
171+
# dataverse dataset, including the latest version and previous versions (v3,
172+
# v2, etc). Dataverse doesn't mint DOIs for each version of a dataset, but
173+
# that has been discussed in https://github.com/IQSS/dataverse/issues/4499
174+
#
169175
"spec,resolved_spec,resolved_ref,resolved_ref_url,build_slug",
170176
[
171177
[
172178
"10.7910/DVN/TJCLKP",
173179
"10.7910/DVN/TJCLKP",
174-
"3035124.v3.0",
180+
r"3035124\.v\d+\.\d+$",
175181
"https://doi.org/10.7910/DVN/TJCLKP",
176182
"dataverse-dvn-2ftjclkp",
177183
],
178184
[
179185
"10.25346/S6/DE95RT",
180186
"10.25346/S6/DE95RT",
181-
"20460.v1.0",
187+
r"20460\.v\d+\.\d+$",
182188
"https://doi.org/10.25346/S6/DE95RT",
183189
"dataverse-s6-2fde95rt",
184190
],
@@ -191,7 +197,7 @@ async def test_dataverse(
191197

192198
# have to resolve the ref first
193199
ref = await provider.get_resolved_ref()
194-
assert ref == resolved_ref
200+
assert re.match(resolved_ref, ref)
195201

196202
slug = provider.get_build_slug()
197203
assert slug == build_slug

0 commit comments

Comments
 (0)