@@ -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
0 commit comments