Commit 76762b21 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

test: use appropriate user to invoke workflow transitions.

parent 2f888e0b
......@@ -480,7 +480,7 @@ class TestAdvancedSaleInvoice(TestAdvancedInvoice):
collect_order_group='delivery',
int_index=len(delivery_movement_group_list)+1
)
user = uf.getUserById('test_invoice_user').__of__(uf)
user = uf.getUserById('test_user').__of__(uf)
newSecurityManager(None, user)
def test_01_TwoInvoicesFromTwoPackingList(self, quiet=quiet, run=RUN_ALL_TESTS):
......
......@@ -30,6 +30,7 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from testOrder import TestOrderMixin
class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase):
......@@ -48,6 +49,10 @@ class TestApparelTransformation(TestOrderMixin, ERP5TypeTestCase):
transformed_resource_portal_type = 'Transformation Transformed Resource'
operation_portal_type = 'Transformation Operation'
def afterSetUp(self, quiet=1, run=1):
super(TestApparelTransformation, self).afterSetUp()
self.login()
def getTitle(self):
return "Transformation"
......
......@@ -30,6 +30,7 @@ import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import Sequence
from Products.ERP5.tests.testPackingList import TestPackingListMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
"""
......@@ -62,6 +63,7 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
portal_rules.deleteContent(rule_id_list)
self.tic()
@UnrestrictedMethod
def stepResetDeliveringRule(self, sequence):
original_rule = rule = self.getDeliveringRule()
self.assertEqual(rule.getId(), 'new_delivery_simulation_rule')
......@@ -125,6 +127,7 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
self.assertNotEqual(prevision, decision)
movement.setQuantity(decision)
@UnrestrictedMethod
def _addDivergenceTester(self, sequence, tester_type, tester_name, **kw):
"""
Add a divergence tester to the rule
......
......@@ -41,6 +41,7 @@ class TestERP5Simulation(TestPackingListMixin, ERP5TypeTestCase):
def afterSetUp(self):
super(TestERP5Simulation, self).afterSetUp()
self.login('manager')
self.portal.portal_rules.new_delivery_simulation_rule.quantity_tester.edit(
quantity_range_max=2,
quantity_range_min=-1)
......
......@@ -31,6 +31,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from DateTime import DateTime
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testOrder import TestOrderMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
"""
......@@ -125,6 +126,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
sequence.edit(inventory_list=inventory_list)
return inventory
@UnrestrictedMethod
def createNotVariatedInventoryLine(self, quantity=None,
sequence=None,**kw):
"""
......@@ -161,6 +163,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
quantity=quantity)
@UnrestrictedMethod
def stepModifySecondNotVariatedInventory(self, sequence=None,
sequence_list=None, **kw):
"""
......@@ -232,6 +235,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
sequence_list.play(self)
@UnrestrictedMethod
def createVariatedInventoryLine(self, sequence=None, sequence_list=None,
start_date=None, quantity=None, item_list=None,
**kw):
......@@ -287,6 +291,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
self.createVariatedInventoryLine(start_date=date,
sequence=sequence, quantity=quantity)
@UnrestrictedMethod
def createVariatedInventory(self, start_date=None,quantity=None,
sequence=None,**kw):
"""
......
......@@ -124,15 +124,20 @@ class TestInvoiceMixin(TestPackingListMixin):
'use/trade/tax',
)
def afterSetUp(self):
self.createUser('test_user',
['Assignee', 'Assignor', 'Member',
'Associate', 'Auditor', 'Author'])
self.createUser('manager', ['Manager'])
self.login('manager')
self.createCategories()
self.validateRules()
self.createBusinessProcess()
self.login()
self.login('test_user')
def beforeTearDown(self):
self.abort()
self.login('manager')
super(TestInvoiceMixin, self).beforeTearDown()
for folder in (self.portal.accounting_module,
self.portal.organisation_module,
......@@ -144,14 +149,6 @@ class TestInvoiceMixin(TestPackingListMixin):
folder.manage_delObjects([x for x in folder.objectIds() if x not in ('organisation_1','organisation_2','ppl_1','ppl_2')])
self.tic()
def login(self):
"""login, without manager role"""
uf = self.getPortal().acl_users
uf._doAddUser('test_invoice_user', '', ['Assignee', 'Assignor', 'Member',
'Associate', 'Auditor', 'Author'], [])
user = uf.getUserById('test_invoice_user').__of__(uf)
newSecurityManager(None, user)
def stepCreateSaleInvoiceTransactionRule(self, sequence, **kw) :
pass # see createBusinessProcess
......@@ -183,7 +180,7 @@ class TestInvoiceMixin(TestPackingListMixin):
if not account_module.has_key(account_id):
account = account_module.newContent(account_id, gap=account_gap,
account_type=account_type)
portal.portal_workflow.doActionFor(account, 'validate_action')
account.validate()
for line_id, line_source_id, line_destination_id, line_ratio in \
self.transaction_line_definition_list:
trade_model_path = business_process.newContent(
......@@ -2546,9 +2543,6 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase):
"""
quiet = 0
# fix inheritance
login = TestInvoiceMixin.login
@UnrestrictedMethod
def createCategories(self):
TestPackingListMixin.createCategories(self)
......
......@@ -35,7 +35,7 @@ from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5.tests.testInvoice import TestSaleInvoiceMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
class TestItemMixin(TestSaleInvoiceMixin):
item_portal_type = 'Item'
......@@ -52,12 +52,6 @@ class TestItemMixin(TestSaleInvoiceMixin):
return TestSaleInvoiceMixin.getBusinessTemplateList(self) + \
('erp5_item',) + ('erp5_trade_proxy_field_legacy',)
def login(self):
uf = self.getPortal().acl_users
uf._doAddUser('rc', '', ['Manager', 'Member', 'Assignee'], [])
user = uf.getUserById('rc').__of__(uf)
newSecurityManager(None, user)
def createOrganisation(self, title=None):
organisation_portal_type = 'Organisation'
organisation_module = self.portal.getDefaultModule(
......@@ -222,6 +216,7 @@ class TestItemMixin(TestSaleInvoiceMixin):
self.assertEqual(packing_list.getStartDate(),self.datetime+15)
@UnrestrictedMethod
def stepModifyOrderLinesQuantity(self,sequence=None, sequence_list=None, **kw):
"""
modify order line quantities
......@@ -231,6 +226,7 @@ class TestItemMixin(TestSaleInvoiceMixin):
for order_line in order_line_list:
order_line.edit(quantity=self.default_quantity-1)
@UnrestrictedMethod
def stepModifyOneOrderLineStartDate(self,sequence=None, sequence_list=None, **kw):
"""
modify order line start date
......@@ -242,6 +238,7 @@ class TestItemMixin(TestSaleInvoiceMixin):
order_line_list[-1].edit(start_date=self.datetime+15)
@UnrestrictedMethod
def stepModifyOrderLinesDate(self,sequence=None, sequence_list=None, **kw):
"""
modify order line date
......
......@@ -73,6 +73,7 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
def test_01_get_document(self):
module = self.getNotificationMessageModule()
tool = self.getPortal().portal_notifications
self.login('manager')
#Test Document A in english
n_m_en = module.newContent(portal_type='Notification Message',
reference='A',
......
......@@ -119,7 +119,7 @@ class TestNotificationTool(ERP5TypeTestCase):
newSecurityManager(None, self.old_user)
def afterSetUp(self):
self.createUser('erp5user', ['Auditor', 'Author'])
self.createUser('erp5user', ['Associate', 'Auditor', 'Author'])
self.createUser('manager', ['Manager'])
portal = self.getPortal()
if 'MailHost' in portal.objectIds():
......@@ -134,6 +134,7 @@ class TestNotificationTool(ERP5TypeTestCase):
def beforeTearDown(self):
self.abort()
# clear modules if necessary
self.login('manager')
self.portal.person_module.manage_delObjects(
list(self.portal.person_module.objectIds()))
self.tic()
......
......@@ -38,6 +38,7 @@ from AccessControl.SecurityManagement import newSecurityManager
from DateTime import DateTime
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.CMFCore.utils import getToolByName
class TestOrderMixin(SubcontentReindexingWrapper):
......@@ -69,12 +70,6 @@ class TestOrderMixin(SubcontentReindexingWrapper):
'erp5_configurator_standard_trade_template',
'erp5_simulation_test', 'erp5_administration')
def login(self, quiet=0, run=1):
uf = self.getPortal().acl_users
uf._doAddUser('rc', '', ['Manager', 'Member', 'Assignee'], [])
user = uf.getUserById('rc').__of__(uf)
newSecurityManager(None, user)
def setUpPreferences(self):
#create apparel variation preferences
portal_preferences = self.getPreferenceTool()
......@@ -95,13 +90,21 @@ class TestOrderMixin(SubcontentReindexingWrapper):
preference.enable()
self.tic()
def createUser(self, name, role_list):
user_folder = self.getPortal().acl_users
user_folder._doAddUser(name, 'password', role_list, [])
def afterSetUp(self):
# XXX-Leo: cannot call super here, because other classes call
# SuperClass.afterSetUp(self) directly... this needs to be cleaned
# up, including consolidating all conflicting definitions of
# .createCategories()
#super(TestOrderMixin, self).afterSetUp()
self.login()
self.createUser('test_user',
['Assignee', 'Assignor', 'Member',
'Associate', 'Auditor', 'Author'])
self.createUser('manager', ['Manager'])
self.login('manager')
self.category_tool = self.getCategoryTool()
portal_catalog = self.getCatalogTool()
#portal_catalog.manage_catalogClear()
......@@ -113,6 +116,7 @@ class TestOrderMixin(SubcontentReindexingWrapper):
# 1. All calculations are done relative to the same time
# 2. We don't get random failures when tests run close to midnight
self.pinDateTime(self.datetime)
self.login('test_user')
def beforeTearDown(self):
self.unpinDateTime()
......@@ -231,6 +235,7 @@ class TestOrderMixin(SubcontentReindexingWrapper):
resource_list.append(resource)
sequence.edit( resource_list = resource_list )
@UnrestrictedMethod
def stepCreateVariatedMultipleQuantityUnitResource(self, sequence=None, sequence_list=None, **kw):
"""
Create a resource with variation and multiple quantity units
......
......@@ -240,6 +240,7 @@ class TestPackingListMixin(TestOrderMixin):
packing_list = sequence.get('packing_list')
self.assertFalse(packing_list.isDivergent())
@UnrestrictedMethod
def stepChangeOrderLineResource(self, sequence=None,
sequence_list=None, **kw):
"""
......@@ -262,6 +263,7 @@ class TestPackingListMixin(TestOrderMixin):
portal_type=self.packing_list_line_portal_type):
packing_list_line.edit(resource_value=resource)
@UnrestrictedMethod
def stepDecreaseOrderLineQuantity(self, sequence=None, sequence_list=None,
**kw):
"""
......@@ -704,6 +706,7 @@ class TestPackingListMixin(TestOrderMixin):
packing_list = sequence.get('packing_list')
self._solveDivergence(packing_list, 'quantity', 'Adopt Solver')
@UnrestrictedMethod
def _solveDivergence(self, document, property, solver, **kw):
"""Solve divergence by using solver tool"""
solver_process_tool = self.portal.portal_solver_processes
......@@ -1851,6 +1854,7 @@ class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase):
solver_process_type_info.getTypeAllowedContentTypeList()
self.added_target_solver_list = []
@UnrestrictedMethod
def beforeTearDown(self, quiet=1, run=1):
super(TestSolvingPackingList, self).beforeTearDown()
self.portal.portal_rules.new_delivery_simulation_rule.quantity_tester.edit(
......@@ -1886,18 +1890,21 @@ class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase):
self.portal.portal_caches.clearAllCache()
self.added_target_solver_list.append(solver_id)
@UnrestrictedMethod
def stepSetUpAutomaticQuantityAcceptSolver(self, sequence=None, sequence_list=None):
self._setUpTargetSolver('Automatic Quantity Accept Solver',
'AcceptSolver', ('quantity',))
self.portal.portal_rules.new_delivery_simulation_rule.quantity_tester.edit(
solver=('portal_solvers/Automatic Quantity Accept Solver',))
@UnrestrictedMethod
def stepSetUpAutomaticQuantityAdoptSolver(self, sequence=None, sequence_list=None):
self._setUpTargetSolver('Automatic Quantity Adopt Solver',
'AdoptSolver', ('quantity',))
self.portal.portal_rules.new_delivery_simulation_rule.quantity_tester.edit(
solver=('portal_solvers/Automatic Quantity Adopt Solver',))
@UnrestrictedMethod
def stepSetUpMovementSplitSolver(self, sequence=None, sequence_list=None):
self._setUpTargetSolver('Movement Split Solver',
'MovementSplitSolver', ())
......
......@@ -83,7 +83,9 @@ class TestProductionOrderMixin(TestOrderMixin):
def afterSetUp(self):
TestOrderMixin.afterSetUp(self)
self.login('manager')
self.setUpPreferences()
self.login('test_user')
def createCategories(self):
"""
......
......@@ -547,6 +547,7 @@ class TestTask(TestTaskMixin, ERP5TypeTestCase):
run_all_test = 1
def afterSetUp(self):
self.stepLogin()
self.validateRules()
self.tic()
......
......@@ -158,7 +158,9 @@ class TestTaskReportDivergence(TestTaskReportDivergenceMixin, ERP5TypeTestCase)
quiet = 0
def afterSetUp(self):
self.stepLogin()
self.validateRules()
self.tic()
def enableLightInstall(self):
"""
......
......@@ -1876,8 +1876,10 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
# by searchFolder.
# This will work as long as Bank Account are associated to a workflow that
# allow deletion.
self.login()
obj2.delete()
self.tic()
self.login('bob')
self.assertEqual([], [x.getObject() for x in
obj.searchFolder(portal_type='Bank Account')])
......
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