def test_limit_negative(self, ctx, product_manager: ProductManager): with raises(IntMustBePositive): product_manager.search(ctx, limit=-1, offset=2, product_id=None, terms=None)
def test_happy_path(self, ctx, mock_product_repository: ProductRepository, sample_product: Product, product_manager: ProductManager): mock_product_repository.search_product_by = MagicMock( return_value=([sample_product], 1)) result, count = product_manager.search(ctx, limit=42, offset=2, product_id=None, terms='abc') assert [sample_product] == result assert 1 == count mock_product_repository.search_product_by.assert_called_once_with( ctx, limit=42, offset=2, product_id=None, terms='abc')