[grilo] tests: added simple tests for media dates
- From: Guillaume JÃrÃme Emont <guijemont src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] tests: added simple tests for media dates
- Date: Fri, 7 Oct 2011 15:12:23 +0000 (UTC)
commit 63c499adaf7ba1a4fd173997971820c3aabef2da
Author: Guillaume Emont <guijemont igalia com>
Date: Fri Jun 3 18:05:20 2011 +0200
tests: added simple tests for media dates
tests/python/test_media.py | 59 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/tests/python/test_media.py b/tests/python/test_media.py
new file mode 100644
index 0000000..ccd4727
--- /dev/null
+++ b/tests/python/test_media.py
@@ -0,0 +1,59 @@
+import unittest
+import logging
+
+try:
+ from gi.repository import Grl
+except:
+ logging.warning("Unable to import Grilo's introspection bindings")
+ exit()
+try:
+ from gi.repository import GLib
+except TypeError:
+ # there seems to be a bug with GVariants these days that triggers an
+ # exception when importing GLib. Seems to be harmless though. We import
+ # explicitly GLib in a try/except here so that we can handle that, else the
+ # exception would be raised the first time it is imported by other code
+ # (e.g. by using a GDateTime)
+ from gi.repository import GLib
+
+class TestMedia(unittest.TestCase):
+ def test_creation(self):
+ media = Grl.Media.new()
+ self.assertFalse(media is None)
+
+ 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")
+
+# who said "this is ugly" ?
+Grl.init([])
+registry = Grl.PluginRegistry.get_default()
+registry.load_by_id("grl-filesystem")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]