Skip to content

Commit

Permalink
LITE-30249 Product exporting plugin fails with error TypeError
Browse files Browse the repository at this point in the history
  • Loading branch information
IMSalnikov committed May 29, 2024
1 parent c2db1f8 commit 7574c77
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
9 changes: 6 additions & 3 deletions connect/cli/plugins/product/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def _build_f1_options(option_list):
return '"{options}"'.format(options=','.join(option_list))


def _primary_translation_str(trans):
return f'{trans["locale"]["id"]} ({trans["locale"]["name"]})' if trans else ''


def _setup_cover_sheet(ws, product, location, client, media_path):
ws.title = 'General Information'
ws.column_dimensions['A'].width = 50
Expand Down Expand Up @@ -118,9 +122,8 @@ def _setup_cover_sheet(ws, product, location, client, media_path):
.translations.filter(context__instance_id=product['id'], primary=True)
.first()
)
ws[
'B14'
].value = f'{ primary_translation["locale"]["id"] } ({ primary_translation["locale"]["name"] })'

ws['B14'].value = _primary_translation_str(primary_translation)

categories = client.categories.all()
unassignable_cat = ['Cloud Services', 'All Categories']
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ccli = 'connect.cli.ccli:main'
python = ">=3.8,<4"
click = "^8.1.3"
openpyxl = "^3.0.7"
connect-openapi-client = ">=28"
connect-openapi-client = ">=29"
interrogatio = "^2.3.1"
connect-markdown-renderer = ">=3,<4"
iso3166 = "^1.0.1"
Expand All @@ -68,7 +68,7 @@ requests = "^2.25.1"
toml = "^0.10.2"
Jinja2 = "^3.1.2"
jinja2-time = "^0.2.0"
connect-eaas-core = ">=28.13,<29"
connect-eaas-core = ">=28.13,<31"
rich = "^12.4.1"
poetry-core = "^1.3.0"
uvloop = { version = "^0.16.0", markers = "sys_platform == \"linux\" or sys_platform == \"darwin\"" }
Expand Down
16 changes: 16 additions & 0 deletions tests/plugins/product/test_export.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest

from connect.cli.plugins.product.export import _primary_translation_str


def test_primary_translation_str_ok():
translation = {'locale': {
'id': 'jp',
'name': 'Japanese',
}}

assert 'jp (Japanese)' == _primary_translation_str(translation)


def test_primary_translation_str_none():
assert '' == _primary_translation_str(None)

0 comments on commit 7574c77

Please sign in to comment.