source: products/quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/tests/testMetaTagsDuplication.py @ 1877

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

Remove config module from tests, move all constants into testInstallation and testResponce modules

File size: 2.6 KB
Line 
1import re
2from base import *
3
4class TestMetaTagsDuplication(FunctionalTestCase):
5
6    def afterSetUp(self):
7        self.qi = self.portal.portal_quickinstaller
8        self.qi = self.qi.uninstallProducts([PROJECT_NAME])
9
10        self.basic_auth = 'portal_manager:secret'
11        uf = self.app.acl_users
12        uf.userFolderAddUser('portal_manager', 'secret', ['Manager'], [])
13        user = uf.getUserById('portal_manager')
14        if not hasattr(user, 'aq_base'):
15            user = user.__of__(uf)
16        newSecurityManager(None, user)
17
18        '''Preparation for functional testing'''
19        self.my_doc = self.portal.invokeFactory('Document', id='my_doc')
20        self.my_doc = self.portal['my_doc']
21        self.my_doc.update(description="Document description")
22
23    def test_GeneratorMeta(self):
24        # Get document without customized canonical url
25        abs_path = "/%s" % self.my_doc.absolute_url(1)
26
27        # Before product installation
28        self.html = self.publish(abs_path, self.basic_auth).getBody()
29        f = re.findall('.*(<meta\s+(?:(?:name="generator"\s*)|(?:content=".*?"\s*)){2}/>)', self.html, re.S|re.M)
30        lengen = len(f)
31        self.assert_(lengen==1, "There is %d generator meta tag(s) " \
32           "before seoptimizer installation" % lengen)
33
34#         # After PROJECT_NAME installation
35#         self.qi.installProduct(PROJECT_NAME)
36#         html = self.publish(abs_path, self.basic_auth).getBody()
37#         lengen = len(regen.findall(html))
38#         self.assert_(lengen==1, "There is %d generator meta tag(s) " \
39#            "after seoptimizer installation" % lengen)
40
41    def test_DescriptionMeta(self):
42        # Get document without customized canonical url
43        abs_path = "/%s" % self.my_doc.absolute_url(1)
44
45        # Before product installation
46        self.html = self.publish(abs_path, self.basic_auth).getBody()
47        f = re.findall('.*(<meta\s+(?:(?:name="description"\s*)|(?:content=".*?"\s*)){2}/>)', self.html, re.S|re.M)
48        lendesc = len(f)
49        self.assert_(lendesc==1, "There is %d DESCRIPTION meta tag(s) " \
50           "before seoptimizer installation" % lendesc)
51
52#         # After PROJECT_NAME installation
53#         self.qi.installProduct(PROJECT_NAME)
54#         html = self.publish(abs_path, self.basic_auth).getBody()
55#         lendesc = len(regen.findall(html))
56#         self.assert_(lendesc==1, "There is %d DESCRIPTION meta tag(s) " \
57#            "after seoptimizer installation" % lendesc)
58def test_suite():
59    from unittest import TestSuite, makeSuite
60    suite = TestSuite()
61    suite.addTest(makeSuite(TestMetaTagsDuplication))
62    return suite
Note: See TracBrowser for help on using the repository browser.