2017-06-30 02:10:07 +02:00
|
|
|
"""Test image functions."""
|
|
|
|
import unittest
|
|
|
|
|
2017-07-22 14:26:49 +02:00
|
|
|
from pywal import image
|
2017-07-22 02:26:36 +02:00
|
|
|
|
|
|
|
|
2017-06-30 02:10:07 +02:00
|
|
|
class TestImage(unittest.TestCase):
|
|
|
|
"""Test image functions."""
|
|
|
|
def test_get_img(self):
|
|
|
|
"""> Validate image file."""
|
2017-07-22 14:26:49 +02:00
|
|
|
result = image.get("tests/test_files/test.jpg")
|
2017-06-30 02:10:07 +02:00
|
|
|
self.assertEqual(result, "tests/test_files/test.jpg")
|
|
|
|
|
|
|
|
def test_get_img_dir(self):
|
|
|
|
"""> Validate image directory."""
|
2017-07-22 14:26:49 +02:00
|
|
|
result = image.get("tests/test_files")
|
2017-07-23 13:29:38 +02:00
|
|
|
self.assertEqual(result.endswith((".jpg", ".png")), True)
|
2017-06-30 02:10:07 +02:00
|
|
|
|
2017-07-23 12:46:29 +02:00
|
|
|
def test_get_img_fail(self):
|
|
|
|
"""> Validate image file. (fail)"""
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
image.get("tests/test_files/test_fail.jpg")
|
|
|
|
|
|
|
|
def test_get_img_dir_fail(self):
|
|
|
|
"""> Validate image directory. (fail)"""
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
image.get("tests")
|
|
|
|
|
2017-06-30 02:10:07 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|