Skip to content

Commit 2682f84

Browse files
committed
test image component path argument
1 parent 4cf229e commit 2682f84

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/avp/components/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def fail():
183183
if "=" in arg:
184184
key, arg = arg.split("=", 1)
185185
if key == "path" and os.path.exists(arg):
186-
if os.path.splitext(arg)[1] not in self.core.imageFormats:
186+
if f"*{os.path.splitext(arg)[1]}" not in self.core.imageFormats:
187187
fail()
188188
try:
189189
Image.open(arg)

tests/test_comp_image.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
sampleSize = 1470 # 44100 / 30 = 1470
8+
testFile = "inputfiles/test.jpg"
89

910

1011
@fixture
@@ -19,15 +20,15 @@ def coreWithImageComp(qtbot, command):
1920
def test_comp_image_set_path(coreWithImageComp):
2021
"Set imagePath of Image component"
2122
comp = coreWithImageComp.selectedComponents[0]
22-
comp.imagePath = getTestDataPath("inputfiles/test.jpg")
23+
comp.imagePath = getTestDataPath(testFile)
2324
image = comp.previewRender()
2425
assert imageDataSum(image) == 463711601
2526

2627

2728
def test_comp_image_scale_50_1080p(coreWithImageComp):
2829
"""Image component stretches image to 50% at 1080p"""
2930
comp = coreWithImageComp.selectedComponents[0]
30-
comp.imagePath = getTestDataPath("inputfiles/test.jpg")
31+
comp.imagePath = getTestDataPath(testFile)
3132
image = comp.previewRender()
3233
sum = imageDataSum(image)
3334
comp.page.spinBox_scale.setValue(50)
@@ -37,7 +38,7 @@ def test_comp_image_scale_50_1080p(coreWithImageComp):
3738
def test_comp_image_scale_50_720p(coreWithImageComp):
3839
"""Image component stretches image to 50% at 720p"""
3940
comp = coreWithImageComp.selectedComponents[0]
40-
comp.imagePath = getTestDataPath("inputfiles/test.jpg")
41+
comp.imagePath = getTestDataPath(testFile)
4142
comp.page.spinBox_scale.setValue(50)
4243
image = comp.previewRender()
4344
sum = imageDataSum(image)
@@ -47,3 +48,12 @@ def test_comp_image_scale_50_720p(coreWithImageComp):
4748
assert image.width == 1920
4849
assert newImage.width == 1280
4950
assert imageDataSum(comp.previewRender()) == sum
51+
52+
53+
def test_comp_image_command_path(coreWithImageComp):
54+
"""Image component accepts commandline argument:
55+
`path=test.jpg`"""
56+
imgPath = os.path.realpath(getTestDataPath(testFile))
57+
comp = coreWithImageComp.selectedComponents[0]
58+
comp.command(f"path={imgPath}")
59+
assert comp.imagePath == imgPath

0 commit comments

Comments
 (0)