Skip to content

Commit

Permalink
Fix a misleading test.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdilauro committed Dec 18, 2024
1 parent ec00a8e commit a9b1e04
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions tests/manager/api/test_lanes.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,29 @@ def test_overview_facets(self, lane_fixture: LaneFixture):


class TestCrawlableFacets:
def test_default(self, db: DatabaseTransactionFixture):
facets = CrawlableFacets.default(db.default_library())
@pytest.mark.parametrize(
"c1_distributor, c2_distributor, expected_distributor_count",
(
pytest.param("distributor", "distributor", 1, id="same_distributor"),
pytest.param("distributor", "distributor2", 2, id="different_distributor"),
),
)
def test_default(
self,
db: DatabaseTransactionFixture,
c1_distributor: str,
c2_distributor: str,
expected_distributor_count: int,
):
library = db.library()
c1 = db.collection(
library=library, settings=db.opds_settings(data_source=c1_distributor)
)
c2 = db.collection(
library=library, settings=db.opds_settings(data_source=c2_distributor)
)

facets = CrawlableFacets.default(library)
assert facets.availability == CrawlableFacets.AVAILABLE_ALL
assert facets.order == CrawlableFacets.ORDER_LAST_UPDATE
assert facets.order_ascending is False
Expand All @@ -926,9 +947,9 @@ def test_default(self, db: DatabaseTransactionFixture):
assert len(facet) == 1

# Except for distributor and collectionName, which have the default
# and data for each collection in the library.
for facet in [distributor, collectionName]:
assert len(facet) == 1 + len(db.default_library().associated_collections)
# along with their unique values among each collection in the library.
assert len(distributor) == 1 + expected_distributor_count
assert len(collectionName) == 1 + len(library.associated_collections)

@pytest.mark.parametrize(
"group_name, expected",
Expand Down

0 comments on commit a9b1e04

Please sign in to comment.