|
5 | 5 |
|
6 | 6 |
|
7 | 7 | from decimal import Decimal |
| 8 | +from unittest.mock import AsyncMock |
8 | 9 |
|
9 | 10 | import pytest |
10 | 11 | from aiohttp import web |
@@ -196,10 +197,33 @@ async def test_auto_create_products_groups(app: web.Application): |
196 | 197 | ), f"Invalid {groups}" |
197 | 198 |
|
198 | 199 |
|
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 |
201 | 202 | ): |
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( |
203 | 210 | app, product_name=default_product_name |
204 | 211 | ) |
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