Skip to content

Commit 9163f29

Browse files
committed
Reverse back to use None as default form at initialization to allow non remote-data accessing testing
1 parent fd9bf0d commit 9163f29

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

astroquery/atomic/core.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AtomicLineListClass(BaseQuery):
2727

2828
def __init__(self):
2929
super(AtomicLineListClass, self).__init__()
30-
self.__default_form_values = self._default_form_values()
30+
self.__default_form_values = None
3131

3232
def query_object(self, *, wavelength_range=None, wavelength_type=None, wavelength_accuracy=None, element_spectrum=None,
3333
minimal_abundance=None, depl_factor=None, lower_level_energy_range=None,
@@ -179,7 +179,7 @@ def query_object_async(self, *, wavelength_range=None, wavelength_type='', wavel
179179
response : `requests.Response`
180180
The HTTP response returned from the service.
181181
"""
182-
default_values = self.__default_form_values
182+
default_values = self._default_form_values()
183183
wltype = (wavelength_type or default_values.get('air', '')).lower()
184184
if wltype in ('air', 'vacuum'):
185185
air = wltype.capitalize()
@@ -290,7 +290,7 @@ def _submit_form(self, input_data=None, cache=True):
290290
input_data = {}
291291
# only overwrite payload's values if the ``input_data`` value is not None
292292
# to avoid overwriting of the form's default values
293-
payload = self.__default_form_values.copy()
293+
payload = self._default_form_values().copy()
294294
for k, v in input_data.items():
295295
if v is not None:
296296
payload[k] = v
@@ -302,14 +302,17 @@ def _submit_form(self, input_data=None, cache=True):
302302
return response
303303

304304
def _default_form_values(self):
305-
response = self._request("GET", url=self.FORM_URL, params={},
306-
timeout=self.TIMEOUT, cache=False)
307-
bs = BeautifulSoup(response.text, features='html5lib')
308-
form = bs.find('form')
309-
default_form_values = self._get_default_form_values(form)
310-
self._form_action_url = urlparse.urljoin(self.FORM_URL, form.get('action'))
311-
312-
return default_form_values
305+
if self.__default_form_values is None:
306+
response = self._request("GET", url=self.FORM_URL, params={},
307+
timeout=self.TIMEOUT, cache=False)
308+
bs = BeautifulSoup(response.text, features='html5lib')
309+
form = bs.find('form')
310+
default_form_values = self._get_default_form_values(form)
311+
self._form_action_url = urlparse.urljoin(self.FORM_URL, form.get('action'))
312+
self.__default_form_values = default_form_values
313+
else:
314+
raise ValueError(self.__default_form_values)
315+
return self.__default_form_values
313316

314317
def _get_default_form_values(self, form):
315318
"""Return the already selected values of a given form (a BeautifulSoup

0 commit comments

Comments
 (0)