Nokia add images new location (#1233)

* Re-add front/rear images following new location & filename conventions

* Renamed following exact match slug convention

* Debug test failing

* Different log msg

* More debug

* Filter on startswith(slug)

* Debug

* Quotes

* Updated filter

* Match on string part
This commit is contained in:
J vanBemmel 2023-03-27 14:06:48 -05:00 committed by GitHub
parent 4e53e49c5e
commit 3bf511ece6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 25 additions and 17 deletions

View File

@ -7,6 +7,8 @@ u_height: 1
is_full_depth: false # 15.75"
weight: 16.31
weight_unit: lb
front_image: true
rear_image: true
comments: '[Datasheet](https://pf.content.nokia.com/too54x-webscale-dc-fabric-product/7220-dc-routers-data-sheet)'
console-ports:
- name: Console

View File

@ -7,6 +7,8 @@ u_height: 1
is_full_depth: false # 18.11"
weight: 18.08
weight_unit: lb
front_image: true
rear_image: true
comments: '[Datasheet](https://pf.content.nokia.com/too54x-webscale-dc-fabric-product/7220-dc-routers-data-sheet)'
console-ports:
- name: Console

View File

@ -7,6 +7,8 @@ u_height: 1
is_full_depth: true # 21.10"
weight: 22 # fully populated, 16.23 unpopulated
weight_unit: lb
front_image: true
rear_image: true
comments: '[Datasheet](https://pf.content.nokia.com/too54x-webscale-dc-fabric-product/7220-dc-routers-data-sheet)'
console-ports:
- name: Console

View File

@ -7,6 +7,8 @@ u_height: 1
is_full_depth: false # 18.11"
weight: 19.20
weight_unit: lb
front_image: true
rear_image: true
comments: '[Datasheet](https://pf.content.nokia.com/too54x-webscale-dc-fabric-product/7220-dc-routers-data-sheet)'
console-ports:
- name: Console

View File

@ -7,6 +7,8 @@ u_height: 1
is_full_depth: true # 21.28"
weight: 20.64 # fully populated, 14.66 unpopulated
weight_unit: lb
front_image: true
rear_image: true
comments: '[Datasheet](https://pf.content.nokia.com/too54x-webscale-dc-fabric-product/7220-dc-routers-data-sheet)'
console-ports:
- name: Console

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -60,10 +60,10 @@ def _get_image_files():
ret = []
for f in sorted(glob.glob(f"elevation-images/*/*", recursive=True)):
# f = 'elevation-images/Nokia/nokia-7220-ixr-h3-front.png'
# f = 'elevation-images/Nokia/nokia-7220-ixr-h3.front.png'
# f.split('/')[1] = Nokia
assert f.split('/')[2].split('.')[-1] in IMAGE_FILETYPES, f"Invalid file extension: {f}"
ret.append((f.split('/')[1], f))
return ret
@ -155,25 +155,23 @@ def test_definitions(file_path, schema):
# Check for images if front_image or rear_image is True
if (definition.get('front_image') or definition.get('rear_image')):
manufacturer_images = [image for image in image_files if image[0] == file_path.split('/')[1]]
# Find images for given manufacturer, with matching device slug (exact match including case)
manufacturer_images = [image[1] for image in image_files if image[0] == file_path.split('/')[1] and os.path.basename(image[1]).split('.')[0] == slug]
if not manufacturer_images:
pytest.fail(f'{file_path} has Front or Rear Image set to True but no images found for manufacturer', False)
pytest.fail(f'{file_path} has Front or Rear Image set to True but no images found for manufacturer/device (slug={slug})', False)
elif len(manufacturer_images)>2:
pytest.fail(f'More than 2 images found for device with slug {slug}: {manufacturer_images}', False)
if(definition.get('front_image')):
devices = [image_path.split('/')[2] for image, image_path in manufacturer_images if image_path.split('/')[2].split('.')[1] == 'front']
if not devices:
pytest.fail(f'{file_path} has front_image set to True but no images found for device', False)
for device_image in devices:
assert slug.find(device_image.split('.')[0].casefold()) != -1, f'{file_path} has front_image set to True but no images found for device'
front_image = [image_path.split('/')[2] for image_path in manufacturer_images if os.path.basename(image_path).split('.')[1] == 'front']
if not front_image:
pytest.fail(f'{file_path} has front_image set to True but no matching image found for device ({manufacturer_images})', False)
if(definition.get('rear_image')):
devices = [image_path.split('/')[2] for image, image_path in manufacturer_images if image_path.split('/')[2].split('.')[1] == 'rear']
if not devices:
rear_image = [image_path.split('/')[2] for image_path in manufacturer_images if os.path.basename(image_path).split('.')[1] == 'rear']
if not rear_image:
pytest.fail(f'{file_path} has rear_image set to True but no images found for device', False)
for device_image in devices:
assert slug.find(device_image.split('.')[0].casefold()) != -1, f'{file_path} has rear_image set to True but no images found for device'
iterdict(definition)