From 1d01dff74b80e862b491b1cb7ed28a3f004b26fd Mon Sep 17 00:00:00 2001 From: Leonardo Schwarz Date: Fri, 9 Aug 2024 09:31:09 +0200 Subject: [PATCH] test __len__ method --- bfabric/tests/unit/entities/core/test_has_many.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bfabric/tests/unit/entities/core/test_has_many.py b/bfabric/tests/unit/entities/core/test_has_many.py index 9e7450b1..2cd9e73f 100644 --- a/bfabric/tests/unit/entities/core/test_has_many.py +++ b/bfabric/tests/unit/entities/core/test_has_many.py @@ -123,6 +123,13 @@ def test_has_many_proxy_iter(mocker: MockerFixture, mock_client, mock_proxy): MockEntity.find_all.assert_called_once_with(ids=[1, 2], client=mock_client) +def test_has_many_proxy_len(mocker: MockerFixture, mock_client, mock_proxy): + mock_entities = {1: MockEntity(), 2: MockEntity()} + mocker.patch.object(MockEntity, "find_all", return_value=mock_entities) + assert len(mock_proxy) == 2 + MockEntity.find_all.assert_not_called() + + def test_has_many_proxy_repr(mocker: MockerFixture, mock_client, mock_proxy): assert repr(mock_proxy) == f"_HasManyProxy({MockEntity}, [1, 2], {mock_client})" assert str(mock_proxy) == repr(mock_proxy)