[1878] | 1 | from base import * |
---|
| 2 | |
---|
[1886] | 3 | class TestConfiglet(FunctionalTestCase): |
---|
[1878] | 4 | |
---|
| 5 | def afterSetUp(self): |
---|
| 6 | self.sp = self.portal.portal_properties.site_properties |
---|
| 7 | self.seo = self.portal.portal_properties.seo_properties |
---|
| 8 | self.basic_auth = ':'.join((portal_owner,default_password)) |
---|
| 9 | self.loginAsPortalOwner() |
---|
| 10 | self.save_url = self.portal.id+'/@@seo-controlpanel?form.actions.save=1' \ |
---|
| 11 | '&_authenticator=%s' % self._getauth() |
---|
| 12 | |
---|
| 13 | def test_exposeDCMetaTags_On(self): |
---|
| 14 | self.publish(self.save_url + '&form.exposeDCMetaTags=on', |
---|
| 15 | self.basic_auth) |
---|
| 16 | self.assert_(self.sp.exposeDCMetaTags) |
---|
| 17 | |
---|
| 18 | def test_exposeDCMetaTags_Off(self): |
---|
| 19 | self.publish(self.save_url + '&form.exposeDCMetaTags=', |
---|
| 20 | self.basic_auth) |
---|
| 21 | self.assertTrue(not self.sp.exposeDCMetaTags) |
---|
| 22 | |
---|
| 23 | def test_defaultCustomMetatags_On(self): |
---|
| 24 | expect = ('test', 'custom', 'metatags') |
---|
| 25 | formdata = "\n".join(expect) |
---|
| 26 | self.publish(self.save_url + '&form.default_custom_metatags=%s'%formdata, |
---|
| 27 | self.basic_auth) |
---|
| 28 | |
---|
| 29 | dcm = self.seo.getProperty("default_custom_metatags", ()) |
---|
| 30 | self.assertTrue(dcm == expect, '"default_custom_metatags" property ' \ |
---|
| 31 | 'contains: "%s", must: "%s"' % (dcm, expect)) |
---|
| 32 | |
---|
| 33 | def test_defaultCustomMetatags_Off(self): |
---|
| 34 | data = ('test', 'custom', 'metatags') |
---|
| 35 | self.seo._updateProperty("default_custom_metatags", data) |
---|
| 36 | self.publish(self.save_url + '&form.default_custom_metatags=', |
---|
| 37 | self.basic_auth) |
---|
| 38 | |
---|
| 39 | dcm = self.seo.getProperty("default_custom_metatags", ()) |
---|
| 40 | self.assertTrue(dcm == (), '"default_custom_metatags" property ' \ |
---|
| 41 | 'contains: "%s", must be empty"' % str(dcm)) |
---|
| 42 | |
---|
| 43 | def test_metatagsOrder_On(self): |
---|
| 44 | expect = ('test', 'metatags', 'order') |
---|
| 45 | formdata = "\n".join(expect) |
---|
| 46 | self.publish(self.save_url + '&form.metatags_order=%s'%formdata, |
---|
| 47 | self.basic_auth) |
---|
| 48 | |
---|
| 49 | mo = self.seo.getProperty("metatags_order", ()) |
---|
| 50 | self.assertTrue(mo == expect, '"metatags_order" property ' \ |
---|
| 51 | 'contains: "%s", must: "%s"' % (mo, expect)) |
---|
| 52 | |
---|
| 53 | def test_metatagsOrder_Off(self): |
---|
| 54 | data = ('test', 'metatags', 'order') |
---|
| 55 | self.seo._updateProperty("metatags_order", data) |
---|
| 56 | self.publish(self.save_url + '&form.metatags_order=', |
---|
| 57 | self.basic_auth) |
---|
| 58 | |
---|
| 59 | mo = self.seo.getProperty("metatags_order", ()) |
---|
| 60 | self.assertTrue(mo == (), '"metatags_order" property ' \ |
---|
| 61 | 'contains: "%s", must be empty"' % str(mo)) |
---|
| 62 | |
---|
| 63 | def test_typesSEOEnabled_On(self): |
---|
| 64 | expect = 'Event' |
---|
| 65 | self.publish(self.save_url + "&form.types_seo_enabled=%s" % expect, self.basic_auth) |
---|
| 66 | tse = self.seo.getProperty("content_types_with_seoproperties", ()) |
---|
| 67 | self.assertTrue(tse == (expect,), |
---|
| 68 | '"content_types_with_seoproperties" property contains: ' \ |
---|
[1886] | 69 | '"%s", must: "%s"' % (tse, expect)) |
---|
[1878] | 70 | |
---|
| 71 | def test_typesSEOEnabled_Off(self): |
---|
| 72 | self.publish(self.save_url + '&form.types_seo_enabled-empty-marker=1', |
---|
| 73 | self.basic_auth) |
---|
| 74 | |
---|
| 75 | tse = self.seo.getProperty("content_types_with_seoproperties", ()) |
---|
| 76 | self.assertTrue(tse == (), '"content_types_with_seoproperties" property ' \ |
---|
| 77 | 'contains: "%s", must be empty"' % str(tse)) |
---|
| 78 | |
---|
[1907] | 79 | def test_CustomScriptAdd(self): |
---|
| 80 | expect = "<script>\n<!-- Test custom script -->\n</script>" |
---|
[1878] | 81 | |
---|
[1907] | 82 | self.publish(self.save_url + '&form.custom_script=%s' % expect, |
---|
| 83 | self.basic_auth) |
---|
| 84 | |
---|
| 85 | cs = self.seo.getProperty("custom_script", "") |
---|
| 86 | self.assertTrue(cs == expect, '"custom_script" property ' \ |
---|
| 87 | 'contains: "%s", but "%s" must be"' % (cs, expect)) |
---|
| 88 | |
---|
| 89 | def test_CustomScriptDel(self): |
---|
| 90 | self.publish(self.save_url + '&form.custom_script=', |
---|
| 91 | self.basic_auth) |
---|
| 92 | |
---|
| 93 | cs = self.seo.getProperty("custom_script", "") |
---|
| 94 | self.assertTrue(cs == "", '"custom_script" property ' \ |
---|
| 95 | 'contains: "%s", must be empty"' % cs) |
---|
| 96 | |
---|
| 97 | def test_fieldsAdd(self): |
---|
| 98 | expect = ('field1', 'field2') |
---|
| 99 | formdata = "\n".join(expect) |
---|
| 100 | self.publish(self.save_url + '&form.fields=%s'%formdata, |
---|
| 101 | self.basic_auth) |
---|
| 102 | |
---|
| 103 | f = self.seo.getProperty("fields", ()) |
---|
| 104 | self.assertTrue(f == expect, '"fields" property ' \ |
---|
| 105 | 'contains: "%s", must: "%s"' % (f, expect)) |
---|
| 106 | |
---|
| 107 | def test_fieldsDel(self): |
---|
| 108 | data = ('field1', 'field2') |
---|
| 109 | self.seo._updateProperty("fields", data) |
---|
| 110 | self.publish(self.save_url + '&form.fields=', |
---|
| 111 | self.basic_auth) |
---|
| 112 | |
---|
| 113 | f = self.seo.getProperty("fields", ()) |
---|
| 114 | self.assertTrue(f == (), '"fields" property ' \ |
---|
| 115 | 'contains: "%s", must be empty"' % str(f)) |
---|
| 116 | |
---|
| 117 | def test_stopWordsAdd(self): |
---|
| 118 | expect = ('sw1', 'sw2', 'sw3') |
---|
| 119 | formdata = "\n".join(expect) |
---|
| 120 | self.publish(self.save_url + '&form.stop_words=%s'%formdata, |
---|
| 121 | self.basic_auth) |
---|
| 122 | |
---|
| 123 | f = self.seo.getProperty("stop_words", ()) |
---|
| 124 | self.assertTrue(f == expect, '"stop_words" property ' \ |
---|
| 125 | 'contains: "%s", must: "%s"' % (f, expect)) |
---|
| 126 | |
---|
| 127 | def test_stopWordsDel(self): |
---|
| 128 | data = ('sw1', 'sw2', 'sw3') |
---|
| 129 | self.seo._updateProperty("stop_words", data) |
---|
| 130 | self.publish(self.save_url + '&form.stop_words=', |
---|
| 131 | self.basic_auth) |
---|
| 132 | |
---|
| 133 | f = self.seo.getProperty("stop_words", ()) |
---|
| 134 | self.assertTrue(f == (), '"stop_words" property ' \ |
---|
| 135 | 'contains: "%s", must be empty"' % str(f)) |
---|
| 136 | |
---|
| 137 | |
---|
[1878] | 138 | def test_suite(): |
---|
| 139 | from unittest import TestSuite, makeSuite |
---|
| 140 | suite = TestSuite() |
---|
[1886] | 141 | suite.addTest(makeSuite(TestConfiglet)) |
---|
[1878] | 142 | return suite |
---|