Skip to content

Commit

Permalink
Removed validate image test
Browse files Browse the repository at this point in the history
  • Loading branch information
fernando79513 committed Aug 8, 2024
1 parent e743e53 commit cfc5afe
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions providers/base/tests/test_camera_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,35 +737,6 @@ def test_get_default_format_no_formats(self):
with self.assertRaises(SystemExit):
CameraTest._get_default_format(mock_camera)

@patch("os.path.exists")
@patch("imghdr.what")
@patch("struct.unpack")
def test_validate_image(self, mock_unpack, mock_what, mock_exists):
mock_camera = MagicMock()
mock_exists.return_value = True
mock_what.return_value = "jpeg"
mock_unpack.return_value = (320, 480)

# Binary data to reach the struct.unpack statement
data = (
b"\x00\x00" # Initial bytes to seek past
b"\xff\xc0" # Marker indicating the start of a frame
b"\x00\x00\x00" # Three bytes to seek after the marker
)

# Add the bytes representing the height and width to be unpacked
height = 0x0140 # 320 in hexadecimal
width = 0x01E0 # 480 in hexadecimal
data += struct.pack(">HH", height, width)
data = bytes(data)

with patch("builtins.open", mock_open(read_data=data)):
result = CameraTest._validate_image(
mock_camera, "/tmp/test.jpg", 480, 320
)

self.assertEqual(result, True)

@patch("os.path.exists")
def test_validate_image_no_file(self, mock_exists):
mock_camera = MagicMock()
Expand Down

0 comments on commit cfc5afe

Please sign in to comment.