Commit bd8d83fb authored by Łukasz Nowak's avatar Łukasz Nowak

- update copyrights

 - remove not needed run and quiet parameters
 - clean not needed whitespaces
 - remove not needed imports


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28288 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d9bf057b
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2005-2009 Nexedi SA and Contributors. All Rights Reserved.
# Jerome Perrin <jerome@nexedi.com> # Jerome Perrin <jerome@nexedi.com>
# Łukasz Nowak <luke@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsability of assessing all potential
...@@ -33,17 +35,13 @@ from AccessControl.SecurityManagement import newSecurityManager ...@@ -33,17 +35,13 @@ from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.SecurityManagement import getSecurityManager from AccessControl.SecurityManagement import getSecurityManager
from zExceptions import Unauthorized from zExceptions import Unauthorized
from zLOG import LOG
from DateTime import DateTime from DateTime import DateTime
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Form.Document.Preference import Priority from Products.ERP5Form.Document.Preference import Priority
class TestPreferences(ERP5TypeTestCase): class TestPreferences(ERP5TypeTestCase):
quiet = 1
run_all_tests = 1
def getTitle(self): def getTitle(self):
return "Portal Preference" return "Portal Preference"
...@@ -61,7 +59,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -61,7 +59,7 @@ class TestPreferences(ERP5TypeTestCase):
transaction.commit() transaction.commit()
self.tic() self.tic()
def createPreferences(self) : def createPreferences(self):
""" create some preferences objects """ """ create some preferences objects """
portal_preferences = self.getPreferenceTool() portal_preferences = self.getPreferenceTool()
## create initial preferences ## create initial preferences
...@@ -97,21 +95,14 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -97,21 +95,14 @@ class TestPreferences(ERP5TypeTestCase):
""" """
self.assertEquals('Preferences', self.getPreferenceTool().Title()) self.assertEquals('Preferences', self.getPreferenceTool().Title())
def test_AllowedContentTypes(self, quiet=quiet, run=run_all_tests): def test_AllowedContentTypes(self):
"""Tests Preference can be added in Preference Tool. """Tests Preference can be added in Preference Tool.
""" """
if not run: return
if not quiet:
ZopeTestCase._print('\n Test allowed content types')
self.failUnless('Preference' in [x.getId() for x in self.failUnless('Preference' in [x.getId() for x in
self.getPortal().portal_preferences.allowedContentTypes()]) self.getPortal().portal_preferences.allowedContentTypes()])
def test_EnablePreferences(self, quiet=quiet, run=run_all_tests) : def test_EnablePreferences(self):
""" tests preference workflow """ """ tests preference workflow """
if not run: return
if not quiet:
ZopeTestCase._print('\n Test enabling preferences')
portal_workflow = self.getWorkflowTool() portal_workflow = self.getWorkflowTool()
person1 = self.getPreferenceTool()['person1'] person1 = self.getPreferenceTool()['person1']
person2 = self.getPreferenceTool()['person2'] person2 = self.getPreferenceTool()['person2']
...@@ -141,12 +132,8 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -141,12 +132,8 @@ class TestPreferences(ERP5TypeTestCase):
self.assertEquals(group.getPreferenceState(), 'enabled') self.assertEquals(group.getPreferenceState(), 'enabled')
self.assertEquals(site.getPreferenceState(), 'global') self.assertEquals(site.getPreferenceState(), 'global')
def test_GetPreference(self, quiet=quiet, run=run_all_tests): def test_GetPreference(self):
""" checks that getPreference returns the good preferred value""" """ checks that getPreference returns the good preferred value"""
if not run: return
if not quiet:
ZopeTestCase._print('\n Test getPreference')
portal_workflow = self.getWorkflowTool() portal_workflow = self.getWorkflowTool()
pref_tool = self.getPreferenceTool() pref_tool = self.getPreferenceTool()
person1 = self.getPreferenceTool()['person1'] person1 = self.getPreferenceTool()['person1']
...@@ -212,13 +199,9 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -212,13 +199,9 @@ class TestPreferences(ERP5TypeTestCase):
'this_does_not_exists', 'default')) 'this_does_not_exists', 'default'))
def test_GetAttr(self, quiet=quiet, run=run_all_tests) : def test_GetAttr(self):
""" checks that preference methods can be called directly """ checks that preference methods can be called directly
on portal_preferences """ on portal_preferences """
if not run: return
if not quiet:
ZopeTestCase._print('\n Test methods on portal_preference')
portal_workflow = self.getWorkflowTool() portal_workflow = self.getWorkflowTool()
pref_tool = self.getPreferenceTool() pref_tool = self.getPreferenceTool()
person1 = self.getPreferenceTool()['person1'] person1 = self.getPreferenceTool()['person1']
...@@ -251,13 +234,9 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -251,13 +234,9 @@ class TestPreferences(ERP5TypeTestCase):
except AttributeError : except AttributeError :
pass pass
def test_SetPreference(self, quiet=quiet, run=run_all_tests) : def test_SetPreference(self):
""" check setting a preference modifies """ check setting a preference modifies
the first enabled user preference """ the first enabled user preference """
if not run: return
if not quiet:
ZopeTestCase._print('\n Test setting preferences')
portal_workflow = self.getWorkflowTool() portal_workflow = self.getWorkflowTool()
pref_tool = self.getPreferenceTool() pref_tool = self.getPreferenceTool()
person1 = self.getPreferenceTool()['person1'] person1 = self.getPreferenceTool()['person1']
...@@ -276,13 +255,8 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -276,13 +255,8 @@ class TestPreferences(ERP5TypeTestCase):
person1.getPreferredAccountingTransactionAtDate(), person1.getPreferredAccountingTransactionAtDate(),
DateTime(2004, 12, 31)) DateTime(2004, 12, 31))
def test_UserIndependance(self, quiet=quiet, run=run_all_tests) : def test_UserIndependance(self):
""" check that the preferences are related to the user. """ """ check that the preferences are related to the user. """
if not run: return
if not quiet:
ZopeTestCase._print(
'\n Test different users preferences are independants')
portal_workflow = self.getWorkflowTool() portal_workflow = self.getWorkflowTool()
portal_preferences = self.getPreferenceTool() portal_preferences = self.getPreferenceTool()
# create 2 users: user_a and user_b # create 2 users: user_a and user_b
...@@ -485,8 +459,6 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -485,8 +459,6 @@ class TestPreferences(ERP5TypeTestCase):
except ImportError: except ImportError:
self.assertRaises(Unauthorized, user_pref.edit, preferred_ooodoc_server_address="localhost") self.assertRaises(Unauthorized, user_pref.edit, preferred_ooodoc_server_address="localhost")
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPreferences)) suite.addTest(unittest.makeSuite(TestPreferences))
......
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