Skip to content

Commit e4abd6a

Browse files
authored
Add tests, build wheels on release (#26)
1 parent d5e1e68 commit e4abd6a

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

.github/workflows/wheel-builds.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: wheels
1+
name: release wheels
22

33
on:
4-
push:
5-
branches: [ master ]
4+
release:
5+
types: [ published ]
66

77
jobs:
88
build_wheels:

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[![Build Status](https://github.com/pydicom/pylibjpeg-openjpeg/workflows/build/badge.svg)](https://github.com/pydicom/pylibjpeg-openjpeg/actions?query=workflow%3Abuild)
2-
[![Build Status](https://github.com/pydicom/pylibjpeg-openjpeg/workflows/wheels/badge.svg)](https://github.com/pydicom/pylibjpeg-openjpeg/actions?query=workflow%3Awheels)
32
[![codecov](https://codecov.io/gh/pydicom/pylibjpeg-openjpeg/branch/master/graph/badge.svg)](https://codecov.io/gh/pydicom/pylibjpeg-openjpeg)
43
[![PyPI version](https://badge.fury.io/py/pylibjpeg-openjpeg.svg)](https://badge.fury.io/py/pylibjpeg-openjpeg)
54
[![Python versions](https://img.shields.io/pypi/pyversions/pylibjpeg-openjpeg.svg)](https://img.shields.io/pypi/pyversions/pylibjpeg-openjpeg.svg)

openjpeg/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44

55

6-
__version__ = '1.0.0.dev0'
6+
__version__ = '1.0.0'
77

88

99
VERSION_PATTERN = r"""

openjpeg/tests/test_handler.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
HAS_PYDICOM = False
1616

1717
from . import add_handler, remove_handler
18-
from openjpeg import decode, get_parameters
18+
from openjpeg import decode, get_parameters, decode_pixel_data
1919
from openjpeg.data import get_indexed_datasets
2020

2121

@@ -62,6 +62,30 @@ def test_should_change_pi(self):
6262
)
6363
assert not func(ds)
6464

65+
def test_invalid_type_raises(self):
66+
"""Test decoding using invalid type raises."""
67+
index = get_indexed_datasets('1.2.840.10008.1.2.4.90')
68+
ds = index['MR_small_jp2klossless.dcm']['ds']
69+
frame = tuple(next(generate_frames(ds)))
70+
assert not hasattr(frame, 'tell') and not isinstance(frame, bytes)
71+
72+
msg = (
73+
r"The Python object containing the encoded JPEG 2000 data must "
74+
r"either be bytes or have read\(\), tell\(\) and seek\(\) methods."
75+
)
76+
with pytest.raises(TypeError, match=msg):
77+
decode_pixel_data(frame)
78+
79+
def test_no_dataset(self):
80+
index = get_indexed_datasets('1.2.840.10008.1.2.4.90')
81+
ds = index['MR_small_jp2klossless.dcm']['ds']
82+
frame = next(generate_frames(ds))
83+
arr = decode_pixel_data(frame)
84+
assert arr.flags.writeable
85+
assert 'uint8' == arr.dtype
86+
length = ds.Rows * ds.Columns * ds.SamplesPerPixel * ds.BitsAllocated / 8
87+
assert (length,) == arr.shape
88+
6589

6690
@pytest.mark.skipif(not HAS_PYDICOM, reason="pydicom unavailable")
6791
def test_add_handler():

openjpeg/tests/test_parameters.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,13 @@ def test_decode_bad_type_raises(self):
113113
)
114114
with pytest.raises(TypeError, match=msg):
115115
get_parameters(frame)
116+
117+
@pytest.mark.skipif(not HAS_PYDICOM, reason="No pydicom")
118+
def test_decode_format_raises(self):
119+
"""Test decoding using invalid format raises."""
120+
index = get_indexed_datasets('1.2.840.10008.1.2.4.90')
121+
ds = index['693_J2KR.dcm']['ds']
122+
frame = next(generate_frames(ds))
123+
msg = r"Unsupported 'j2k_format' value: 3"
124+
with pytest.raises(ValueError, match=msg):
125+
get_parameters(frame, j2k_format=3)

0 commit comments

Comments
 (0)