77import arrow
88import pytest
99from aiohttp .test_utils import TestClient
10- from models_library .licensed_items import (
11- LicensedItemDB ,
12- LicensedItemUpdateDB ,
13- LicensedResourceType ,
14- )
10+ from models_library .licensed_items import LicensedItemUpdateDB , LicensedResourceType
1511from models_library .rest_ordering import OrderBy
1612from pytest_simcore .helpers .webserver_login import UserInfoDict
1713from simcore_service_webserver .db .models import UserRole
@@ -33,65 +29,66 @@ async def test_licensed_items_db_crud(
3329 pricing_plan_id : int ,
3430):
3531 assert client .app
36-
37- output : tuple [int , list [LicensedItemDB ]] = await _licensed_items_repository .list_ (
32+ total_count , items = await _licensed_items_repository .list_ (
3833 client .app ,
3934 product_name = osparc_product_name ,
4035 offset = 0 ,
4136 limit = 10 ,
4237 order_by = OrderBy (field = "modified" ),
4338 )
44- assert output [0 ] == 0
39+ assert total_count == 0
40+ assert not items
4541
46- licensed_item_db = await _licensed_items_repository .create (
42+ got = await _licensed_items_repository .create (
4743 client .app ,
4844 product_name = osparc_product_name ,
4945 licensed_resource_name = "Model A" ,
5046 licensed_resource_type = LicensedResourceType .VIP_MODEL ,
5147 pricing_plan_id = pricing_plan_id ,
5248 )
53- _licensed_item_id = licensed_item_db .licensed_item_id
49+ licensed_item_id = got .licensed_item_id
5450
55- output : tuple [ int , list [ LicensedItemDB ]] = await _licensed_items_repository .list_ (
51+ total_count , items = await _licensed_items_repository .list_ (
5652 client .app ,
5753 product_name = osparc_product_name ,
5854 offset = 0 ,
5955 limit = 10 ,
6056 order_by = OrderBy (field = "modified" ),
6157 )
62- assert output [0 ] == 1
58+ assert total_count == 1
59+ assert items [0 ].licensed_item_id == licensed_item_id
6360
64- licensed_item_db = await _licensed_items_repository .get (
61+ got = await _licensed_items_repository .get (
6562 client .app ,
66- licensed_item_id = _licensed_item_id ,
63+ licensed_item_id = licensed_item_id ,
6764 product_name = osparc_product_name ,
6865 )
69- assert licensed_item_db .licensed_resource_name == "Model A"
66+ assert got .licensed_resource_name == "Model A"
7067
7168 await _licensed_items_repository .update (
7269 client .app ,
73- licensed_item_id = _licensed_item_id ,
70+ licensed_item_id = licensed_item_id ,
7471 product_name = osparc_product_name ,
75- updates = LicensedItemUpdateDB (name = "Model B" ),
72+ updates = LicensedItemUpdateDB (licensed_resource_name = "Model B" ),
7673 )
7774
78- licensed_item_db = await _licensed_items_repository .get (
75+ got = await _licensed_items_repository .get (
7976 client .app ,
80- licensed_item_id = _licensed_item_id ,
77+ licensed_item_id = licensed_item_id ,
8178 product_name = osparc_product_name ,
8279 )
83- assert licensed_item_db .licensed_resource_name == "Model B"
80+ assert got .licensed_resource_name == "Model B"
8481
85- licensed_item_db = await _licensed_items_repository .delete (
82+ got = await _licensed_items_repository .delete (
8683 client .app ,
87- licensed_item_id = _licensed_item_id ,
84+ licensed_item_id = licensed_item_id ,
8885 product_name = osparc_product_name ,
8986 )
9087
9188 with pytest .raises (LicensedItemNotFoundError ):
9289 await _licensed_items_repository .get (
9390 client .app ,
94- licensed_item_id = _licensed_item_id ,
91+ licensed_item_id = licensed_item_id ,
9592 product_name = osparc_product_name ,
9693 )
9794
0 commit comments