--- tests/TestJumble.py 2014-10-23 02:33:26.849283179 +0200 +++ tests/TestJumble.py 2014-10-23 02:26:21.841396700 +0200 @@ -25,10 +25,26 @@ sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) class P1(IPlugin): - pass + @classmethod + def get_info(cls): + return { + "name": "Sample name", + "description": "Sample description", + "version": "1.0", + "author": "Author name", # optional + "url": "Plugin URL" # optional + } class P2(IQuoteSource): - pass + @classmethod + def get_info(cls): + return { + "name": "Sample name 2", + "description": "Sample description 2", + "version": "2.0", + "author": "Author name 2", # optional + "url": "Plugin URL 2" # optional + } class TestJumble(unittest.TestCase): --- tests/TestUtil.py 2013-09-24 20:55:52 +0000 +++ tests/TestUtil.py 2014-10-25 00:33:17 +0000 @@ -19,6 +19,7 @@ import os.path import unittest from variety.Util import Util +from gi.repository import GLib sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) @@ -62,7 +63,7 @@ def test_find_unique_name(self): self.assertEquals('/etc/fstab_1', Util.find_unique_name('/etc/fstab')) - self.assertEquals('/etc/bash_1.bashrc', Util.find_unique_name('/etc/bash.bashrc')) + self.assertEquals('TestUtil_1.py', Util.find_unique_name('TestUtil.py')) def test_folderpath(self): self.assertEquals("/", Util.folderpath("/")) @@ -97,7 +98,7 @@ self.assertEquals("a32377b309e3230f3c89c455ef1bdf0b", Util.md5file("test.jpg")) def test_collapseuser(self): - self.assertEquals("~/.config/variety", Util.collapseuser("/home/peter/.config/variety")) + self.assertEquals("~/.config/variety", Util.collapseuser(os.environ['HOME'] + "/.config/variety")) self.assertEquals("/home/peteraaa/.config/variety", Util.collapseuser("/home/peteraaa/.config/variety")) self.assertEquals("/media/.config/variety", Util.collapseuser("/media/.config/variety")) @@ -110,10 +111,10 @@ def test_get_file_icon_name(self): self.assertEquals("folder", Util.get_file_icon_name("/xxx/yyy/zzz")) # nonexistent self.assertEquals("user-home", Util.get_file_icon_name("~")) - self.assertEquals("folder-pictures", Util.get_file_icon_name("~/Pictures")) - - def test_get_xdg_pictures_folder(self): - self.assertEquals(os.path.expanduser('~/Pictures'), Util.get_xdg_pictures_folder()) + pictures_directory=GLib.get_user_special_dir(GLib.USER_DIRECTORY_PICTURES) + # Test proper icon reading of 'Pictures' folder only if one exists for current user + if not pictures_directory is None: + self.assertEquals("folder-pictures", Util.get_file_icon_name(pictures_directory)) def test_safe_map(self): def f(i): --- data/plugins/quotes/QuotesDaddySource.py 2014-07-06 19:33:36 +0000 +++ data/plugins/quotes/QuotesDaddySource.py 2014-10-25 23:29:28 +0000 @@ -24,6 +24,13 @@ class QuotesDaddySource(IQuoteSource): + def __init__(self): + super(QuotesDaddySource,self).__init__() + self.url = "http://www.quotesdaddy.com/feed" + + def set_url(self, url): + self.url = url + @classmethod def get_info(cls): return { @@ -38,9 +45,7 @@ return False def get_random(self): - url = "http://www.quotesdaddy.com/feed" - - bs = Util.xml_soup(url) + bs = Util.xml_soup(self.url) item = bs.find("item") if not item: logger.warning("Could not find quotes for URL " + url) --- tests/TestQuotesDaddySource.py 2013-09-24 21:08:15 +0000 +++ tests/TestQuotesDaddySource.py 2014-10-25 23:30:14 +0000 @@ -24,8 +24,10 @@ class TestQuotesDaddySource(unittest.TestCase): def test_get_random(self): p = Jumble(["../data/plugins"]) p.load() source = p.get_plugins(typename="QuotesDaddySource")[0] - q = source["plugin"].get_random()[0] + p = source["plugin"] + p.set_url("file:///" + os.path.realpath(os.path.join(os.path.dirname(__file__), "test_quotes_feed.xml"))) + q = p.get_random()[0] self.assertEqual("QuotesDaddy", q["sourceName"]) --- tests/test_quotes_feed.xml 1970-01-01 00:00:00 +0000 +++ tests/test_quotes_feed.xml 2014-10-25 23:28:48 +0000 @@ -0,0 +1,17 @@ + + + + Quotes Daddy - Quote of the Day + http://www.quotesdaddy.com/ + + Sat, 25 Oct 2014 21:56:34 +0000 + en + + "I am a success today because I had a friend who believed in me and I didn't have the heart to let him down..." - Abraham Lincoln + http://www.quotesdaddy.com/quote/288/abraham-lincoln/i-am-a-success-today-because-i-had-a-friend-who-believed + "I am a success today because I had a friend who believed in me and I didn't have the heart to let him down..." - Abraham Lincoln + 288 + Sat, 25 Oct 2014 21:56:34 +0000 + + +