Commit e618dc84 authored by Julien Muchembled's avatar Julien Muchembled

New testLegacyDivergenceTester

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@38425 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9fcc4769
......@@ -27,10 +27,10 @@
##############################################################################
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList
from testPackingList import TestPackingListMixin
from Products.ERP5.tests.testPackingList import TestPackingListMixin
class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
"""
......@@ -38,20 +38,26 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
"""
run_all_test = 1
quiet = 0
rule_id = 'default_delivery_simulation_rule'
def getTitle(self):
return "Divergence Tester"
def stepRemoveDivergenceTesters(self, sequence=None,
sequence_list=None, **kw):
def getRule(self):
rule_reference = 'default_delivering_rule'
return self.portal.portal_rules.searchFolder(reference=rule_reference,
validation_state="validated", sort_on='version',
sort_order='descending')[0].getObject()
def afterSetUp(self):
"""
Remove all divergence testers from order_rule.
"""
rule = getattr(self.getPortal().portal_rules, self.rule_id)
rule = self.getRule()
tester_list = rule.contentValues(
portal_type=rule.getPortalDivergenceTesterTypeList())
rule.deleteContent([x.getId() for x in tester_list])
transaction.commit()
self.tic()
def bootstrapSite(self):
"""
......@@ -62,7 +68,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
sequence_list = SequenceList()
# Create a clean packing list
sequence_string = ' \
stepRemoveDivergenceTesters \
stepCreateOrganisation1 \
stepCreateOrganisation2 \
stepCreateOrganisation3 \
......@@ -88,6 +93,8 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
This has to be called only once.
"""
self.validateRules()
transaction.commit()
self.tic(verbose=1)
self.bootstrapSite()
def stepGetPackingList(self, sequence=None, sequence_list=None, **kw):
......@@ -100,7 +107,7 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
packing_list = sql_result[0].getObject()
# XXX Hardcoded id
movement=packing_list['1']
rule = getattr(self.getPortal().portal_rules, self.rule_id)
rule = self.getRule()
sequence.edit(
packing_list=packing_list,
movement=movement,
......@@ -158,8 +165,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
stepSetPreviousQuantity \
stepCheckPackingListIsNotDivergent \
Tic \
stepRemoveDivergenceTesters \
Tic \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=self.quiet)
......@@ -217,8 +222,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
stepSetPreviousSource \
stepCheckPackingListIsNotDivergent \
Tic \
stepRemoveDivergenceTesters \
Tic \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=self.quiet)
......@@ -276,8 +279,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
stepSetPreviousStartDate \
stepCheckPackingListIsNotDivergent \
Tic \
stepRemoveDivergenceTesters \
Tic \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=self.quiet)
......@@ -327,8 +328,6 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase):
stepSetPreviousAggregate \
stepCheckPackingListIsNotDivergent \
Tic \
stepRemoveDivergenceTesters \
Tic \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=self.quiet)
......
# -*- coding: utf-8 -*-
##############################################################################
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Julien Muchembled <jm@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
# It has been decided to have fully duplicated tests in ERP5Legacy, rather that
# monkey-patching everywhere.
# But waiting that we really start fixing testDivergenceTester for new
# simulation, this file can be a virtual copy of testDivergenceTester.py
import sys
from Products.ERP5Legacy.tests import testLegacySimulationPackingList
sys.modules['Products.ERP5.tests.testPackingList'] = testLegacySimulationPackingList
from Products.ERP5.tests.testDivergenceTester import *
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