Skip to content

Commit

Permalink
Merge pull request #82 from geoadmin/feat-PB-227-add-babs-to-legacy-i…
Browse files Browse the repository at this point in the history
…con-sets

PB-227: Add babs to legacy icon sets which will no longer be listed
  • Loading branch information
LukasJoss authored Sep 5, 2024
2 parents d9fc68b + 6f29231 commit d00ac0d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/icon_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from app.icon import Icon
from app.settings import COLORABLE_ICON_SETS
from app.settings import IMAGE_FOLDER
from app.settings import LEGACY_ICON_SETS


def get_icon_set(icon_set_name):
Expand All @@ -30,7 +31,9 @@ def get_all_icon_sets():
icon_sets = []
for root, dirs, files in os.walk(IMAGE_FOLDER):
for icon_set_name in dirs:
icon_sets.append(get_icon_set(icon_set_name))
# 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:
icon_sets.append(get_icon_set(icon_set_name))
return icon_sets


Expand Down
1 change: 1 addition & 0 deletions app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)

COLORABLE_ICON_SETS = ['default']
LEGACY_ICON_SETS = ['babs']
DEFAULT_COLOR = {"r": '255', "g": '0', "b": '0'}
DEFAULT_ICON_SIZE = 48
TRAP_HTTP_EXCEPTIONS = True
Expand Down
11 changes: 9 additions & 2 deletions tests/unit_tests/test_all_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +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 tests.unit_tests.base_test import ServiceIconsUnitTests


Expand Down Expand Up @@ -145,7 +146,7 @@ def test_icon_set_origin_allowed(self, headers):

def test_all_icon_sets_endpoint(self):
"""
Checking that the endpoint /sets returns all available icon sets
Checking that the endpoint /sets returns all non-legacy icon sets
"""
response = self.app.get(url_for('all_icon_sets'), headers=self.default_header)
self.assertEqual(response.status_code, 200)
Expand All @@ -157,7 +158,13 @@ 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))
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.assertNotIn(
legacy_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)
self.assertTrue(icon_set['name'] in self.all_icon_sets)
Expand Down

0 comments on commit d00ac0d

Please sign in to comment.