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
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
BIN
elevation-images/Nokia/nokia-7220-ixr-d1.front.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
elevation-images/Nokia/nokia-7220-ixr-d1.rear.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
elevation-images/Nokia/nokia-7220-ixr-d2.front.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
elevation-images/Nokia/nokia-7220-ixr-d2.rear.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
elevation-images/Nokia/nokia-7220-ixr-d2l.front.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
elevation-images/Nokia/nokia-7220-ixr-d2l.rear.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
elevation-images/Nokia/nokia-7220-ixr-d3.front.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
elevation-images/Nokia/nokia-7220-ixr-d3.rear.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
elevation-images/Nokia/nokia-7220-ixr-d3l.front.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
elevation-images/Nokia/nokia-7220-ixr-d3l.rear.png
Normal file
After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@ -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)
|
||||
|