Skip to content

Commit

Permalink
Fix more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbernstein committed Nov 21, 2024
1 parent 1677f2b commit f833605
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
4 changes: 2 additions & 2 deletions tests/manager/api/controller/test_work.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_contributor(self, work_fixture: WorkFixture):
facet_links = [
link for link in links if link["rel"] == "http://opds-spec.org/facet"
]
assert 10 == len(facet_links)
assert 8 == len(facet_links)

# At this point we don't want to generate real feeds anymore.
# We can't do a real end-to-end test without setting up a real
Expand Down Expand Up @@ -868,7 +868,7 @@ def test_series(self, work_fixture: WorkFixture):
facet_links = [
link for link in links if link["rel"] == "http://opds-spec.org/facet"
]
assert 11 == len(facet_links)
assert 9 == len(facet_links)

# The facet link we care most about is the default sort order,
# put into place by SeriesFacets.
Expand Down
15 changes: 4 additions & 11 deletions tests/manager/feed/test_opds_acquisition_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,18 +886,11 @@ def facet_link(cls, url, facet_title, group_title, selected, is_default):
annotator = MockAnnotator()
facets = MockFacets()

# The only 5-tuple yielded by facet_groups was passed on to us.
# The link was run through MockAnnotator.facet_url(),
# and the human-readable titles were found using lookups.
#
# The other three 5-tuples were ignored since we don't know
# The 5-tuples were ignored since we don't know
# how to generate human-readable titles for them.
[[url, facet, group, selected, is_default]] = MockFeed.facet_links(
annotator, facets
)
assert "url: try the featured collection instead" == url
assert selected
assert not is_default
links = MockFeed.facet_links(annotator, facets)

assert len([x for x in links]) == 0

def test_active_loans_for_with_holds(
self, db: DatabaseTransactionFixture, patch_url_for: PatchedUrlFor
Expand Down
7 changes: 0 additions & 7 deletions tests/manager/search/test_external_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,12 +1157,6 @@ def expect(availability, works):
[data.horse, data.moby],
)

# Show only featured-quality works.
expect(
Facets.AVAILABLE_ALL,
[data.becoming, data.moby],
)


class TestSearchOrderData:
a1: LicensePool
Expand Down Expand Up @@ -2612,7 +2606,6 @@ def from_facets(*args, **kwargs):
# used to convert it to appropriate Opensearch syntax, and
# the MockSearch object is modified appropriately.
built = from_facets(
None,
None,
order=Facets.ORDER_AUTHOR,
distributor=None,
Expand Down
14 changes: 5 additions & 9 deletions tests/manager/sqlalchemy/model/test_lane.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ def test_facet_groups(self, db: DatabaseTransactionFixture):
all_groups = list(facets.facet_groups)

# By default, there are 10 facet transitions: two groups of three
# and one group of two and 2 datasource groups and 2 for collection names
assert 12 == len(all_groups)
# and 2 datasource groups and 2 for collection names
assert 10 == len(all_groups)

# available=all, collection=full, and order=title are the selected
# available=all and order=title are the selected
# facets.
selected = sorted(x[:2] for x in all_groups if x[-2] == True)
assert [
Expand All @@ -342,9 +342,7 @@ def test_facet_groups(self, db: DatabaseTransactionFixture):
library = db.default_library()
self._configure_facets(library, test_enabled_facets, test_default_facets)

facets = Facets(
db.default_library(), None, None, Facets.ORDER_TITLE, None, None
)
facets = Facets(db.default_library(), None, Facets.ORDER_TITLE, None, None)
all_groups = list(facets.facet_groups)
# We have disabled almost all the facets, so the list of
# facet transitions includes only two items.
Expand Down Expand Up @@ -707,7 +705,7 @@ def default_facet(cls, config, facet_group_name):
collection_name,
) = Mock.available_facets_calls
# available_facets was called three times, to ask the Mock class what it thinks
# the options for order, availability, and collection should be.
# the options for order and availability should be.
assert (library, "order") == order
assert (library, "available") == available
assert (library, "distributor") == distributor
Expand All @@ -718,13 +716,11 @@ def default_facet(cls, config, facet_group_name):
(
order_d,
available_d,
collection_d,
distributor_d,
collection_name_d,
) = Mock.default_facet_calls
assert (library, "order") == order_d
assert (library, "available") == available_d
assert (library, "collection") == collection_d
assert (library, "distributor") == distributor_d
assert (library, "collectionName") == collection_name_d

Expand Down

0 comments on commit f833605

Please sign in to comment.