1 | import re |
---|
2 | from base import * |
---|
3 | |
---|
4 | class 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 | def test_CustomScriptAdd(self): |
---|
81 | expect = "<script>\n<!-- Test custom script -->\n</script>" |
---|
82 | |
---|
83 | self.publish(self.save_url + '&form.custom_script=%s' % expect, |
---|
84 | self.basic_auth) |
---|
85 | |
---|
86 | cs = self.seo.getProperty("custom_script", "") |
---|
87 | self.assertTrue(cs == expect, '"custom_script" property ' \ |
---|
88 | 'contains: "%s", but "%s" must be"' % (cs, expect)) |
---|
89 | |
---|
90 | def test_CustomScriptDel(self): |
---|
91 | self.publish(self.save_url + '&form.custom_script=', |
---|
92 | self.basic_auth) |
---|
93 | |
---|
94 | cs = self.seo.getProperty("custom_script", "") |
---|
95 | self.assertTrue(cs == "", '"custom_script" property ' \ |
---|
96 | 'contains: "%s", must be empty"' % cs) |
---|
97 | |
---|
98 | def test_fieldsAdd(self): |
---|
99 | expect = ('field1', 'field2') |
---|
100 | formdata = "\n".join(expect) |
---|
101 | self.publish(self.save_url + '&form.fields=%s'%formdata, |
---|
102 | self.basic_auth) |
---|
103 | |
---|
104 | f = self.seo.getProperty("fields", ()) |
---|
105 | self.assertTrue(f == expect, '"fields" property ' \ |
---|
106 | 'contains: "%s", must: "%s"' % (f, expect)) |
---|
107 | |
---|
108 | def test_fieldsDel(self): |
---|
109 | data = ('field1', 'field2') |
---|
110 | self.seo._updateProperty("fields", data) |
---|
111 | self.publish(self.save_url + '&form.fields=', |
---|
112 | self.basic_auth) |
---|
113 | |
---|
114 | f = self.seo.getProperty("fields", ()) |
---|
115 | self.assertTrue(f == (), '"fields" property ' \ |
---|
116 | 'contains: "%s", must be empty"' % str(f)) |
---|
117 | |
---|
118 | def test_stopWordsAdd(self): |
---|
119 | expect = ('sw1', 'sw2', 'sw3') |
---|
120 | formdata = "\n".join(expect) |
---|
121 | self.publish(self.save_url + '&form.stop_words=%s'%formdata, |
---|
122 | self.basic_auth) |
---|
123 | |
---|
124 | f = self.seo.getProperty("stop_words", ()) |
---|
125 | self.assertTrue(f == expect, '"stop_words" property ' \ |
---|
126 | 'contains: "%s", must: "%s"' % (f, expect)) |
---|
127 | |
---|
128 | def test_stopWordsDel(self): |
---|
129 | data = ('sw1', 'sw2', 'sw3') |
---|
130 | self.seo._updateProperty("stop_words", data) |
---|
131 | self.publish(self.save_url + '&form.stop_words=', |
---|
132 | self.basic_auth) |
---|
133 | |
---|
134 | f = self.seo.getProperty("stop_words", ()) |
---|
135 | self.assertTrue(f == (), '"stop_words" property ' \ |
---|
136 | 'contains: "%s", must be empty"' % str(f)) |
---|
137 | |
---|
138 | |
---|
139 | def test_suite(): |
---|
140 | from unittest import TestSuite, makeSuite |
---|
141 | suite = TestSuite() |
---|
142 | suite.addTest(makeSuite(TestConfiglet)) |
---|
143 | return suite |
---|