Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a misleading test. #2215

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading