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

Remove unused Collection.parents attribute. #2192

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 0 additions & 14 deletions src/palace/manager/sqlalchemy/model/collection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from collections.abc import Generator
from typing import TYPE_CHECKING, Any, TypeVar

from dependency_injector.wiring import Provide, inject
Expand Down Expand Up @@ -451,19 +450,6 @@ def data_source(self, new_value: DataSource | str) -> None:
**{Collection.DATA_SOURCE_NAME_SETTING: new_datasource_name}
)

@property
def parents(self) -> Generator[Collection]:
if not self.parent_id:
return None

_db = Session.object_session(self)
parent = Collection.by_id(_db, self.parent_id)
if parent is None:
return None

yield parent
yield from parent.parents

@property
def pools_with_no_delivery_mechanisms(self) -> Query[LicensePool]:
"""Find all LicensePools in this Collection that have no delivery
Expand Down
15 changes: 0 additions & 15 deletions tests/manager/sqlalchemy/model/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,6 @@ def test_by_protocol(self, example_collection_fixture: ExampleCollectionFixture)
c1.marked_for_deletion = True
assert [test_collection] == Collection.by_protocol(db.session, overdrive).all()

def test_parents(self, example_collection_fixture: ExampleCollectionFixture):
db = example_collection_fixture.database_fixture

# Collections can return all their parents recursively.
c1 = db.collection()
assert [] == list(c1.parents)

c2 = db.collection()
c2.parent_id = c1.id
assert [c1] == list(c2.parents)

c3 = db.collection()
c3.parent_id = c2.id
assert [c2, c1] == list(c3.parents)

def test_get_protocol(self, db: DatabaseTransactionFixture):
test_collection = db.collection()
integration = test_collection.integration_configuration
Expand Down