def test_happy_path(self, ctx, mock_member_repository: MagicMock, sample_member: Member, member_manager: MemberManager): # Given... mock_member_repository.search_member_by = MagicMock( return_value=([sample_member], 1)) # When... test_terms = 'somthing to serach' test_offset = 42 test_limit = 99 result, count = member_manager.search(ctx, limit=test_limit, offset=test_offset, room_number=TEST_ROOM_NUMBER, terms=test_terms) # Expect... assert [sample_member] == result # Make sure that all the parameters are passed to the DB. mock_member_repository.search_member_by.assert_called_once_with( ctx, limit=test_limit, offset=test_offset, room_number=TEST_ROOM_NUMBER, terms=test_terms)
def test_invalid_offset(self, ctx, member_manager: MemberManager): # When... with raises(IntMustBePositive): member_manager.search(ctx, limit=10, offset=-1)