Skip to content

Commit

Permalink
test __len__ method
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Aug 9, 2024
1 parent 26588e8 commit 1d01dff
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bfabric/tests/unit/entities/core/test_has_many.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1d01dff

Please sign in to comment.