[PATCH 3/7] tests: Tested the PluginMedia class using GI



---
 src/tests/test_plugin.py |   77 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 77 insertions(+), 0 deletions(-)
 create mode 100644 src/tests/test_plugin.py

diff --git a/src/tests/test_plugin.py b/src/tests/test_plugin.py
new file mode 100644
index 0000000..1af54cb
--- /dev/null
+++ b/src/tests/test_plugin.py
@@ -0,0 +1,77 @@
+import unittest
+import logging
+
+try:
+    from gi.repository import Grl
+except:
+    logging.warning("Unable to import Grilo's introspection bindings")
+    exit()
+
+class TestMediaPlugin(unittest.TestCase):
+
+    NONEXISTING_KEY = 'nonexisting_key'
+
+    def setUp(self):
+        Grl.init([])
+        self.registry = Grl.PluginRegistry.get_default()
+        self.registry.load_all()
+        sources = self.registry.get_sources(False)
+        if sources:
+            self.plugin = sources[0]
+
+    def tearDown(self):
+        self.plugin = None
+        for source in self.registry.get_sources(False):
+            self.registry.unload(source.get_id())
+            self.registry.unregister_source(source)
+
+    def test_get_name(self):
+        name = self.plugin.get_name()
+        self.assertTrue(name)
+
+    def test_get_description(self):
+        description = self.plugin.get_name()
+        self.assertTrue(description)
+
+    def test_get_version(self):
+        version = self.plugin.get_version()
+        self.assertTrue(version)
+
+    def test_get_license(self):
+        license = self.plugin.get_license()
+        self.assertTrue(license)
+
+    def test_get_author(self):
+        author = self.plugin.get_author()
+        self.assertTrue(author)
+
+    def test_get_site(self):
+        site = self.plugin.get_site()
+        self.assertTrue(site)
+
+    def test_get_id(self):
+        id = self.plugin.get_id()
+        self.assertTrue(id)
+
+    def test_get_filename(self):
+        filename = self.plugin.get_filename()
+        self.assertTrue(filename)
+
+    def test_get_rank(self):
+        rank = self.plugin.get_rank()
+        self.assertTrue(rank is not None)
+
+    def test_get_info_keys(self):
+        info_keys = self.plugin.get_info_keys()
+        self.assertTrue(info_keys)
+
+    def test_get_info_existing_key(self):
+        keys = self.plugin.get_info_keys()
+        if keys:
+            existing_key = keys[0]
+            info = self.plugin.get_info(existing_key)
+            self.assertTrue(info)
+
+    def test_get_info_nonexisting_key(self):
+        info = self.plugin.get_info(self.NONEXISTING_KEY)
+        self.assertFalse(info)
-- 
1.7.0.4



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