2023-12-21 14:13:31 +03:00
|
|
|
from __future__ import annotations
|
2024-01-20 14:23:03 +03:00
|
|
|
|
2020-02-12 19:29:19 +03:00
|
|
|
import pytest
|
2020-08-07 13:28:33 +03:00
|
|
|
|
2017-05-28 16:11:16 +03:00
|
|
|
from PIL import Image, McIdasImagePlugin
|
2015-07-03 08:03:25 +03:00
|
|
|
|
2021-02-21 14:15:56 +03:00
|
|
|
from .helper import assert_image_equal_tofile
|
2019-07-06 23:40:53 +03:00
|
|
|
|
2015-07-03 08:03:25 +03:00
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
def test_invalid_file() -> None:
|
2020-02-12 19:29:19 +03:00
|
|
|
invalid_file = "Tests/images/flower.jpg"
|
2015-07-03 09:22:56 +03:00
|
|
|
|
2020-02-12 19:29:19 +03:00
|
|
|
with pytest.raises(SyntaxError):
|
|
|
|
McIdasImagePlugin.McIdasImageFile(invalid_file)
|
2015-07-03 08:03:25 +03:00
|
|
|
|
2017-05-28 16:11:16 +03:00
|
|
|
|
2024-01-27 07:19:43 +03:00
|
|
|
def test_valid_file() -> None:
|
2020-02-12 19:29:19 +03:00
|
|
|
# Arrange
|
|
|
|
# https://ghrc.nsstc.nasa.gov/hydro/details/cmx3g8
|
|
|
|
# https://ghrc.nsstc.nasa.gov/pub/fieldCampaigns/camex3/cmx3g8/browse/
|
|
|
|
test_file = "Tests/images/cmx3g8_wv_1998.260_0745_mcidas.ara"
|
|
|
|
saved_file = "Tests/images/cmx3g8_wv_1998.260_0745_mcidas.png"
|
2017-05-28 16:11:16 +03:00
|
|
|
|
2020-02-12 19:29:19 +03:00
|
|
|
# Act
|
|
|
|
with Image.open(test_file) as im:
|
|
|
|
im.load()
|
|
|
|
|
|
|
|
# Assert
|
|
|
|
assert im.format == "MCIDAS"
|
|
|
|
assert im.mode == "I"
|
|
|
|
assert im.size == (1800, 400)
|
2021-02-21 14:15:56 +03:00
|
|
|
assert_image_equal_tofile(im, saved_file)
|