diff options
author | Guillaume Emont <guijemont@igalia.com> | 2011-12-14 18:16:24 +0100 |
---|---|---|
committer | Juan A. Suarez Romero <jasuarez@igalia.com> | 2012-06-19 09:07:43 +0200 |
commit | d6b12abcd28c88d21a29b6a44386cc993506e64a (patch) | |
tree | f6c0b430ab328b80caa182033fc06a65e125d3a9 /tests | |
parent | 40e02a11ff6d03d5d4cc54026e1c23ab3284d745 (diff) | |
download | grilo-d6b12abcd28c88d21a29b6a44386cc993506e64a.tar.gz |
tests: added a test of key range filter for fs
Diffstat (limited to 'tests')
-rw-r--r-- | tests/python/test_fs.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/python/test_fs.py b/tests/python/test_fs.py index c77fb22..b74ea4f 100644 --- a/tests/python/test_fs.py +++ b/tests/python/test_fs.py @@ -1,7 +1,7 @@ # some tests on filesystem, useful to test core stuff as long as we don't have # proper mock sources. import unittest -import os, tempfile, shutil +import os, tempfile, shutil, time, calendar import glib try: @@ -66,6 +66,14 @@ class TestFSOperations(unittest.TestCase): for f in file_tree: self._touch_file(f) + self._old_files = [os.path.join(_tempdir, f) \ + for f in (self.file_tree_pictures[1], + self.file_tree_audio[1], + self.file_tree_video[1])] + for f in self._old_files: + mtime = calendar.timegm(time.strptime("1989-07-14", "%Y-%m-%d")) + os.utime(f, (mtime, mtime)) + def tearDown(self): if _tempdir and os.path.isdir(_tempdir): shutil.rmtree(_tempdir) @@ -101,6 +109,26 @@ class TestFSOperations(unittest.TestCase): path_list = sorted(m.get_id() for m in l) self.assertEqual(path_list, expected_result) + def test_key_range_filtered_search(self): + caps = self.plugin.get_caps(Grl.SupportedOps.SEARCH) + options = Grl.OperationOptions.new(caps) + # For now, we provide date _and_ time because of + # https://bugzilla.gnome.org/show_bug.cgi?id=650968 + start = Grl.date_time_from_iso8601("1989-07-13T00:00:00Z") + end = Grl.date_time_from_iso8601("1989-07-15T00:00:00Z") + start.ref() + end.ref() + options.set_key_range_filter_value(Grl.METADATA_KEY_MODIFICATION_DATE, + start, end) + l = self.plugin.search_sync("a", + [Grl.METADATA_KEY_ID, + Grl.METADATA_KEY_MODIFICATION_DATE], + options) + expected_result = sorted(self._old_files) + path_list = sorted(m.get_id() for m in l) + self.assertEqual(path_list, expected_result) + + def test_browse(self): caps = self.plugin.get_caps(Grl.SupportedOps.SEARCH) options = Grl.OperationOptions.new(caps) |