diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py index c83354f8c7494c3cb258759e6e0d749578c1c6fd..18508d5ae75455795a2a7dceaa5ece56fedf4c60 100644 --- a/src/linkahead/common/models.py +++ b/src/linkahead/common/models.py @@ -2564,7 +2564,7 @@ class PropertyList(list): def filter(self, *args, **kwargs): warnings.warn(DeprecationWarning("This function was renamed to filter_by_identity.")) - return self.filter(*args, **kwargs) + return self.filter_by_identity(*args, **kwargs) def filter_by_identity(self, prop: Optional[Property] = None, pid: Union[None, str, int] = None, @@ -2735,7 +2735,7 @@ class ParentList(list): def filter(self, *args, **kwargs): warnings.warn(DeprecationWarning("This function was renamed to filter_by_identity.")) - return self.filter(*args, **kwargs) + return self.filter_by_identity(*args, **kwargs) def filter_by_identity(self, parent: Optional[Parent] = None, pid: Union[None, str, int] = None, diff --git a/unittests/test_entity.py b/unittests/test_entity.py index e946fd40b8ea95c9f493b5e8f1e12457b2739a72..da057783df50a81a38074e84ddb9822c8e86cc61 100644 --- a/unittests/test_entity.py +++ b/unittests/test_entity.py @@ -29,6 +29,7 @@ import unittest import linkahead from linkahead import (INTEGER, Entity, Parent, Property, Record, RecordType, configure_connection) +import warnings from linkahead.common.models import SPECIAL_ATTRIBUTES from linkahead.connection.mockup import MockUpServerConnection from lxml import etree @@ -282,3 +283,16 @@ def test_filter_by_identity(): assert len(r8.properties.filter_by_identity(name="B")) == 3 assert len(r8.properties.filter_by_identity(name="C")) == 1 assert len(r8.properties.filter_by_identity(pid=12)) == 1 + + + with warnings.catch_warnings(record=True) as w: + # Cause all warnings to always be triggered. + warnings.simplefilter("always") + + r7.properties.filter(pid=34) + assert issubclass(w[-1].category, DeprecationWarning) + assert "This function was renamed" in str(w[-1].message) + + t.parents.filter(pid=234) + assert issubclass(w[-1].category, DeprecationWarning) + assert "This function was renamed" in str(w[-1].message)