[PATCH 4/6] tests: added simple tests for media dates



---
 tests/python/test_media.py |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100644 tests/python/test_media.py

diff --git a/tests/python/test_media.py b/tests/python/test_media.py
new file mode 100644
index 0000000..e3fc5a2
--- /dev/null
+++ b/tests/python/test_media.py
@@ -0,0 +1,34 @@
+import unittest
+
+try:
+    from gi.repository import Grl
+except:
+    logging.warning("Unable to import Grilo's introspection bindings")
+    exit()
+
+class TestMedia(unittest.TestCase):
+    def test_creation(self):
+        media = Grl.Media.new()
+        self.assertFalse(media is None)
+
+    def test_date(self):
+        media = Grl.Media.new()
+
+        self.assertTrue(media.get_date() is None)
+        self.assertTrue(media.set_date_from_iso8601("2001-02-03T04:05:06Z"))
+        self.assertFalse(media.set_date_from_iso8601("abcd"))
+        # incomplete
+        self.assertFalse(media.set_date_from_iso8601("2001-02-03"))
+        d = media.get_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)
+
+# who said "this is ugly" ?
+Grl.init([])
+registry = Grl.PluginRegistry.get_default()
+registry.load_by_id("grl-filesystem")
-- 
1.7.4.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]