From fcb252eee4e22468126bbbaf6a9b217105a146f9 Mon Sep 17 00:00:00 2001 From: agostina Date: Thu, 17 Aug 2023 14:54:28 +0200 Subject: [PATCH] LITE-28430: Setting in null logo if the account doesn't have an icon --- connect_ext_ppr/service.py | 2 +- tests/test_service.py | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/connect_ext_ppr/service.py b/connect_ext_ppr/service.py index 7d65bf5..385df8f 100644 --- a/connect_ext_ppr/service.py +++ b/connect_ext_ppr/service.py @@ -41,7 +41,7 @@ def upsert_account(db, account_data): account = Account(id=account_data['id']) account.name = account_data['name'] - account.logo = account_data['icon'] + account.logo = account_data.get('icon') db.add(account) db.commit() diff --git a/tests/test_service.py b/tests/test_service.py index 35a72e0..54c7b21 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -7,8 +7,9 @@ from connect_ext_ppr.models.deployment import Deployment, MarketplaceConfiguration from connect_ext_ppr.models.file import File +from connect_ext_ppr.models.replicas import Account from connect_ext_ppr.schemas import FileSchema, PPRVersionCreateSchema -from connect_ext_ppr.service import add_deployments, create_ppr, get_ppr_new_version +from connect_ext_ppr.service import add_deployments, create_ppr, get_ppr_new_version, upsert_account def test_add_one_deployments( @@ -382,3 +383,20 @@ def test_create_ppr_db_error( assert ex.value.message == ( "Object `MFL-6390-1110-0832` already exists, cannot create a new one." ) + + +@pytest.mark.parametrize( + 'account_data', + ( + {'id': 'VA-000-000', 'name': 'I am a vendor', 'icon': 'my_avatar.png'}, + {'id': 'VA-000-000', 'name': 'I am a vendor'}, + ), +) +def test_upsert_account(dbsession, account_data): + + upsert_account(dbsession, account_data) + account = dbsession.query(Account).first() + + assert account.id == account_data['id'] + assert account.name == account_data['name'] + assert account.logo == account_data.get('icon')