Index: quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/tests/testQSEOptimizer.py
===================================================================
--- quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/tests/testQSEOptimizer.py	(revision 1458)
+++ quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/tests/testQSEOptimizer.py	(revision 1475)
@@ -2,4 +2,5 @@
 import string
 import urllib
+from cStringIO import StringIO
 from zope.component import getMultiAdapter
 from Products.Five import zcml, fiveconfigure
@@ -167,29 +168,35 @@
         self.qi = self.portal.portal_quickinstaller
         self.qi.installProduct(PRODUCT)
-        #self.portal.changeSkin('Plone Default')
-
-        self.basic_auth = 'mgr:mgrpw'
-        self.loginAsPortalOwner()
+        self.sp = self.portal.portal_properties.seo_properties
+        self.pu = self.portal.plone_utils
+        self.basic_auth = 'portal_manager:secret'
+
+        uf = self.app.acl_users
+        uf.userFolderAddUser('portal_manager', 'secret', ['Manager'], [])
+        user = uf.getUserById('portal_manager')
+        if not hasattr(user, 'aq_base'):
+            user = user.__of__(uf)
+        newSecurityManager(None, user)
 
         '''Preparation for functional testing'''
         my_doc = self.portal.invokeFactory('Document', id='my_doc')
         my_doc = self.portal['my_doc']
-        self.canonurl = 'http://test.site.com/test.html'
-        self.sp = self.portal.portal_properties.seo_properties
+        self.canonurl = 'http://nohost/plone/test.html'
         self.sp.manage_changeProperties(**global_custom_metatags)
-
-        my_doc.qseo_properties_edit(title='hello world', title_override=1,
-                                    description='it is description', description_override=1,
-                                    keywords='my1|key2', keywords_override=1,
-                                    html_comment='no comments', html_comment_override=1,
-                                    robots='ALL', robots_override=1,
-                                    distribution='Global', distribution_override=1,
-                                    canonical=self.canonurl, canonical_override=1,
-                                    custommetatags=custom_metatags, custommetatags_override=1)
+        abs_path = "/%s" % my_doc.absolute_url(1)
+        self.form_data = {'seo_description': 'it is description', 'seo_keywords_override:int': 1, 'seo_custommetatags_override:int': 1,
+                        'seo_robots_override:int': 1, 'seo_robots': 'ALL', 'seo_description_override:int': 1, 'seo_canonical_override:int': 1,
+                        'seo_keywords:list': 'keyword1', 'seo_html_comment': 'no comments',
+                        'seo_title_override:int': 1, 'seo_title': 'hello world', 'seo_html_comment_override:int': 1,
+                        'seo_distribution_override:int': 1, 'seo_distribution': 'Global', 'seo_canonical': self.canonurl, 'form.submitted:int': 1}
+        st = ''
+        for d in custom_metatags:
+            st += '&seo_custommetatags.meta_name:records=%s&seo_custommetatags.meta_content:records=%s' % (d['meta_name'],d['meta_content'])
+        self.publish(path=abs_path+'/@@seo-context-properties', basic=self.basic_auth, request_method='POST', stdin=StringIO(urllib.urlencode(self.form_data)+st))
+        #self.publish(abs_path+'/@@seo-context-properties?%s' % urllib.urlencode(self.form_data), self.basic_auth)
 
         wf_tool = self.portal.portal_workflow
         wf_tool.doActionFor(my_doc, 'publish')
 
-        abs_path = "/%s" % my_doc.absolute_url(1)
         self.abs_path = abs_path
         self.my_doc = my_doc
@@ -222,7 +229,7 @@
 
     def testKeywords(self):
-        m = re.match('.*<meta name="keywords" content="my1|key2" />', self.html, re.S|re.M)
-        if not m:
-             m = re.match('.*<meta content="my1|key2" name="keywords" />', self.html, re.S|re.M)
+        m = re.match('.*<meta name="keywords" content="keyword1" />', self.html, re.S|re.M)
+        if not m:
+             m = re.match('.*<meta content="keyword1" name="keywords" />', self.html, re.S|re.M)
         self.assert_(m, 'Keywords not set in')
 
@@ -281,5 +288,6 @@
         self.sp.manage_changeProperties(**{'default_custom_metatags':'metatag1|global_metatag1value'})
         my_doc = self.my_doc
-        my_doc.qseo_properties_edit(custommetatags=custom_metatags, custommetatags_override=0)
+        self.form_data = {'seo_custommetatags': custom_metatags,  'seo_custommetatags_override:int': 0, 'form.submitted:int': 1}
+        self.publish(path=self.abs_path+'/@@seo-context-properties', basic=self.basic_auth, request_method='POST', stdin=StringIO(urllib.urlencode(self.form_data)))
         html = self.publish(self.abs_path, self.basic_auth).getBody()
         m = re.search('<meta name="metatag4" content="global_metatag4value" />' , html, re.S|re.M)
@@ -290,5 +298,5 @@
         if not m:
             m = re.search('<meta content="global_metatag1value" name="metatag1" />' , html, re.S|re.M)
-        self.assert_(m, "Global custom meta tag %s is prosent in the page." % 'metatag4')
+        self.assert_(m, "Global custom meta tag %s not applied." % 'metatag1')
 
     def testCanonical(self):
@@ -317,5 +325,4 @@
         self.sp = self.portal.portal_properties.seo_properties
         self.pu = self.portal.plone_utils
-        #self.portal.changeSkin('Plone Default')
 
         self.basic_auth = 'portal_manager:secret'
@@ -387,7 +394,5 @@
         self.my_doc.manage_addProperty('qSEO_keywords', ('baz',), 'lines')
         self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth))
-        m = re.match('.*<meta\ content="baz,\ foo,\ bar"\ name="keywords"\ />', self.html, re.S|re.M)
-        if not m:
-            m = re.match('.*<meta\ name="keywords"\ content="baz,\ foo,\ bar"\ />', self.html, re.S|re.M)
+        m = re.findall('.*(<meta\s+(?:content="(?:(?:baz|bar|foo),\s*(?:baz|foo|bar),\s*(?:baz|foo|bar)"\s*)|(?:name="keywords"\s*)){2}/>)', self.html, re.S|re.M)
         self.assert_(m, "No 'foo, bar, baz' keyword find")
 
@@ -399,6 +404,4 @@
         self.sp = self.portal.portal_properties.site_properties
         self.qi.installProduct(PRODUCT)
-        #self.portal.changeSkin('Plone Default')
-
         self.basic_auth = 'portal_manager:secret'
         uf = self.app.acl_users
@@ -424,6 +427,4 @@
     def test_exposeDCMetaTagsPropertyOff(self):
         self.sp.manage_changeProperties(exposeDCMetaTags = False)
-
-        self.my_doc.qseo_properties_edit()
         self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth))
         m1 = re.match('.*<meta\ name="DC.format"\ content=".*?"\ />', self.html, re.S|re.M)
@@ -438,5 +439,4 @@
     def test_exposeDCMetaTagsPropertyOn(self):
         self.sp.manage_changeProperties(exposeDCMetaTags = True)
-        self.my_doc.qseo_properties_edit()
         self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth))
         m1 = re.match('.*<meta\ content=".*?"\ name="DC.format"\ />', self.html, re.S|re.M)
@@ -522,9 +522,9 @@
         my_doc = self.portal['my_doc']
         regen = re.compile('<base\s+[^>]*href=\"([^\"]*)\"[^>]*>', re.S|re.M)
-        
+
         path = "/%s" % my_doc.absolute_url(1)
         html = self.publish(path, self.basic_auth).getBody()
         burls = regen.findall(html)
-        
+
         mydocurl = my_doc.absolute_url()
         self.assert_(not [1 for burl in burls if not burl==mydocurl],
@@ -566,10 +566,11 @@
 
         md_before = my_doc.modification_date
-        my_doc.qseo_properties_edit(title="New Title")
+        abs_path = "/%s" % my_doc.absolute_url(1)
+        form_data = {'seo_title': 'New Title',  'seo_title_override:int': 1, 'form.submitted:int': 1}
+        self.publish(path=abs_path+'/@@seo-context-properties', basic=self.basic_auth, request_method='POST', stdin=StringIO(urllib.urlencode(form_data)))
         md_after = my_doc.modification_date
-
         self.assertNotEqual(md_before, md_after)
 
-        
+
 TESTS = [TestBeforeInstall,
          TestInstallation,
