Example #1
0
    def test_product_not_found(self, ctx,
                               mock_product_repository: ProductRepository,
                               product_manager: ProductManager):
        mock_product_repository.search_product_by = MagicMock(return_value=([],
                                                                            0))

        with raises(ProductNotFoundError):
            product_manager.get_by_id(ctx, product_id=TEST_PRODUCT_ID)
Example #2
0
    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 = product_manager.get_by_id(ctx, product_id=TEST_PRODUCT_ID)

        assert sample_product == result
        mock_product_repository.search_product_by.assert_called_once()