source: products/quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testConfiglet.py @ 2538

Last change on this file since 2538 was 2538, checked in by mylan, 9 years ago

Merged revisions 3566-3575 via svnmerge from
http://svn.quintagroup.com/products/quintagroup.plonegooglesitemaps/branches/test_refactoring

........

r3566 | mylan | 2010-06-14 12:24:52 +0300 (Mon, 14 Jun 2010) | 1 line


#206: Split single testqPloneGoogleSitemaps module into several specific one

........

r3567 | mylan | 2010-06-14 16:14:34 +0300 (Mon, 14 Jun 2010) | 1 line


#206: Improve code coverage - remove useless BBB code from interfaces.

........

r3568 | mylan | 2010-06-14 20:24:25 +0300 (Mon, 14 Jun 2010) | 1 line


#206: Improve code coverage - added test for MobileSitemap?, MobileSitemapView?.

........

r3569 | mylan | 2010-06-14 22:39:39 +0300 (Mon, 14 Jun 2010) | 1 line


#206: reorganize sitemap tests

........

r3570 | mylan | 2010-06-14 22:40:12 +0300 (Mon, 14 Jun 2010) | 1 line


#206: Added configlet tests

........

r3571 | mylan | 2010-06-14 23:05:19 +0300 (Mon, 14 Jun 2010) | 1 line


#206: remove BBB code for plone<3.0

........

r3572 | mylan | 2010-06-14 23:12:00 +0300 (Mon, 14 Jun 2010) | 1 line


#206: added workflow vocabularies tests for SitemapTypes?

........

r3573 | mylan | 2010-06-15 21:36:40 +0300 (Tue, 15 Jun 2010) | 1 line


#206: some cleanup, simplify tests

........

r3574 | mylan | 2010-06-16 16:35:31 +0300 (Wed, 16 Jun 2010) | 1 line


#206: move mobile sitemap code preparation into base module

........

r3575 | mylan | 2010-06-16 16:37:14 +0300 (Wed, 16 Jun 2010) | 1 line


#206: Added security tests

........

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1#
2# Tests for quintagroup.plonegooglesitemaps
3#
4
5from base import *
6from cgi import FieldStorage
7from tempfile import TemporaryFile, NamedTemporaryFile
8
9from OFS.Image import cookId
10from Products.CMFPlone.utils import _createObjectByType
11from ZPublisher.HTTPRequest import FileUpload
12
13
14class TestConfigletSettings(FunctionalTestCase):
15
16    def afterSetUp(self):
17        super(TestConfigletSettings, self).afterSetUp()
18        self.settingsURL = '/'+self.portal.absolute_url(1) + '/prefs_gsm_settings'
19
20    def submitForm(self, fdata, fextra={}):
21        form = {'form.submitted': 1}
22        form.update(fdata)
23        return self.publish(self.settingsURL, request_method='POST',
24                            stdin=StringIO(urlencode(form)),
25                            basic=self.auth, extra=fextra)
26
27    def testInitButtons(self):
28        settings = self.publish(self.settingsURL, self.auth).getBody()
29        self.assert_("Add Content Sitemap" in settings)
30        self.assert_("Add News Sitemap" in settings)
31        self.assert_("Add Mobile Sitemap" in settings)
32
33    def testAddContentSitemap(self):
34        resp = self.submitForm({'form.button.AddContent': "Add Content Sitemap"})
35        self.assertEqual(resp.getStatus() / 100, 3)
36        self.assertEqual(resp.getHeader("Location").endswith("sitemap.xml/edit"), True)
37        # Add SM
38        sm = self.portal["sitemap.xml"]
39        #sm.setPortalTypes(("Documents",))
40        newform = self.publish(self.settingsURL, basic=self.auth).getBody()
41        self.assertEqual('href="http://nohost/plone/sitemap.xml/edit"' in newform, True)
42        self.assertEqual("form.button.AddContent" in newform, False)
43
44    def testAddNewsSitemap(self):
45        resp = self.submitForm({'form.button.AddNews': "Add News Sitemap"})
46        self.assertEqual(resp.getStatus() / 100, 3)
47        self.assertEqual(resp.getHeader("Location").endswith("news-sitemap.xml/edit"), True)
48        # Add SM
49        sm = self.portal["news-sitemap.xml"]
50        #sm.setPortalTypes(("News Item",))
51        newform = self.publish(self.settingsURL, basic=self.auth).getBody()
52        self.assertEqual('href="http://nohost/plone/news-sitemap.xml/edit"' in newform, True)
53        self.assertEqual("form.button.AddNews" in newform, False)
54
55    def testAddMobileSitemap(self):
56        resp = self.submitForm({'form.button.AddMobile': "Add Mobile Sitemap"})
57        self.assertEqual(resp.getStatus() / 100, 3)
58        self.assertEqual(resp.getHeader("Location").endswith("mobile-sitemap.xml/edit"), True)
59        # Add SM
60        sm = self.portal["mobile-sitemap.xml"]
61        #sm.setPortalTypes(("Documents",))
62        newform = self.publish(self.settingsURL, basic=self.auth).getBody()
63        self.assertEqual('href="http://nohost/plone/mobile-sitemap.xml/edit"' in newform, True)
64        self.assertEqual("form.button.AddMobile" in newform, False)
65
66
67class TestConfigletOverview(FunctionalTestCase):
68
69    def afterSetUp(self):
70        super(TestConfigletOverview, self).afterSetUp()
71        self.overviewURL = '/'+self.portal.absolute_url(1) + '/prefs_gsm_overview'
72        self.smURL = "%s/sitemap.xml" % self.portal.absolute_url()
73       
74    def testInitial(self):
75        overview = self.publish(self.overviewURL, self.auth).getBody()
76        self.assert_(not self.smURL in overview)
77
78    def testPresentedSM(self):
79        _createObjectByType("Sitemap", self.portal, id="sitemap.xml",
80                            sitemapType="content")
81        overview = self.publish(self.overviewURL, self.auth).getBody()
82        self.assert_(self.smURL in overview)
83
84
85def test_suite():
86    from unittest import TestSuite, makeSuite
87    suite = TestSuite()
88    suite.addTest(makeSuite(TestConfigletSettings))
89    suite.addTest(makeSuite(TestConfigletOverview))
90    return suite
91
92if __name__ == '__main__':
93    unittest.main(defaultTest='test_suite')
94#    framework()
Note: See TracBrowser for help on using the repository browser.