Commit 9799d77b authored by Jérome Perrin's avatar Jérome Perrin

test: don't depend on the order of dict iteration

parent 625eb2cc
...@@ -1180,8 +1180,11 @@ class TestCaptchaField(ERP5TypeTestCase): ...@@ -1180,8 +1180,11 @@ class TestCaptchaField(ERP5TypeTestCase):
def test_numeric_good_captcha(self): def test_numeric_good_captcha(self):
self.field.values['captcha_type'] = 'numeric' self.field.values['captcha_type'] = 'numeric'
def random_choice(seq):
self.assertIn('+', seq)
return '+'
with mock.patch('Products.ERP5Form.CaptchaField.random.randint', return_value=1), \ with mock.patch('Products.ERP5Form.CaptchaField.random.randint', return_value=1), \
mock.patch('Products.ERP5Form.CaptchaField.random.choice', side_effect=lambda seq: seq[0]): mock.patch('Products.ERP5Form.CaptchaField.random.choice', side_effect=random_choice):
field_html = self.field.render(REQUEST=self.portal.REQUEST) field_html = self.field.render(REQUEST=self.portal.REQUEST)
self.assertIn('1 plus 1', field_html) self.assertIn('1 plus 1', field_html)
self.assertIn(hashlib.md5(b'1 + 1').hexdigest(), field_html) self.assertIn(hashlib.md5(b'1 + 1').hexdigest(), field_html)
...@@ -1197,8 +1200,11 @@ class TestCaptchaField(ERP5TypeTestCase): ...@@ -1197,8 +1200,11 @@ class TestCaptchaField(ERP5TypeTestCase):
def test_numeric_bad_captcha(self): def test_numeric_bad_captcha(self):
self.field.values['captcha_type'] = 'numeric' self.field.values['captcha_type'] = 'numeric'
def random_choice(seq):
self.assertIn('+', seq)
return '+'
with mock.patch('Products.ERP5Form.CaptchaField.random.randint', return_value=1), \ with mock.patch('Products.ERP5Form.CaptchaField.random.randint', return_value=1), \
mock.patch('Products.ERP5Form.CaptchaField.random.choice', side_effect=lambda seq: seq[0]): mock.patch('Products.ERP5Form.CaptchaField.random.choice', side_effect=random_choice):
self.field.render(REQUEST=self.portal.REQUEST) self.field.render(REQUEST=self.portal.REQUEST)
self.assertRaises( self.assertRaises(
ValidationError, self.validator.validate, self.field, 'field_test', { ValidationError, self.validator.validate, self.field, 'field_test', {
......
import json import json
return ['test report %s' % json.dumps(kw)] return ['test report %s' % json.dumps(kw, sort_keys=True)]
...@@ -206,11 +206,11 @@ class TestCorporateIdentityMethod(ERP5TypeTestCase): ...@@ -206,11 +206,11 @@ class TestCorporateIdentityMethod(ERP5TypeTestCase):
# it has no matter with/without follow up # it has no matter with/without follow up
doc_content = '<div> <a href="sale_opportunity_module/template_test_embed_sale_opportunity?report=Base_generateCorporareIdentityTestReport&amp;test=23"></a> </div>' doc_content = '<div> <a href="sale_opportunity_module/template_test_embed_sale_opportunity?report=Base_generateCorporareIdentityTestReport&amp;test=23"></a> </div>'
output =web_page_with_follow_up.WebPage_embedReportDocumentList(doc_content) output =web_page_with_follow_up.WebPage_embedReportDocumentList(doc_content)
self.assertEqual(output, '<div> test report {"test": "23", "document_language": null, "format": null} </div>') self.assertEqual(output, '<div> test report {"document_language": null, "format": null, "test": "23"} </div>')
doc_content = '<div> <a href="sale_opportunity_module/template_test_embed_sale_opportunity?report=Base_generateCorporareIdentityTestReport&amp;test=23"></a> </div>' doc_content = '<div> <a href="sale_opportunity_module/template_test_embed_sale_opportunity?report=Base_generateCorporareIdentityTestReport&amp;test=23"></a> </div>'
output =web_page_no_follow_up.WebPage_embedReportDocumentList(doc_content) output =web_page_no_follow_up.WebPage_embedReportDocumentList(doc_content)
self.assertEqual(output, '<div> test report {"test": "23", "document_language": null, "format": null} </div>') self.assertEqual(output, '<div> test report {"document_language": null, "format": null, "test": "23"} </div>')
def test_getTemplateProxyParameter_override_person(self): def test_getTemplateProxyParameter_override_person(self):
output_dict_list = self.test_person.Base_getTemplateProxyParameter( output_dict_list = self.test_person.Base_getTemplateProxyParameter(
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
# #
############################################################################## ##############################################################################
import six.moves.urllib.parse
import uuid import uuid
import mock import mock
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
...@@ -92,11 +93,15 @@ class TestFacebookLogin(ERP5TypeTestCase): ...@@ -92,11 +93,15 @@ class TestFacebookLogin(ERP5TypeTestCase):
self.logout() self.logout()
self.portal.ERP5Site_redirectToFacebookLoginPage() self.portal.ERP5Site_redirectToFacebookLoginPage()
location = self.portal.REQUEST.RESPONSE.getHeader("Location") location = self.portal.REQUEST.RESPONSE.getHeader("Location")
self.assertIn("https://www.facebook.com/v2.10/dialog/oauth?", location)
self.assertIn("scope=email&redirect_uri=", location)
self.assertIn("client_id=%s" % CLIENT_ID, location)
self.assertNotIn("secret_key=", location)
self.assertIn("ERP5Site_callbackFacebookLogin", location) self.assertIn("ERP5Site_callbackFacebookLogin", location)
parsed_location = six.moves.urllib.parse.urlparse(location)
self.assertEqual(parsed_location.hostname, 'www.facebook.com')
self.assertEqual(parsed_location.path, '/v2.10/dialog/oauth')
params = dict(six.moves.urllib.parse.parse_qsl(parsed_location.query))
self.assertEqual(params['scope'], 'email')
self.assertEqual(params['client_id'], CLIENT_ID)
self.assertIn("redirect_uri", params)
self.assertNotIn("secret_key", params)
def test_existing_user(self): def test_existing_user(self):
self.login() self.login()
......
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: \' \'.join(here.getCategoryList())</string> </value> <value> <string>python: \' \'.join(sorted(here.getCategoryList()))</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -85,7 +85,12 @@ ...@@ -85,7 +85,12 @@
</tr> </tr>
<tr> <tr>
<td>assertLocation</td> <td>assertLocation</td>
<td>regexp:${base_url}/web_site_module/test_web_site/web_page_module/[^/]+(/view)+\?portal_status_message=Created%20Clone%20Web%20Page.&amp;editable_mode:int=1</td> <td>regexp:${base_url}/web_site_module/test_web_site/web_page_module/[^/]+(/view)+\?.*portal_status_message=Created%20Clone%20Web%20Page.</td>
<td></td>
</tr>
<tr>
<td>assertLocation</td>
<td>regexp:${base_url}/web_site_module/test_web_site/web_page_module/[^/]+(/view)+\?.*editable_mode:int=1</td>
<td></td> <td></td>
</tr> </tr>
</tbody></table> </tbody></table>
......
...@@ -1507,7 +1507,7 @@ class TestIngestion(IngestionTestCase): ...@@ -1507,7 +1507,7 @@ class TestIngestion(IngestionTestCase):
self.assertEqual(['anybody'], document.getGroupList()) self.assertEqual(['anybody'], document.getGroupList())
document.discoverMetadata(document.getFilename(), other_user.Person_getUserId()) document.discoverMetadata(document.getFilename(), other_user.Person_getUserId())
self.assertEqual(['anybody/a1', 'anybody/a2'], document.getGroupList()) self.assertEqual(sorted(document.getGroupList()), ['anybody/a1', 'anybody/a2'])
def test_IngestionConfigurationByTypeBasedMethod_usecase1(self): def test_IngestionConfigurationByTypeBasedMethod_usecase1(self):
"""How to configure meta data discovery so that each time a file """How to configure meta data discovery so that each time a file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment