From 6f2526570c92acbf49fa8d4b69b39f41c4e87591 Mon Sep 17 00:00:00 2001 From: Tim DiLauro Date: Tue, 26 Nov 2024 12:15:31 -0500 Subject: [PATCH] Remove unused `Collection.parents` attribute. (#2192) --- src/palace/manager/sqlalchemy/model/collection.py | 14 -------------- tests/manager/sqlalchemy/model/test_collection.py | 15 --------------- 2 files changed, 29 deletions(-) diff --git a/src/palace/manager/sqlalchemy/model/collection.py b/src/palace/manager/sqlalchemy/model/collection.py index d35ab3812..c1f20596f 100644 --- a/src/palace/manager/sqlalchemy/model/collection.py +++ b/src/palace/manager/sqlalchemy/model/collection.py @@ -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 @@ -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 diff --git a/tests/manager/sqlalchemy/model/test_collection.py b/tests/manager/sqlalchemy/model/test_collection.py index bcd66806d..2c90eb112 100644 --- a/tests/manager/sqlalchemy/model/test_collection.py +++ b/tests/manager/sqlalchemy/model/test_collection.py @@ -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