Skip to content

Commit 5b1a6b5

Browse files
add test
1 parent c22179a commit 5b1a6b5

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

services/web/server/tests/unit/with_dbs/04/products/test_products_service.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
from decimal import Decimal
8+
from unittest.mock import AsyncMock
89

910
import pytest
1011
from aiohttp import web
@@ -196,10 +197,33 @@ async def test_auto_create_products_groups(app: web.Application):
196197
), f"Invalid {groups}"
197198

198199

199-
async def test_get_product_api_base_url_default(
200-
app: web.Application, default_product_name: ProductName
200+
async def test_get_product_api_base_url(
201+
default_product_name: ProductName, mocker: MockerFixture
201202
):
202-
base_url = await _service.get_product_api_base_url(
203+
app = web.Application()
204+
205+
mocker.patch(
206+
"simcore_service_webserver.products._service.ProductRepository.create_from_app"
207+
).return_value.get_product_base_url = AsyncMock(return_value="https://osparc.io")
208+
209+
api_base_url = await _service.get_product_api_base_url(
203210
app, product_name=default_product_name
204211
)
205-
assert base_url == "https://api.must.be.filled"
212+
213+
assert api_base_url == "https://api.osparc.io"
214+
215+
216+
async def test_get_product_api_base_url_default(
217+
app: web.Application, default_product_name: ProductName
218+
):
219+
api_base_url = await _service.get_product_api_base_url(app, product_name="aaaaa")
220+
assert api_base_url == "https://api.must.be.filled"
221+
222+
223+
async def test_get_product_api_base_url_for_not_existing_product_raises(
224+
app: web.Application,
225+
):
226+
with pytest.raises(ProductNotFoundError):
227+
await _service.get_product_api_base_url(
228+
app, product_name="not-existing-product"
229+
)

0 commit comments

Comments
 (0)