Commit 8bdb9329 authored by Ivan Tyagov's avatar Ivan Tyagov

Implement tests with real Sale Order / Resource / Supply Line.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28824 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5f3155f0
...@@ -30,7 +30,6 @@ import unittest ...@@ -30,7 +30,6 @@ import unittest
import transaction import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.utils import reindex from Products.ERP5Type.tests.utils import reindex
from DateTime import DateTime from DateTime import DateTime
...@@ -44,7 +43,7 @@ class TestSupplyMixin: ...@@ -44,7 +43,7 @@ class TestSupplyMixin:
""" """
List of needed Business Templates List of needed Business Templates
""" """
return ('erp5_base', 'erp5_pdm', 'erp5_dummy_movement', 'erp5_trade',) return ('erp5_base', 'erp5_pdm', 'erp5_dummy_movement', 'erp5_trade', 'erp5_invoicing')
def afterSetUp(self, quiet=1, run=1): def afterSetUp(self, quiet=1, run=1):
self.login() self.login()
...@@ -58,22 +57,6 @@ class TestSupplyMixin: ...@@ -58,22 +57,6 @@ class TestSupplyMixin:
id='testing_folder') id='testing_folder')
self.folder = self.portal.testing_folder self.folder = self.portal.testing_folder
def changeUser(self, user_id):
"""
Change the current user to user_id
"""
user_folder = self.getPortal().acl_users
user = user_folder.getUserById(user_id).__of__(user_folder)
newSecurityManager(None, user)
def createTestUser(self, **kw):
"""
"""
person = self.portal.person_module.newContent(portal_type="Person", **kw)
person.validate()
class TestSaleSupply(TestSupplyMixin, ERP5TypeTestCase): class TestSaleSupply(TestSupplyMixin, ERP5TypeTestCase):
""" """
Test Supplies usage Test Supplies usage
...@@ -197,35 +180,34 @@ class TestSaleSupply(TestSupplyMixin, ERP5TypeTestCase): ...@@ -197,35 +180,34 @@ class TestSaleSupply(TestSupplyMixin, ERP5TypeTestCase):
def test_03_SupplyLineApplied(self, quiet=0, run=run_all_test): def test_03_SupplyLineApplied(self, quiet=0, run=run_all_test):
""" """
Test supply line being found based on different users and security. Test supply line being found.
XXX: Still incimplete. XXX: This tests fails for second run due to bug #1248.
""" """
if not run: return if not run: return
portal = self.portal portal = self.portal
original_date = DateTime().earliestTime() # lower precision of date original_date = DateTime().earliestTime()
# clean up # clean up
portal.sale_supply_module.manage_delObjects(list(portal.sale_supply_module.objectIds())) portal.sale_supply_module.manage_delObjects(list(portal.sale_supply_module.objectIds()))
portal.person_module.manage_delObjects(list(portal.person_module.objectIds()))
self.stepTic() self.stepTic()
# movement is in middle of timeframe...
movement = self._makeMovement(start_date=original_date)
supply = self._makeSupply(start_date_range_min=original_date) supply = self._makeSupply(start_date_range_min=original_date)
supply_line = self._makeSupplyLine(supply) supply_line = self._makeSupplyLine(supply)
self.stepTic() self.stepTic()
user_reference = "dummy_%s" %self.supply_portal_type[:5] # create Sale Order and check Supply Line settings when
self.createTestUser(reference=user_reference) # a Resource is set on Sale Order Line
product = portal.product_module.newContent(portal_type="Product",
title = "Product 1")
sale_order = portal.sale_order_module.newContent(portal_type = 'Sale Order',
start_date = DateTime())
sale_order_line = sale_order.newContent(portal_type = 'Sale Order Line')
sale_order_line.setResource(product.getRelativeUrl())
self.stepTic() self.stepTic()
self.changeUser(user_reference) supply_line_list = self.domain_tool.searchPredicateList(sale_order,
res = self.domain_tool.searchPredicateList(movement,
portal_type=self.supply_line_portal_type) portal_type=self.supply_line_portal_type)
self.assertSameSet([supply_line], supply_line_list)
# ...and predicate shall NOT be found
self.assertSameSet([], res)
class TestPurchaseSupply(TestSaleSupply): class TestPurchaseSupply(TestSaleSupply):
""" """
......
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