[1878] | 1 | import re |
---|
| 2 | from base import * |
---|
| 3 | |
---|
[1886] | 4 | class TestConfiglet(FunctionalTestCase): |
---|
[1878] | 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: ' \ |
---|
[1886] | 70 | '"%s", must: "%s"' % (tse, expect)) |
---|
[1878] | 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 | |
---|
| 81 | def test_suite(): |
---|
| 82 | from unittest import TestSuite, makeSuite |
---|
| 83 | suite = TestSuite() |
---|
[1886] | 84 | suite.addTest(makeSuite(TestConfiglet)) |
---|
[1878] | 85 | return suite |
---|