From c094e694c518cbfc95e23683948cd3b9f7785c5e Mon Sep 17 00:00:00 2001 From: "David H. Irving" Date: Mon, 14 Oct 2024 16:24:25 -0700 Subject: [PATCH] Fix tests for missing RemoteButler warning --- .../daf/butler/registry/tests/_registry.py | 33 ++++++++++++------- tests/test_remote_butler.py | 1 + 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/python/lsst/daf/butler/registry/tests/_registry.py b/python/lsst/daf/butler/registry/tests/_registry.py index da310102aa..4b6334fb18 100644 --- a/python/lsst/daf/butler/registry/tests/_registry.py +++ b/python/lsst/daf/butler/registry/tests/_registry.py @@ -149,6 +149,11 @@ class RegistryTests(ABC): searches. The new one is able to search in these collections.) """ + supportsNonCommonSkypixQueries: bool = True + """True if the registry class being tested supports data ID constraints + like {'htm11' = ...} + """ + @classmethod @abstractmethod def getDataDir(cls) -> str: @@ -3430,17 +3435,21 @@ def do_query(element, datasets=None, collections=None): Test("visit", "-visit.name", (2, 1)), Test("visit", "day_obs,-visit.timespan.begin", (2, 1)), ] - if self.supportsQueryOffset: - test_data.append(Test("detector", "-purpose,detector.raft,name_in_raft", (2, 3), limit=(2, 2))) - with self.assertWarns(FutureWarning): - for test in test_data: - order_by = test.order_by.split(",") - query = do_query(test.element).order_by(*order_by) - if test.limit is not None: - query = query.limit(*test.limit) - dataIds = tuple(rec.id for rec in query) - self.assertEqual(dataIds, test.result) + def do_test(test: Test): + order_by = test.order_by.split(",") + query = do_query(test.element).order_by(*order_by) + if test.limit is not None: + query = query.limit(*test.limit) + dataIds = tuple(rec.id for rec in query) + self.assertEqual(dataIds, test.result) + + for test in test_data: + do_test(test) + + if self.supportsQueryOffset: + with self.assertWarns(FutureWarning): + do_test(Test("detector", "-purpose,detector.raft,name_in_raft", (2, 3), limit=(2, 2))) # errors in a name for order_by in ("", "-"): @@ -3723,8 +3732,8 @@ def test_skypix_constraint_queries(self) -> None: # New query system does not support non-common skypix constraints # and we are deprecating it to replace with region-based constraints. # TODO: Drop this tests once we remove support for non-common skypix. - with self.assertWarns(FutureWarning): - with contextlib.suppress(NotImplementedError): + if self.supportsNonCommonSkypixQueries: + with self.assertWarns(FutureWarning): self.assertEqual( { (data_id["tract"], data_id["patch"]) diff --git a/tests/test_remote_butler.py b/tests/test_remote_butler.py index 8b53927257..e1ed3522c2 100644 --- a/tests/test_remote_butler.py +++ b/tests/test_remote_butler.py @@ -150,6 +150,7 @@ class RemoteButlerRegistryTests(RegistryTests): supportsDetailedQueryExplain = False supportsQueryOffset = False supportsQueryGovernorValidation = False + supportsNonCommonSkypixQueries = False # Jim decided to drop these expressions from the new query system -- they # can be written less ambiguously by writing e.g. ``time <