source: products/quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/tests/testConfiglet.py @ 1886

Last change on this file since 1886 was 1886, checked in by mylan, 14 years ago

#161: fix minor bug, rename testSEOConfiglet into testConfiglet module and test

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
1import re
2from base import *
3
4class TestConfiglet(FunctionalTestCase):
5
6    def afterSetUp(self):
7        self.sp = self.portal.portal_properties.site_properties
8        self.seo = self.portal.portal_properties.seo_properties
9        self.basic_auth = ':'.join((portal_owner,default_password))
10        self.loginAsPortalOwner()
11        self.save_url = self.portal.id+'/@@seo-controlpanel?form.actions.save=1' \
12            '&_authenticator=%s' % self._getauth()
13
14    def test_exposeDCMetaTags_On(self):
15        self.publish(self.save_url + '&form.exposeDCMetaTags=on',
16                     self.basic_auth)
17        self.assert_(self.sp.exposeDCMetaTags)
18
19    def test_exposeDCMetaTags_Off(self):
20        self.publish(self.save_url + '&form.exposeDCMetaTags=',
21             self.basic_auth)
22        self.assertTrue(not self.sp.exposeDCMetaTags)
23
24    def test_defaultCustomMetatags_On(self):
25        expect = ('test', 'custom', 'metatags')
26        formdata = "\n".join(expect)
27        self.publish(self.save_url + '&form.default_custom_metatags=%s'%formdata,
28             self.basic_auth)
29
30        dcm = self.seo.getProperty("default_custom_metatags", ())
31        self.assertTrue(dcm == expect, '"default_custom_metatags" property ' \
32            'contains: "%s", must: "%s"' % (dcm, expect))
33
34    def test_defaultCustomMetatags_Off(self):
35        data = ('test', 'custom', 'metatags')
36        self.seo._updateProperty("default_custom_metatags", data)
37        self.publish(self.save_url + '&form.default_custom_metatags=',
38             self.basic_auth)
39
40        dcm = self.seo.getProperty("default_custom_metatags", ())
41        self.assertTrue(dcm == (), '"default_custom_metatags" property ' \
42            'contains: "%s", must be empty"' % str(dcm))
43
44    def test_metatagsOrder_On(self):
45        expect = ('test', 'metatags', 'order')
46        formdata = "\n".join(expect)
47        self.publish(self.save_url + '&form.metatags_order=%s'%formdata,
48             self.basic_auth)
49
50        mo = self.seo.getProperty("metatags_order", ())
51        self.assertTrue(mo == expect, '"metatags_order" property ' \
52            'contains: "%s", must: "%s"' % (mo, expect))
53
54    def test_metatagsOrder_Off(self):
55        data = ('test', 'metatags', 'order')
56        self.seo._updateProperty("metatags_order", data)
57        self.publish(self.save_url + '&form.metatags_order=',
58             self.basic_auth)
59
60        mo = self.seo.getProperty("metatags_order", ())
61        self.assertTrue(mo == (), '"metatags_order" property ' \
62            'contains: "%s", must be empty"' % str(mo))
63
64    def test_typesSEOEnabled_On(self):
65        expect = 'Event'
66        self.publish(self.save_url + "&form.types_seo_enabled=%s" % expect, self.basic_auth)
67        tse = self.seo.getProperty("content_types_with_seoproperties", ())
68        self.assertTrue(tse == (expect,),
69            '"content_types_with_seoproperties" property contains: ' \
70            '"%s", must: "%s"' % (tse, expect))
71
72    def test_typesSEOEnabled_Off(self):
73        self.publish(self.save_url + '&form.types_seo_enabled-empty-marker=1',
74             self.basic_auth)
75
76        tse = self.seo.getProperty("content_types_with_seoproperties", ())
77        self.assertTrue(tse == (), '"content_types_with_seoproperties" property ' \
78            'contains: "%s", must be empty"' % str(tse))
79
80
81def test_suite():
82    from unittest import TestSuite, makeSuite
83    suite = TestSuite()
84    suite.addTest(makeSuite(TestConfiglet))
85    return suite
Note: See TracBrowser for help on using the repository browser.