10
10
from astroquery .query import QueryWithLogin
11
11
from astroquery import cache_conf
12
12
13
+
13
14
URL1 = "http://fakeurl.edu"
14
15
URL2 = "http://fakeurl.ac.uk"
15
16
@@ -82,22 +83,22 @@ def test_basic_caching(changing_mocked_response):
82
83
assert cache_conf .cache_active
83
84
84
85
mytest .clear_cache ()
85
- assert len (os .listdir (mytest .cache_location )) == 0
86
+ assert len (os .listdir (mytest .get_cache_location () )) == 0
86
87
87
88
resp = mytest .test_func (URL1 )
88
89
assert resp .content == TEXT1
89
- assert len (os .listdir (mytest .cache_location )) == 1
90
+ assert len (os .listdir (mytest .get_cache_location () )) == 1
90
91
91
92
resp = mytest .test_func (URL2 ) # query that has not been cached
92
93
assert resp .content == TEXT2
93
- assert len (os .listdir (mytest .cache_location )) == 2
94
+ assert len (os .listdir (mytest .get_cache_location () )) == 2
94
95
95
96
resp = mytest .test_func (URL1 )
96
97
assert resp .content == TEXT1 # query that was cached
97
- assert len (os .listdir (mytest .cache_location )) == 2 # no new cache file
98
+ assert len (os .listdir (mytest .get_cache_location () )) == 2 # no new cache file
98
99
99
100
mytest .clear_cache ()
100
- assert len (os .listdir (mytest .cache_location )) == 0
101
+ assert len (os .listdir (mytest .get_cache_location () )) == 0
101
102
102
103
resp = mytest .test_func (URL1 )
103
104
assert resp .content == TEXT2 # Now get new response
@@ -134,11 +135,11 @@ def test_login(changing_mocked_response):
134
135
assert cache_conf .cache_active
135
136
136
137
mytest .clear_cache ()
137
- assert len (os .listdir (mytest .cache_location )) == 0
138
+ assert len (os .listdir (mytest .get_cache_location () )) == 0
138
139
139
140
mytest .login ("ceb" )
140
141
assert mytest .authenticated ()
141
- assert len (os .listdir (mytest .cache_location )) == 0 # request should not be cached
142
+ assert len (os .listdir (mytest .get_cache_location () )) == 0 # request should not be cached
142
143
143
144
mytest .login ("ceb" )
144
145
assert not mytest .authenticated () # Should not be accessing cache
@@ -151,7 +152,7 @@ def test_timeout(changing_mocked_response, monkeypatch):
151
152
assert cache_conf .cache_active
152
153
153
154
mytest .clear_cache ()
154
- assert len (os .listdir (mytest .cache_location )) == 0
155
+ assert len (os .listdir (mytest .get_cache_location () )) == 0
155
156
156
157
resp = mytest .test_func (URL1 ) # should be cached
157
158
assert resp .content == TEXT1
@@ -183,11 +184,11 @@ def test_deactivate_directly(changing_mocked_response):
183
184
cache_conf .cache_active = False
184
185
185
186
mytest .clear_cache ()
186
- assert len (os .listdir (mytest .cache_location )) == 0
187
+ assert len (os .listdir (mytest .get_cache_location () )) == 0
187
188
188
189
resp = mytest .test_func (URL1 )
189
190
assert resp .content == TEXT1
190
- assert len (os .listdir (mytest .cache_location )) == 0
191
+ assert len (os .listdir (mytest .get_cache_location () )) == 0
191
192
192
193
resp = mytest .test_func (URL1 )
193
194
assert resp .content == TEXT2
0 commit comments