Skip to content

Commit

Permalink
Some tests for wand/pillow backends
Browse files Browse the repository at this point in the history
  • Loading branch information
kaedroho committed Feb 18, 2015
1 parent 5b6bac9 commit 8ba38fe
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import unittest

from tests.test_image import *
from tests.test_pillow import *
from tests.test_wand import *


if __name__ == '__main__':
Expand Down
Binary file added tests/images/transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions tests/test_pillow.py
Original file line number Diff line number Diff line change
@@ -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)
30 changes: 30 additions & 0 deletions tests/test_wand.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8ba38fe

Please sign in to comment.