diff --git a/runtests.py b/runtests.py index c42898f..a126c88 100644 --- a/runtests.py +++ b/runtests.py @@ -1,6 +1,8 @@ import unittest from tests.test_image import * +from tests.test_pillow import * +from tests.test_wand import * if __name__ == '__main__': diff --git a/tests/images/transparent.png b/tests/images/transparent.png new file mode 100644 index 0000000..902ea82 Binary files /dev/null and b/tests/images/transparent.png differ diff --git a/tests/test_pillow.py b/tests/test_pillow.py new file mode 100644 index 0000000..dece0be --- /dev/null +++ b/tests/test_pillow.py @@ -0,0 +1,30 @@ +import unittest2 + +from willow.backends import pillow as pillow_backend + + +class TestPillowOperations(unittest2.TestCase): + def setUp(self): + with open('tests/images/transparent.png', 'rb') as f: + self.backend = pillow_backend.PillowBackend.from_file(f) + + def test_get_size(self): + width, height = pillow_backend.get_size(self.backend) + self.assertEqual(width, 200) + self.assertEqual(height, 150) + + def test_resize(self): + pillow_backend.resize(self.backend, 100, 75) + self.assertEqual(self.backend.image.size, (100, 75)) + + def test_resize(self): + pillow_backend.resize(self.backend, 100, 75) + self.assertEqual(self.backend.image.size, (100, 75)) + + def test_has_alpha(self): + has_alpha = pillow_backend.has_alpha(self.backend) + self.assertTrue(has_alpha) + + def test_has_animation(self): + has_animation = pillow_backend.has_animation(self.backend) + self.assertFalse(has_animation) diff --git a/tests/test_wand.py b/tests/test_wand.py new file mode 100644 index 0000000..6499ce0 --- /dev/null +++ b/tests/test_wand.py @@ -0,0 +1,30 @@ +import unittest2 + +from willow.backends import wand as wand_backend + + +class TestWandOperations(unittest2.TestCase): + def setUp(self): + with open('tests/images/transparent.png', 'rb') as f: + self.backend = wand_backend.WandBackend.from_file(f) + + def test_get_size(self): + width, height = wand_backend.get_size(self.backend) + self.assertEqual(width, 200) + self.assertEqual(height, 150) + + def test_resize(self): + wand_backend.resize(self.backend, 100, 75) + self.assertEqual(self.backend.image.size, (100, 75)) + + def test_resize(self): + wand_backend.resize(self.backend, 100, 75) + self.assertEqual(self.backend.image.size, (100, 75)) + + def test_has_alpha(self): + has_alpha = wand_backend.has_alpha(self.backend) + self.assertTrue(has_alpha) + + def test_has_animation(self): + has_animation = wand_backend.has_animation(self.backend) + self.assertFalse(has_animation)