|
| 1 | +from stdimage import validators |
| 2 | + |
| 3 | + |
| 4 | +class TestBaseSizeValidator: |
| 5 | + def test_init__none(self): |
| 6 | + assert validators.MinSizeValidator(None, None).limit_value == ( |
| 7 | + float('inf'), float('inf') |
| 8 | + ) |
| 9 | + |
| 10 | + |
| 11 | +class TestMaxSizeValidator: |
| 12 | + def test_compare__inf(self): |
| 13 | + limit_value = float("inf"), float("inf") |
| 14 | + instance = validators.MaxSizeValidator(*limit_value) |
| 15 | + assert not instance.compare((300, 200), limit_value) |
| 16 | + |
| 17 | + def test_compare__eq(self): |
| 18 | + assert not validators.MaxSizeValidator(300, 200).compare((300, 200), (300, 200)) |
| 19 | + |
| 20 | + def test_compare__gt(self): |
| 21 | + limit_value = 300, 200 |
| 22 | + instance = validators.MaxSizeValidator(*limit_value) |
| 23 | + assert instance.compare((600, 400), limit_value) |
| 24 | + assert instance.compare((600, 200), limit_value) |
| 25 | + assert instance.compare((300, 400), limit_value) |
| 26 | + assert instance.compare((600, 100), limit_value) |
| 27 | + assert instance.compare((150, 400), limit_value) |
| 28 | + |
| 29 | + def test_compare__lt(self): |
| 30 | + limit_value = 300, 200 |
| 31 | + instance = validators.MaxSizeValidator(*limit_value) |
| 32 | + assert not instance.compare((150, 100), (300, 200)) |
| 33 | + assert not instance.compare((300, 100), (300, 200)) |
| 34 | + assert not instance.compare((150, 200), (300, 200)) |
| 35 | + |
| 36 | + |
| 37 | +class TestMinSizeValidator: |
| 38 | + def test_compare__inf(self): |
| 39 | + limit_value = float("inf"), float("inf") |
| 40 | + instance = validators.MinSizeValidator(*limit_value) |
| 41 | + assert instance.compare((300, 200), limit_value) |
| 42 | + |
| 43 | + def test_compare__eq(self): |
| 44 | + assert not validators.MinSizeValidator(300, 200).compare((300, 200), (300, 200)) |
| 45 | + |
| 46 | + def test_compare__gt(self): |
| 47 | + limit_value = 300, 200 |
| 48 | + instance = validators.MinSizeValidator(*limit_value) |
| 49 | + assert not instance.compare((600, 400), limit_value) |
| 50 | + assert not instance.compare((600, 200), limit_value) |
| 51 | + assert not instance.compare((300, 400), limit_value) |
| 52 | + assert instance.compare((600, 100), limit_value) |
| 53 | + assert instance.compare((150, 400), limit_value) |
| 54 | + |
| 55 | + def test_compare__lt(self): |
| 56 | + limit_value = 300, 200 |
| 57 | + instance = validators.MinSizeValidator(*limit_value) |
| 58 | + assert instance.compare((150, 100), (300, 200)) |
| 59 | + assert instance.compare((300, 100), (300, 200)) |
| 60 | + assert instance.compare((150, 200), (300, 200)) |
0 commit comments