| Total Complexity | 6 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | |||
| 3 | |||
| 4 | @pytest.fixture |
||
| 5 | def image_manager(): |
||
| 6 | from artificial_artwork.nst_image import ImageManager |
||
| 7 | return ImageManager([lambda array: array + 2]) |
||
| 8 | |||
| 9 | |||
| 10 | @pytest.fixture |
||
| 11 | def compatible_images(test_image): |
||
| 12 | return type('CompatibleImages', (), { |
||
| 13 | 'content': test_image('canoe_water.jpg'), |
||
| 14 | 'style': test_image('blue-red-w400-h300.jpg'), |
||
| 15 | })() |
||
| 16 | |||
| 17 | @pytest.fixture |
||
| 18 | def incompatible_image(test_image): |
||
| 19 | return test_image('wikipedia-logo.png') |
||
| 20 | |||
| 21 | |||
| 22 | def test_image_manager(image_manager, compatible_images, incompatible_image): |
||
| 23 | assert image_manager.images_compatible == False |
||
| 24 | |||
| 25 | image_manager.load_from_disk(compatible_images.content, 'content') |
||
| 26 | assert image_manager.images_compatible == False |
||
| 27 | |||
| 28 | image_manager.load_from_disk(compatible_images.style, 'style') |
||
| 29 | assert image_manager.images_compatible == True |
||
| 30 | |||
| 31 | image_manager.load_from_disk(incompatible_image, 'content') |
||
| 32 | assert image_manager.images_compatible == False |
||
| 33 | |||
| 34 | with pytest.raises(ValueError): |
||
| 35 | image_manager.load_from_disk(compatible_images.content, 'unknown-type') |
||
| 36 |