diff --git a/tests/data/apply/config.ini b/tests/data/apply/config-asf.ini similarity index 100% rename from tests/data/apply/config.ini rename to tests/data/apply/config-asf.ini diff --git a/tests/data/apply/config-fancy.ini b/tests/data/apply/config-fancy.ini new file mode 100644 index 0000000..d562f94 --- /dev/null +++ b/tests/data/apply/config-fancy.ini @@ -0,0 +1,21 @@ +[Planet] +output_theme = classic_fancy +output_dir = tests/work/apply +name = test planet +cache_directory = tests/work/spider/cache + +bill_of_materials: + images/#{face} + +[tests/data/spider/testfeed0.atom] +name = not found + +[tests/data/spider/testfeed1b.atom] +name = one +face = jdub.png + +[tests/data/spider/testfeed2.atom] +name = two + +[tests/data/spider/testfeed3.rss] +name = three diff --git a/tests/data/apply/images/jdub.png b/tests/data/apply/images/jdub.png new file mode 100644 index 0000000..8a0de0b Binary files /dev/null and b/tests/data/apply/images/jdub.png differ diff --git a/tests/test_apply.py b/tests/test_apply.py index c785287..e035ab2 100644 --- a/tests/test_apply.py +++ b/tests/test_apply.py @@ -5,11 +5,15 @@ from planet import config, splice from xml.dom import minidom workdir = 'tests/work/apply' -configfile = 'tests/data/apply/config.ini' +configfile = 'tests/data/apply/config-%s.ini' testfeed = 'tests/data/apply/feed.xml' class ApplyTest(unittest.TestCase): def setUp(self): + testfile = open(testfeed) + self.feeddata = testfile.read() + testfile.close() + try: os.makedirs(workdir) except: @@ -20,13 +24,9 @@ class ApplyTest(unittest.TestCase): shutil.rmtree(workdir) os.removedirs(os.path.split(workdir)[0]) - def test_apply(self): - testfile = open(testfeed) - feeddata = testfile.read() - testfile.close() - - config.load(configfile) - splice.apply(feeddata) + def test_apply_asf(self): + config.load(configfile % 'asf') + splice.apply(self.feeddata) # verify that selected files are there for file in ['index.html', 'default.css', 'images/foaf.png']: @@ -46,3 +46,19 @@ class ApplyTest(unittest.TestCase): html.close() self.assertEqual(3, lang) self.assertEqual(12, content) + + def test_apply_fancy(self): + config.load(configfile % 'fancy') + splice.apply(self.feeddata) + + # verify that selected files are there + for file in ['index.html', 'planet.css', 'images/jdub.png']: + path = os.path.join(workdir, file) + self.assertTrue(os.path.exists(path), path) + self.assertTrue(os.stat(path).st_size > 0) + + # verify that index.html is well formed, has content, and xml:lang + html = open(os.path.join(workdir, 'index.html')).read() + self.assertTrue('

test planet

' in html) + self.assertTrue('

Venus

' + in html)