def test_publication_date(self): media = Grl.Media.new() date_string = "2001-02-03T04:05:06Z" date = Grl.date_time_from_iso8601(date_string) self.assertTrue(media.get_publication_date() is None) media.set_publication_date(date) d = media.get_publication_date() self.assertTrue(d is not None) self.assertEqual(d.get_year(), 2001) self.assertEqual(d.get_month(), 2) self.assertEqual(d.get_day_of_month(), 3) self.assertEqual(d.get_hour(), 4) self.assertEqual(d.get_minute(), 5) self.assertEqual(d.get_second(), 6) self.assertEqual(d.format("%FT%H:%M:%S%Z"), date.format("%FT%H:%M:%S%Z")) # date only date_string = "2001-02-03" date = Grl.date_time_from_iso8601(date_string) media.set_publication_date(date) d = media.get_publication_date() self.assertTrue(d is not None) self.assertEqual(d.get_year(), 2001) self.assertEqual(d.get_month(), 2) self.assertEqual(d.get_day_of_month(), 3) self.assertEqual(d.get_hour(), 12) self.assertEqual(d.get_minute(), 0) self.assertEqual(d.get_second(), 0) self.assertEqual(d.format("%FT%H:%M:%S%Z"), date.format("%FT%H:%M:%S%Z")) self.assertEqual(d.format("%FT%H:%M:%S%Z"), date_string + "T12:00:00UTC")
def test_publication_date(self): media = Grl.Media.new() date_string = "2001-02-03T04:05:06Z" date = Grl.date_time_from_iso8601 (date_string) self.assertTrue(media.get_publication_date() is None) media.set_publication_date(date) d = media.get_publication_date() self.assertTrue(d is not None) self.assertEqual(d.get_year(), 2001) self.assertEqual(d.get_month(), 2) self.assertEqual(d.get_day_of_month(), 3) self.assertEqual(d.get_hour(), 4) self.assertEqual(d.get_minute(), 5) self.assertEqual(d.get_second(), 6) self.assertEqual(d.format("%FT%H:%M:%S%Z"), date.format("%FT%H:%M:%S%Z")) # date only date_string = "2001-02-03" date = Grl.date_time_from_iso8601 (date_string) media.set_publication_date(date) d = media.get_publication_date() self.assertTrue(d is not None) self.assertEqual(d.get_year(), 2001) self.assertEqual(d.get_month(), 2) self.assertEqual(d.get_day_of_month(), 3) self.assertEqual(d.get_hour(), 12) self.assertEqual(d.get_minute(), 0) self.assertEqual(d.get_second(), 0) self.assertEqual(d.format("%FT%H:%M:%S%Z"), date.format("%FT%H:%M:%S%Z")) self.assertEqual(d.format("%FT%H:%M:%S%Z"), date_string + "T12:00:00UTC")
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_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)