From 30789b6b06276e0e54073369289eef296c606d37 Mon Sep 17 00:00:00 2001 From: Lukas Joss Date: Thu, 12 Sep 2024 10:44:41 +0200 Subject: [PATCH 1/3] PB-508: unlist new babs icon sets so that new image can be made for mapviewer on int and prod --- app/icon_set.py | 4 ++-- app/settings.py | 4 +++- tests/unit_tests/test_all_icons.py | 8 +++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/icon_set.py b/app/icon_set.py index d95a5c0..e99219c 100644 --- a/app/icon_set.py +++ b/app/icon_set.py @@ -9,7 +9,7 @@ from app.settings import COLORABLE_ICON_SETS from app.settings import ICON_SET_LANGUAGE from app.settings import IMAGE_FOLDER -from app.settings import LEGACY_ICON_SETS +from app.settings import UNLISTED_SETS def get_icon_set(icon_set_name): @@ -32,7 +32,7 @@ def get_all_icon_sets(): for root, dirs, files in os.walk(IMAGE_FOLDER): for icon_set_name in dirs: # icons of legacy icon sets are still available, but the icon set will not be listed - if icon_set_name not in LEGACY_ICON_SETS: + if icon_set_name not in UNLISTED_SETS: icon_sets.append(get_icon_set(icon_set_name)) return icon_sets diff --git a/app/settings.py b/app/settings.py index a4929ca..35d853a 100644 --- a/app/settings.py +++ b/app/settings.py @@ -15,7 +15,9 @@ ) COLORABLE_ICON_SETS = ['default'] -LEGACY_ICON_SETS = ['babs'] +LEGACY_ICON_SETS = [] +UNRELEASED_SETS = ['babs-de', 'babs-fr', 'babs-it'] +UNLISTED_SETS = LEGACY_ICON_SETS + UNRELEASED_SETS ICON_SET_LANGUAGE = {'babs-de': 'de', 'babs-fr': 'fr', 'babs-it': 'it'} DEFAULT_COLOR = {"r": '255', "g": '0', "b": '0'} DEFAULT_ICON_SIZE = 48 diff --git a/tests/unit_tests/test_all_icons.py b/tests/unit_tests/test_all_icons.py index e3a8704..00b692b 100644 --- a/tests/unit_tests/test_all_icons.py +++ b/tests/unit_tests/test_all_icons.py @@ -13,7 +13,7 @@ from app.settings import COLORABLE_ICON_SETS from app.settings import DEFAULT_ICON_SIZE from app.settings import IMAGE_FOLDER -from app.settings import LEGACY_ICON_SETS +from app.settings import UNLISTED_SETS from tests.unit_tests.base_test import ServiceIconsUnitTests @@ -158,10 +158,8 @@ def test_all_icon_sets_endpoint(self): self.assertIn('items', response.json) self.assertTrue(response.json['items']) icon_sets_from_endpoint = response.json['items'] - self.assertEqual( - len(icon_sets_from_endpoint), len(self.all_icon_sets) - len(LEGACY_ICON_SETS) - ) - for legacy_icon_set in LEGACY_ICON_SETS: + self.assertEqual(len(icon_sets_from_endpoint), len(self.all_icon_sets) - len(UNLISTED_SETS)) + for legacy_icon_set in UNLISTED_SETS: self.assertNotIn( legacy_icon_set, icon_sets_from_endpoint, msg="Icon set should not be listed" ) From f97554943a7f1588be7d8ed01b819c2caff8b385 Mon Sep 17 00:00:00 2001 From: Lukas Joss Date: Thu, 12 Sep 2024 11:39:49 +0200 Subject: [PATCH 2/3] PB-508: Fix variable names --- app/icon_set.py | 4 ++-- app/settings.py | 4 ++-- tests/unit_tests/test_all_icons.py | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/icon_set.py b/app/icon_set.py index e99219c..f08350a 100644 --- a/app/icon_set.py +++ b/app/icon_set.py @@ -9,7 +9,7 @@ from app.settings import COLORABLE_ICON_SETS from app.settings import ICON_SET_LANGUAGE from app.settings import IMAGE_FOLDER -from app.settings import UNLISTED_SETS +from app.settings import UNLISTED_ICON_SETS def get_icon_set(icon_set_name): @@ -32,7 +32,7 @@ def get_all_icon_sets(): for root, dirs, files in os.walk(IMAGE_FOLDER): for icon_set_name in dirs: # icons of legacy icon sets are still available, but the icon set will not be listed - if icon_set_name not in UNLISTED_SETS: + if icon_set_name not in UNLISTED_ICON_SETS: icon_sets.append(get_icon_set(icon_set_name)) return icon_sets diff --git a/app/settings.py b/app/settings.py index 35d853a..00c460b 100644 --- a/app/settings.py +++ b/app/settings.py @@ -16,8 +16,8 @@ COLORABLE_ICON_SETS = ['default'] LEGACY_ICON_SETS = [] -UNRELEASED_SETS = ['babs-de', 'babs-fr', 'babs-it'] -UNLISTED_SETS = LEGACY_ICON_SETS + UNRELEASED_SETS +UNRELEASED_ICON_SETS = ['babs-de', 'babs-fr', 'babs-it'] +UNLISTED_ICON_SETS = LEGACY_ICON_SETS + UNRELEASED_ICON_SETS ICON_SET_LANGUAGE = {'babs-de': 'de', 'babs-fr': 'fr', 'babs-it': 'it'} DEFAULT_COLOR = {"r": '255', "g": '0', "b": '0'} DEFAULT_ICON_SIZE = 48 diff --git a/tests/unit_tests/test_all_icons.py b/tests/unit_tests/test_all_icons.py index 00b692b..d61b606 100644 --- a/tests/unit_tests/test_all_icons.py +++ b/tests/unit_tests/test_all_icons.py @@ -13,7 +13,7 @@ from app.settings import COLORABLE_ICON_SETS from app.settings import DEFAULT_ICON_SIZE from app.settings import IMAGE_FOLDER -from app.settings import UNLISTED_SETS +from app.settings import UNLISTED_ICON_SETS from tests.unit_tests.base_test import ServiceIconsUnitTests @@ -158,10 +158,12 @@ def test_all_icon_sets_endpoint(self): self.assertIn('items', response.json) self.assertTrue(response.json['items']) icon_sets_from_endpoint = response.json['items'] - self.assertEqual(len(icon_sets_from_endpoint), len(self.all_icon_sets) - len(UNLISTED_SETS)) - for legacy_icon_set in UNLISTED_SETS: + self.assertEqual( + len(icon_sets_from_endpoint), len(self.all_icon_sets) - len(UNLISTED_ICON_SETS) + ) + for unlisted_icon_set in UNLISTED_ICON_SETS: self.assertNotIn( - legacy_icon_set, icon_sets_from_endpoint, msg="Icon set should not be listed" + unlisted_icon_set, icon_sets_from_endpoint, msg="Icon set should not be listed" ) for icon_set in icon_sets_from_endpoint: self.assertIn('name', icon_set) From 10a156797e118ab7c8a0b1dc21350cdbf7cf4f46 Mon Sep 17 00:00:00 2001 From: Brice Schaffner Date: Thu, 12 Sep 2024 13:44:11 +0200 Subject: [PATCH 3/3] PB-508: Made the unlisted icon set configurable By default un-list the future legacy babs. --- README.md | 1 + app/settings.py | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b68a7de..4e87cf0 100644 --- a/README.md +++ b/README.md @@ -192,3 +192,4 @@ The service is configured by Environment Variable: | WSGI_TIMEOUT | `5` | WSGI timeout. | | GUNICORN_TMPFS_DIR | `None` |The working directory for the gunicorn workers. | | WSGI_WORKERS | `2` | The number of workers per CPU. | +| UNLISTED_ICON_SETS | `'babs'`| Comma separated list of icon set to un-list. Those sets won't be listed in the /sets endpoint. | diff --git a/app/settings.py b/app/settings.py index 00c460b..41a3d2a 100644 --- a/app/settings.py +++ b/app/settings.py @@ -15,9 +15,7 @@ ) COLORABLE_ICON_SETS = ['default'] -LEGACY_ICON_SETS = [] -UNRELEASED_ICON_SETS = ['babs-de', 'babs-fr', 'babs-it'] -UNLISTED_ICON_SETS = LEGACY_ICON_SETS + UNRELEASED_ICON_SETS +UNLISTED_ICON_SETS = os.environ.get('UNLISTED_ICON_SETS', 'babs').split(',') ICON_SET_LANGUAGE = {'babs-de': 'de', 'babs-fr': 'fr', 'babs-it': 'it'} DEFAULT_COLOR = {"r": '255', "g": '0', "b": '0'} DEFAULT_ICON_SIZE = 48