Skip to content

Commit

Permalink
Fix tests for missing RemoteButler warning
Browse files Browse the repository at this point in the history
  • Loading branch information
dhirving committed Oct 14, 2024
1 parent 900a39e commit e77bf87
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
33 changes: 21 additions & 12 deletions python/lsst/daf/butler/registry/tests/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 ("", "-"):
Expand Down Expand Up @@ -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"])
Expand Down
1 change: 1 addition & 0 deletions tests/test_remote_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <
Expand Down

0 comments on commit e77bf87

Please sign in to comment.