Increase thumbnail size
[joel/kofoto.git] / src / test / test_clientutils.py
1 #! /usr/bin/env python
2
3 import os
4 import sys
5 import unittest
6
7 if __name__ == "__main__":
8     cwd = os.getcwd()
9     libdir = unicode(os.path.realpath(
10         os.path.join(os.path.dirname(sys.argv[0]), "..", "packages")))
11     os.chdir(libdir)
12     sys.path.insert(0, libdir)
13
14 from kofoto.clientutils import group_image_versions
15
16
17 class TestClientUtils(unittest.TestCase):
18     def test_group_image_versions(self):
19         transforms = [
20             # Different bases.
21             (["/foo/bar.jpg", "/foo/bar2.jpg"],
22              [["/foo/bar.jpg"], ["/foo/bar2.jpg"]]),
23             # Different directories.
24             (["/foo/bar.jpg", "/foo2/bar.cr2"],
25              [["/foo/bar.jpg"], ["/foo2/bar.cr2"]]),
26             # Sort known original first.
27             (["/foo/bar.jpg", "/foo/bar.cr2"],
28              [["/foo/bar.cr2", "/foo/bar.jpg"]]),
29             # Handle uppercase extensions.
30             (["/foo/bar.JPG", "/foo/bar.CR2"],
31              [["/foo/bar.CR2", "/foo/bar.JPG"]]),
32             # Sort shorter filenames first.
33             (["/foo/bar-test.jpg", "/foo/bar.jpg", "/foo/bar-fix.jpg"],
34              [["/foo/bar.jpg", "/foo/bar-fix.jpg", "/foo/bar-test.jpg"]]),
35             # Sort filenames with equal lengths conventionally.
36             (["/foo/bar-test2.jpg", "/foo/bar.jpg", "/foo/bar-test1.jpg"],
37              [["/foo/bar.jpg", "/foo/bar-test1.jpg", "/foo/bar-test2.jpg"]]),
38             ]
39         for (paths, expected) in transforms:
40             actual = list(group_image_versions(paths))
41             self.assertEqual(actual, expected)
42
43
44 if __name__ == "__main__":
45     unittest.main()