# This is backport of revisions 436 & 437 from upstream # Change to TestUtil.py was removed as it was not relevant for variety 0.4.20. === modified file 'tests/TestGoodreadsSource.py' --- tests/TestGoodreadsSource.py 2013-09-24 21:08:15 +0000 +++ tests/TestGoodreadsSource.py 2014-10-23 23:31:23 +0000 @@ -24,7 +24,7 @@ class TestGoodreadsSource(unittest.TestCase): def test_get_for_author(self): - p = Jumble(["../plugins"]) + p = Jumble(["../data/plugins"]) p.load() source = p.get_plugins(typename="GoodreadsSource")[0] q = source["plugin"].get_for_author(u"Вежинов") === modified file 'tests/TestJumble.py' --- tests/TestJumble.py 2013-09-24 21:08:15 +0000 +++ tests/TestJumble.py 2014-10-23 23:31:23 +0000 @@ -22,7 +22,7 @@ from jumble.IPlugin import IPlugin from variety.plugins.IQuoteSource import IQuoteSource -sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) +#sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) class P1(IPlugin): pass @@ -33,8 +33,8 @@ class TestJumble(unittest.TestCase): def test_load(self): - p = Jumble(".") + p = Jumble(["../data/plugins"]) p.load() - self.assertEqual(2, len(p.get_plugins())) - self.assertEqual(2, len(p.get_plugins(IPlugin))) - self.assertEqual(1, len(p.get_plugins(IQuoteSource))) + self.assertEqual(4, len(p.get_plugins())) + self.assertEqual(4, len(p.get_plugins(IPlugin))) + self.assertEqual(1, len(p.get_plugins(name="Goodreads"))) === modified file 'tests/TestQuotationsPageSource.py' --- tests/TestQuotationsPageSource.py 2013-09-24 21:08:15 +0000 +++ tests/TestQuotationsPageSource.py 2014-10-23 23:31:23 +0000 @@ -24,7 +24,7 @@ class TestQuotationsPageSource(unittest.TestCase): def test_get_random(self): - p = Jumble(["../plugins"]) + p = Jumble(["../data/plugins"]) p.load() source = p.get_plugins(typename="QuotationsPageSource")[0] q = source["plugin"].get_random() @@ -32,16 +32,16 @@ self.assertEqual("TheQuotationsPage.com", q[0]["sourceName"]) def test_get_for_author(self): - p = Jumble(["../plugins"]) + p = Jumble(["../data/plugins"]) p.load() source = p.get_plugins(typename="QuotationsPageSource")[0] - q = source["plugin"].get_for_author("einstein") + q = source["plugin"].get_for_author("voltaire") self.assertTrue(len(q) > 0) self.assertEqual("TheQuotationsPage.com", q[0]["sourceName"]) - self.assertEqual("Albert Einstein", q[0]["author"]) + self.assertEqual("Voltaire", q[0]["author"]) def test_get_for_keyword(self): - p = Jumble(["../plugins"]) + p = Jumble(["../data/plugins"]) p.load() source = p.get_plugins(typename="QuotationsPageSource")[0] q = source["plugin"].get_for_keyword("funny") === modified file 'tests/TestQuotesDaddySource.py' --- tests/TestQuotesDaddySource.py 2013-09-24 21:08:15 +0000 +++ tests/TestQuotesDaddySource.py 2014-10-23 23:31:23 +0000 @@ -24,7 +24,7 @@ class TestQuotesDaddySource(unittest.TestCase): def test_get_random(self): - p = Jumble(["../plugins"]) + p = Jumble(["../data/plugins"]) p.load() source = p.get_plugins(typename="QuotesDaddySource")[0] q = source["plugin"].get_random()[0] === removed file 'tests/TestQuotesEngine.py' --- tests/TestQuotesEngine.py 2013-02-14 14:42:49 +0000 +++ tests/TestQuotesEngine.py 1970-01-01 00:00:00 +0000 @@ -1,84 +0,0 @@ -#!/usr/bin/python -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- -### BEGIN LICENSE -# Copyright (c) 2012, Peter Levi -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 3, as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranties of -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -### END LICENSE - -import sys -import os.path -import unittest -from variety.QuotesEngine import QuotesEngine - -sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) - -xml1 = """ - - - Quotes Daddy - Random quote by Albert Einstein - http://www.quotesdaddy.com/ - - Mon, 12 Nov 2012 13:23:57 +0000 - en - - - "We can't solve problems by using the same kind of thinking we used when we created them." - Albert Einstein - - - http://www.quotesdaddy.com/quote/17473/albert-einstein/we-cant-solve-problems-by-using-the-same-kind-of-thinking - - - "We can't solve problems by using the same kind of thinking we used when we created them." - Albert Einstein - - 17473 - Mon, 12 Nov 2012 13:23:57 +0000 - - - -""" - -class TestQuotesEngine(unittest.TestCase): - def test_extract_quote(self): - self.assertEqual({"quote" : u"\u201C%s\u201D" % "We can't solve problems by using the same kind of thinking we used when we created them.", - "author" : "Albert Einstein", - "link" : "http://www.quotesdaddy.com/quote/17473/albert-einstein/we-cant-solve-problems-by-using-the-same-kind-of-thinking"}, - QuotesEngine.extract_quote(xml1)) - - def test_choose_random_feed_url(self): - class Opt: - def __init__(self, tags, authors): - self.quotes_tags = tags - self.quotes_authors = authors - - skip = set() - url = QuotesEngine.choose_random_feed_url(Opt("a,b", ""), skip) - self.assertTrue(url.startswith("http://www.quotesdaddy.com/feed/tagged/")) - skip.add(url) - url = QuotesEngine.choose_random_feed_url(Opt("a,b", ""), skip) - self.assertTrue(url.startswith("http://www.quotesdaddy.com/feed/tagged/")) - skip.add(url) - url = QuotesEngine.choose_random_feed_url(Opt("a,b", ""), skip) - self.assertEquals("http://www.quotesdaddy.com/feed", url) - - skip = set() - url = QuotesEngine.choose_random_feed_url(Opt("", "a,b"), skip) - self.assertTrue(url.startswith("http://www.quotesdaddy.com/feed/author/")) - skip.add(url) - url = QuotesEngine.choose_random_feed_url(Opt("", "a,b"), skip) - self.assertTrue(url.startswith("http://www.quotesdaddy.com/feed/author/")) - skip.add(url) - url = QuotesEngine.choose_random_feed_url(Opt("", "a,b"), skip) - self.assertEquals("http://www.quotesdaddy.com/feed", url) - -if __name__ == '__main__': - unittest.main() === removed file 'tests/test_example.py' --- tests/test_example.py 2013-02-14 14:42:49 +0000 +++ tests/test_example.py 1970-01-01 00:00:00 +0000 @@ -1,37 +0,0 @@ -#!/usr/bin/python -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- -### BEGIN LICENSE -# Copyright (c) 2012, Peter Levi -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 3, as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranties of -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -# PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -### END LICENSE - -import sys -import os.path -import unittest -sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) - -from variety import AboutVarietyDialog - -class TestExample(unittest.TestCase): - def setUp(self): - self.AboutVarietyDialog_members = [ - 'AboutDialog', 'AboutVarietyDialog', 'gettext', 'logger', 'logging'] - - def test_AboutVarietyDialog_members(self): - all_members = dir(AboutVarietyDialog) - public_members = [x for x in all_members if not x.startswith('_')] - public_members.sort() - self.assertEqual(self.AboutVarietyDialog_members, public_members) - -if __name__ == '__main__': - unittest.main()