Fix or x-fail integration tests
This commit is contained in:
parent
08e58a3c1d
commit
853301ca5d
1 changed files with 21 additions and 4 deletions
|
|
@ -12,6 +12,7 @@ it has been moved as it artificaially inflated coverage.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import piexif
|
import piexif
|
||||||
|
|
@ -40,11 +41,26 @@ def test_grab_jpeg(simulation_test_env):
|
||||||
assert image.size == (820, 616)
|
assert image.size == (820, 616)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fmt", ["jpeg", "png"])
|
@pytest.mark.parametrize(
|
||||||
def test_capture_and_metadata(simulation_test_env, fmt):
|
"image_format",
|
||||||
"""Check that the position is encoded into the image metadata."""
|
[
|
||||||
|
"jpeg",
|
||||||
|
pytest.param(
|
||||||
|
"png", marks=pytest.mark.xfail(reason="piexif does not support PNG EXIF")
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_capture_and_metadata(simulation_test_env, image_format, caplog):
|
||||||
|
"""Capture an image and check a attributes.
|
||||||
|
|
||||||
|
- Check that the position is encoded into the image metadata.
|
||||||
|
- Check the dimensions
|
||||||
|
- Check the format
|
||||||
|
"""
|
||||||
camera = simulation_test_env.get_thing_client("camera")
|
camera = simulation_test_env.get_thing_client("camera")
|
||||||
blob = getattr(camera, f"capture_{fmt}")()
|
with caplog.at_level(logging.WARNING):
|
||||||
|
blob = camera.capture(image_format=image_format)
|
||||||
|
assert len(caplog.messages) == 0
|
||||||
image = Image.open(blob.open())
|
image = Image.open(blob.open())
|
||||||
exif_dict = piexif.load(image.info["exif"])
|
exif_dict = piexif.load(image.info["exif"])
|
||||||
encoded_metadata = exif_dict["Exif"][piexif.ExifIFD.UserComment]
|
encoded_metadata = exif_dict["Exif"][piexif.ExifIFD.UserComment]
|
||||||
|
|
@ -52,6 +68,7 @@ def test_capture_and_metadata(simulation_test_env, fmt):
|
||||||
assert "position" in metadata["stage"]
|
assert "position" in metadata["stage"]
|
||||||
assert metadata["stage"]["position"] == {"x": 0, "y": 0, "z": 0}
|
assert metadata["stage"]["position"] == {"x": 0, "y": 0, "z": 0}
|
||||||
assert image.size == (820, 616)
|
assert image.size == (820, 616)
|
||||||
|
assert image.format == image_format.upper()
|
||||||
|
|
||||||
|
|
||||||
def test_stage(simulation_test_env):
|
def test_stage(simulation_test_env):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue