Skip to content

Commit 7ab4992

Browse files
committed
making new caching backwards compatible
1 parent b55eb43 commit 7ab4992

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

astroquery/query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def _request(self, method, url,
338338
# ":" so replace them with an underscore
339339
local_filename = local_filename.replace(':', '_')
340340

341-
local_filepath = os.path.join(savedir or self._cache_location or '.', local_filename)
341+
local_filepath = os.path.join(savedir or self.cache_location or '.', local_filename)
342342

343343
response = self._download_file(url, local_filepath, cache=cache, timeout=timeout,
344344
continuation=continuation, method=method,
@@ -364,13 +364,13 @@ def _request(self, method, url,
364364

365365
if not response:
366366
response = query.request(self._session,
367-
self._cache_location,
367+
self.cache_location,
368368
stream=stream,
369369
auth=auth,
370370
allow_redirects=allow_redirects,
371371
verify=verify,
372372
json=json)
373-
to_cache(response, query.request_file(self._cache_location))
373+
to_cache(response, query.request_file(self.cache_location))
374374

375375
self._last_query = query
376376
return response

astroquery/tests/test_cache.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,22 @@ def test_basic_caching(changing_mocked_response):
8383
assert cache_conf.cache_active
8484

8585
mytest.clear_cache()
86-
assert len(os.listdir(mytest.get_cache_location())) == 0
86+
assert len(os.listdir(mytest.cache_location)) == 0
8787

8888
resp = mytest.test_func(URL1)
8989
assert resp.content == TEXT1
90-
assert len(os.listdir(mytest.get_cache_location())) == 1
90+
assert len(os.listdir(mytest.cache_location)) == 1
9191

9292
resp = mytest.test_func(URL2) # query that has not been cached
9393
assert resp.content == TEXT2
94-
assert len(os.listdir(mytest.get_cache_location())) == 2
94+
assert len(os.listdir(mytest.cache_location)) == 2
9595

9696
resp = mytest.test_func(URL1)
9797
assert resp.content == TEXT1 # query that was cached
98-
assert len(os.listdir(mytest.get_cache_location())) == 2 # no new cache file
98+
assert len(os.listdir(mytest.cache_location)) == 2 # no new cache file
9999

100100
mytest.clear_cache()
101-
assert len(os.listdir(mytest.get_cache_location())) == 0
101+
assert len(os.listdir(mytest.cache_location)) == 0
102102

103103
resp = mytest.test_func(URL1)
104104
assert resp.content == TEXT2 # Now get new response
@@ -135,11 +135,11 @@ def test_login(changing_mocked_response):
135135
assert cache_conf.cache_active
136136

137137
mytest.clear_cache()
138-
assert len(os.listdir(mytest.get_cache_location())) == 0
138+
assert len(os.listdir(mytest.cache_location)) == 0
139139

140140
mytest.login("ceb")
141141
assert mytest.authenticated()
142-
assert len(os.listdir(mytest.get_cache_location())) == 0 # request should not be cached
142+
assert len(os.listdir(mytest.cache_location)) == 0 # request should not be cached
143143

144144
mytest.login("ceb")
145145
assert not mytest.authenticated() # Should not be accessing cache
@@ -152,7 +152,7 @@ def test_timeout(changing_mocked_response, monkeypatch):
152152
assert cache_conf.cache_active
153153

154154
mytest.clear_cache()
155-
assert len(os.listdir(mytest.get_cache_location())) == 0
155+
assert len(os.listdir(mytest.cache_location)) == 0
156156

157157
resp = mytest.test_func(URL1) # should be cached
158158
assert resp.content == TEXT1
@@ -184,11 +184,11 @@ def test_deactivate_directly(changing_mocked_response):
184184
cache_conf.cache_active = False
185185

186186
mytest.clear_cache()
187-
assert len(os.listdir(mytest.get_cache_location())) == 0
187+
assert len(os.listdir(mytest.cache_location)) == 0
188188

189189
resp = mytest.test_func(URL1)
190190
assert resp.content == TEXT1
191-
assert len(os.listdir(mytest.get_cache_location())) == 0
191+
assert len(os.listdir(mytest.cache_location)) == 0
192192

193193
resp = mytest.test_func(URL1)
194194
assert resp.content == TEXT2

0 commit comments

Comments
 (0)