Add a test for `svo_fps` query parameter names
The new remote test requests valid parameter names from the server and
checks that `QUERY_PARAMETERS` has not become outdated.
+from io import BytesIO
+
import pytest
from astropy import units as u
+from astropy.io.votable import parse
-from ..core import SvoFps
+from astroquery.svo_fps import conf, SvoFps
+from astroquery.svo_fps.core import QUERY_PARAMETERS
@pytest.mark.remote_data
@@ -25,3 +29,22 @@ class TestSvoFpsClass:
table = SvoFps.get_filter_list(test_facility, test_instrument)
# Check if column for Filter ID (named 'filterID') exists in table
assert 'filterID' in table.colnames
+
+ def test_query_parameter_names(self):
+ # Checks if `QUERY_PARAMETERS` is up to date.
+ query = {"FORMAT": "metadata"}
+ response = BytesIO(
+ SvoFps._request(
+ "GET", conf.base_url, params=query, timeout=conf.timeout, cache=False
+ ).content
+ )
+ params = {p.name.split(":")[1] for p in parse(response).resources[0].params}
+ # All valid parameters should be present in `QUERY_PARAMETERS`.
+ assert not params.difference(QUERY_PARAMETERS)
+ # Some valid parameter names are not in `params`.
+ for p in QUERY_PARAMETERS.difference(params):
+ # `QUERY_PARAMETERS` also contains names without "_min" or "_max" ending
+ # because "Param_min=a&Param_max=b" can be replaced with "Param=a/b".
+ if p + "_min" not in params:
+ # There's a few extra parameters we didn't get from the server.
+ assert p in {"VERB", "FORMAT", "PhotCalID", "ID"}
