|
17 | 17 | ) |
18 | 18 |
|
19 | 19 | from ..unitutil import ( |
20 | | - function_mock, class_mock, initializer_mock, instance_mock, method_mock |
| 20 | + function_mock, class_mock, initializer_mock, instance_mock, loose_mock, |
| 21 | + method_mock |
21 | 22 | ) |
22 | 23 |
|
23 | 24 |
|
@@ -328,3 +329,43 @@ def _RationalIfdEntry_(self, request, ifd_entry_): |
328 | 329 | @pytest.fixture |
329 | 330 | def offset_(self, request): |
330 | 331 | return instance_mock(request, int) |
| 332 | + |
| 333 | + |
| 334 | +class Describe_IfdEntry(object): |
| 335 | + |
| 336 | + def it_can_construct_from_a_stream_and_offset(self, from_stream_fixture): |
| 337 | + (stream_rdr, offset, _parse_value_, value_count, value_offset, |
| 338 | + _IfdEntry__init_, tag_code, value_) = from_stream_fixture |
| 339 | + ifd_entry = _IfdEntry.from_stream(stream_rdr, offset) |
| 340 | + _parse_value_.assert_called_once_with( |
| 341 | + stream_rdr, offset, value_count, value_offset |
| 342 | + ) |
| 343 | + _IfdEntry__init_.assert_called_once_with(tag_code, value_) |
| 344 | + assert isinstance(ifd_entry, _IfdEntry) |
| 345 | + |
| 346 | + # fixtures ------------------------------------------------------- |
| 347 | + |
| 348 | + @pytest.fixture |
| 349 | + def from_stream_fixture( |
| 350 | + self, _parse_value_, _IfdEntry__init_, value_): |
| 351 | + bytes_ = b'\x00\x01\x66\x66\x00\x00\x00\x02\x00\x00\x00\x03' |
| 352 | + stream_rdr = StreamReader(BytesIO(bytes_), BIG_ENDIAN) |
| 353 | + offset, tag_code, value_count, value_offset = 0, 1, 2, 3 |
| 354 | + return ( |
| 355 | + stream_rdr, offset, _parse_value_, value_count, value_offset, |
| 356 | + _IfdEntry__init_, tag_code, value_ |
| 357 | + ) |
| 358 | + |
| 359 | + @pytest.fixture |
| 360 | + def _IfdEntry__init_(self, request): |
| 361 | + return initializer_mock(request, _IfdEntry) |
| 362 | + |
| 363 | + @pytest.fixture |
| 364 | + def _parse_value_(self, request, value_): |
| 365 | + return method_mock( |
| 366 | + request, _IfdEntry, '_parse_value', return_value=value_ |
| 367 | + ) |
| 368 | + |
| 369 | + @pytest.fixture |
| 370 | + def value_(self, request): |
| 371 | + return loose_mock(request) |
0 commit comments