@@ -316,6 +316,19 @@ def it_can_construct_from_a_stream(self, from_stream_fixture):
316316 _Chunks__init_ .assert_called_once_with (chunk_lst )
317317 assert isinstance (chunks , _Chunks )
318318
319+ def it_provides_access_to_the_IHDR_chunk (self , IHDR_fixture ):
320+ chunks , IHDR_chunk_ = IHDR_fixture
321+ assert chunks .IHDR == IHDR_chunk_
322+
323+ def it_provides_access_to_the_pHYs_chunk (self , pHYs_fixture ):
324+ chunks , expected_chunk = pHYs_fixture
325+ assert chunks .pHYs == expected_chunk
326+
327+ def it_raises_if_theres_no_IHDR_chunk (self , no_IHDR_fixture ):
328+ chunks = no_IHDR_fixture
329+ with pytest .raises (InvalidImageStreamError ):
330+ chunks .IHDR
331+
319332 # fixtures -------------------------------------------------------
320333
321334 @pytest .fixture
@@ -341,6 +354,40 @@ def chunk_parser_(self, request):
341354 def _Chunks__init_ (self , request ):
342355 return initializer_mock (request , _Chunks )
343356
357+ @pytest .fixture
358+ def IHDR_fixture (self , IHDR_chunk_ , pHYs_chunk_ ):
359+ chunks = (IHDR_chunk_ , pHYs_chunk_ )
360+ chunks = _Chunks (chunks )
361+ return chunks , IHDR_chunk_
362+
363+ @pytest .fixture
364+ def IHDR_chunk_ (self , request ):
365+ return instance_mock (
366+ request , _IHDRChunk , type_name = PNG_CHUNK_TYPE .IHDR
367+ )
368+
369+ @pytest .fixture
370+ def no_IHDR_fixture (self , pHYs_chunk_ ):
371+ chunks = (pHYs_chunk_ ,)
372+ chunks = _Chunks (chunks )
373+ return chunks
374+
375+ @pytest .fixture
376+ def pHYs_chunk_ (self , request ):
377+ return instance_mock (
378+ request , _pHYsChunk , type_name = PNG_CHUNK_TYPE .pHYs
379+ )
380+
381+ @pytest .fixture (params = [True , False ])
382+ def pHYs_fixture (self , request , IHDR_chunk_ , pHYs_chunk_ ):
383+ has_pHYs_chunk = request .param
384+ chunks = [IHDR_chunk_ ]
385+ if has_pHYs_chunk :
386+ chunks .append (pHYs_chunk_ )
387+ expected_chunk = pHYs_chunk_ if has_pHYs_chunk else None
388+ chunks = _Chunks (chunks )
389+ return chunks , expected_chunk
390+
344391 @pytest .fixture
345392 def stream_ (self , request ):
346393 return instance_mock (request , BytesIO )
0 commit comments