Commit 035530d4 authored by Arnaud Fontaine's avatar Arnaud Fontaine

simulation: Define getTestedProperty() on mixin rather than subclasses.

This makes more sense as all Tester inherits from EquivalenceTesterMixin,
even project-specific EquivalenceTester classes.

Followup of: "simulation: improve equivalence testers explanations messages".
parent b0ff7ee6
......@@ -102,8 +102,3 @@ class CategoryMembershipEquivalenceTester(Predicate, EquivalenceTesterMixin):
decision_value=self.getTestedPropertyText(
decision_movement, tested_property)))
return None
# Temporary compatibility code that will fix existing data.
# This Code must be removed in 2 years (end of 2017)
from Products.ERP5.Document.StringEquivalenceTester import getTestedProperty
CategoryMembershipEquivalenceTester.getTestedProperty = getTestedProperty
......@@ -107,8 +107,3 @@ class DateTimeEquivalenceTester(Predicate, EquivalenceTesterMixin):
raise SimulationError(
"%r: Either Absolute Tolerance, Absolute Tolerance (Min) or Absolute Tolerance"
"(Max) *must* be defined on a DateTime Divergence Tester" % self)
# Temporary compatibility code that will fix existing data.
# This Code must be removed in 2 years (end of 2017)
from Products.ERP5.Document.StringEquivalenceTester import getTestedProperty
DateTimeEquivalenceTester.getTestedProperty = getTestedProperty
......@@ -215,8 +215,3 @@ class FloatEquivalenceTester(Predicate, EquivalenceTesterMixin):
# converted to Decimals everywhere, then the float() call should
# go away
return float(result)
# Temporary compatibility code that will fix existing data.
# This Code must be removed in 2 years (end of 2017)
from Products.ERP5.Document.StringEquivalenceTester import getTestedProperty
FloatEquivalenceTester.getTestedProperty = getTestedProperty
......@@ -84,20 +84,3 @@ class StringEquivalenceTester(Predicate, EquivalenceTesterMixin):
decision_value=decision_value,
prevision_value=prevision_value))
return None
# Temporary compatibility code that will fix existing data.
# This Code must be removed in 2 years (end of 2017)
def getTestedProperty(self):
"""
Override getTestedProperty to fix the way it is stored. Some time
ago it was multi-valued, which is non-sense we the implementation we
have on this equivalence tester.
"""
tested_property = getattr(self, 'tested_property', None)
if tested_property != None:
if isinstance(tested_property, tuple):
if len(tested_property) == 1:
setattr(self, 'tested_property', tested_property[0])
return self._baseGetTestedProperty()
StringEquivalenceTester.getTestedProperty = getTestedProperty
......@@ -215,3 +215,18 @@ class EquivalenceTesterMixin:
tested_property = self.getTestedProperty()
return {tested_property: self._getTestedPropertyValue(prevision_movement,
tested_property)}
# Temporary compatibility code that will fix existing data.
# This Code must be removed in 2 years (end of 2017)
def getTestedProperty(self):
"""
Override getTestedProperty to fix the way it is stored. Some time
ago it was multi-valued, which is non-sense we the implementation we
have on this equivalence tester.
"""
tested_property = getattr(self, 'tested_property', None)
if tested_property != None:
if isinstance(tested_property, tuple):
if len(tested_property) == 1:
setattr(self, 'tested_property', tested_property[0])
return self._baseGetTestedProperty()
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