Changeset 3162 in products
- Timestamp:
- Apr 20, 2011 2:11:46 PM (14 years ago)
- Location:
- quintagroup.plonecaptchas/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/Extensions/Install.py
r2041 r3162 2 2 from Products.CMFCore.utils import getToolByName 3 3 REQUIRED = 'quintagroup.captcha.core' 4 4 5 5 6 def install(self): … … 13 14 # install plonecaptchas 14 15 gs = getToolByName(self, 'portal_setup') 15 gs.runAllImportStepsFromProfile('profile-quintagroup.plonecaptchas:default') 16 profile = 'profile-quintagroup.plonecaptchas:default' 17 gs.runAllImportStepsFromProfile(profile) 16 18 transaction.savepoint() 19 17 20 18 21 def uninstall(self): 19 22 portal_setup = getToolByName(self, 'portal_setup') 20 portal_setup.runAllImportStepsFromProfile('profile-quintagroup.plonecaptchas:uninstall', purge_old=False) 23 profile = 'profile-quintagroup.plonecaptchas:uninstall' 24 portal_setup.runAllImportStepsFromProfile(profile, purge_old=False) 21 25 transaction.savepoint() -
quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/tests/base.py
r3161 r3162 26 26 27 27 ptc.setupPloneSite() 28 28 29 29 30 class NotInstalled(PloneSite): … … 60 61 js_layer = None 61 62 if getattr(ptc_setup, 'PLONE33', 0): 62 js_layer = JF_PROFILE_PREFIX +'33'63 js_layer = JF_PROFILE_PREFIX + '33' 63 64 elif getattr(ptc_setup, 'PLONE32', 0): 64 js_layer = JF_PROFILE_PREFIX +'31_32'65 js_layer = JF_PROFILE_PREFIX + '31_32' 65 66 elif getattr(ptc_setup, 'PLONE31', 0): 66 js_layer = JF_PROFILE_PREFIX +'31_32'67 js_layer = JF_PROFILE_PREFIX + '31_32' 67 68 elif getattr(ptc_setup, 'PLONE30', 0): 68 js_layer = JF_PROFILE_PREFIX +'30'69 js_layer = JF_PROFILE_PREFIX + '30' 69 70 if js_layer is not None: 70 71 gs = getattr(portal, 'portal_setup', None) … … 76 77 def tearDown(cls): 77 78 ptc_setup._placefulTearDown() 78 79 79 80 80 81 class TestCase(ptc.PloneTestCase): 81 82 layer = Installed 83 82 84 83 85 class TestCaseNotInstalled(ptc.PloneTestCase): … … 88 90 layer = Installed 89 91 92 90 93 class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase): 91 94 layer = NotInstalled -
quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/tests/testForms.py
r3161 r3162 34 34 testPatch() 35 35 36 36 37 class TestFormMixin(FunctionalTestCase): 37 38 … … 42 43 addTestLayer(self) 43 44 # Prepare form data 44 self.basic_auth = ':'.join((portal_owner, default_password))45 self.basic_auth = ':'.join((portal_owner, default_password)) 45 46 self.form_url = '' 46 47 self.form_method = "POST" … … 84 85 self.form_method = "GET" 85 86 response = self.publishForm().getBody() 86 patt = re.compile(IMAGE_PATT 87 patt = re.compile(IMAGE_PATT % self.portal.absolute_url()) 87 88 match_obj = patt.search(response) 88 89 img_url = match_obj.group(1) 89 90 90 content_type = self.publish('/plone' + img_url).getHeader('content-type') 91 content_type = self.publish('/plone' + img_url).getHeader( 92 'content-type') 91 93 self.assertTrue(content_type.startswith('image'), 92 94 "Wrong captcha image content type") 93 95 94 96 def testSubmitRightCaptcha(self): 95 key = getWord(int(parseKey(decrypt(self.captcha_key, self.hashkey))['key'])-1) 97 key = getWord(int(parseKey(decrypt( 98 self.captcha_key, self.hashkey))['key']) - 1) 96 99 self.form_data['key'] = key 97 100 98 101 response = self.publishForm().getBody() 99 102 self.assertFalse(NOT_VALID.search(response)) … … 105 108 106 109 def testSubmitRightCaptchaTwice(self): 107 key = getWord(int(parseKey(decrypt(self.captcha_key, self.hashkey))['key'])-1) 110 key = getWord(int(parseKey(decrypt( 111 self.captcha_key, self.hashkey))['key']) - 1) 108 112 self.form_data['key'] = key 109 113 … … 120 124 self.portal['index_html'].allowDiscussion(True) 121 125 self.form_url = '/index_html/discussion_reply_form' 122 126 123 127 def getFormData(self): 124 return {'form.submitted' 128 return {'form.submitted': '1', 125 129 'subject': 'testing', 126 130 'Creator': portal_owner, 127 131 'body_text': 'Text in Comment', 128 132 'discussion_reply:method': 'Save', 129 'form.button.form_submit' 133 'form.button.form_submit': 'Save'} 130 134 131 135 … … 141 145 142 146 def getFormData(self): 143 return {"last_visit:date" 144 "prev_visit:date" : str(DateTime()-1),145 "came_from_prefs" 146 "fullname" 147 "username" 148 "email" 149 'form.button.Register': 'Register',150 'form.submitted': '1'}147 return {"last_visit:date": str(DateTime()), 148 "prev_visit:date": str(DateTime() - 1), 149 "came_from_prefs": "", 150 "fullname": "Tester", 151 "username": "tester", 152 "email": "tester@test.com", 153 'form.button.Register': 'Register', 154 'form.submitted': '1'} 151 155 152 156 … … 158 162 self.portal['index_html'].allowDiscussion(True) 159 163 self.form_url = '/index_html/sendto_form' 160 164 161 165 def getFormData(self): 162 return {'form.submitted' 163 "send_to_address" 164 "send_from_address" 166 return {'form.submitted': '1', 167 "send_to_address": "recipient@test.com", 168 "send_from_address": "sender@test.com", 165 169 'comment': 'Text in Comment', 166 'form.button.Send' : 'Save'} 170 'form.button.Send': 'Save'} 171 167 172 168 173 class TestContactInfo(TestFormMixin): … … 171 176 TestFormMixin.afterSetUp(self) 172 177 # preparation to form correct working 173 self.portal._updateProperty('email_from_address', 'manager@test.com')178 self.portal._updateProperty('email_from_address', 'manager@test.com') 174 179 self.logout() 175 180 self.form_url = '/contact-info' 176 181 177 182 def getFormData(self): 178 return {'form.submitted' 179 "sender_fullname" 180 "sender_from_address" 183 return {'form.submitted': '1', 184 "sender_fullname": "tester", 185 "sender_from_address": "sender@test.com", 181 186 'subject': 'Subject', 182 187 'message': 'Message', 183 'form.button.Send' 188 'form.button.Send': 'Save'} 184 189 185 190 -
quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/tests/testInstallation.py
r3161 r3162 5 5 6 6 from quintagroup.plonecaptchas.config import PRODUCT_NAME 7 7 8 8 9 class TestInstallation(TestCase): … … 18 19 for layer in LAYERS: 19 20 self.assert_(layer.split('/')[0] in self.skins.objectIds(), 20 '%s directory view not found in portal_skins after installation' % layer) 21 '%s directory view not found in portal_skins '\ 22 'after installation' % layer) 21 23 self.assert_(layer in path, 22 24 '%s layer not found in %s' % (PRODUCT_NAME, skin)) … … 31 33 path = map(str.strip, path.split(',')) 32 34 for layer in LAYERS: 33 self.assertTrue(not layer.split('/')[0] in self.skins.objectIds(), 34 '%s directory view found in portal_skins after uninstallation' % layer) 35 self.assertTrue( 36 not layer.split('/')[0] in self.skins.objectIds(), 37 '%s directory view found in portal_skins '\ 38 'after uninstallation' % layer) 35 39 self.assert_(not layer in path, 36 '%s layer found in %s skin after uninstallation' % (layer, skin)) 40 '%s layer found in %s skin '\ 41 'after uninstallation' % (layer, skin)) 42 37 43 38 44 def test_suite(): -
quintagroup.plonecaptchas/trunk/setup.py
r2064 r3162 6 6 setup(name='quintagroup.plonecaptchas', 7 7 version=version, 8 description="quintagroup.plonecaptchas is simple captchas implementation for Plone, designed for validating human input in insecure forms.", 8 description="quintagroup.plonecaptchas is simple captchas " 9 "implementation for Plone, designed for validating " 10 "human input in insecure forms.", 9 11 long_description=open("README.txt").read() + "\n" + 10 12 open(os.path.join("docs", "HISTORY.txt")).read(), 11 # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers12 13 classifiers=[ 13 14 "Framework :: Plone", … … 41 42 target = plone 42 43 """, 43 paster_plugins =["ZopeSkel"],44 paster_plugins=["ZopeSkel"], 44 45 )
Note: See TracChangeset
for help on using the changeset viewer.