def test_merge_commutativity_on_continuous_rules(self): """Continuous rule merging should be commutative.""" rule1 = ContinuousRule('Rule1', True, 1) rule2 = ContinuousRule('Rule1', True, 2) new_rule1 = rule1.merge_with(rule2) new_rule2 = rule2.merge_with(rule1) self.assertEqual(new_rule1.value, new_rule2.value)
def test_merge_commutativity_on_continuous_rules(self): """Continuous rule merging should be commutative.""" rule1 = ContinuousRule("Rule1", True, 1) rule2 = ContinuousRule("Rule1", True, 2) new_rule1 = rule1.merge_with(rule2) new_rule2 = rule2.merge_with(rule1) self.assertEqual(new_rule1.value, new_rule2.value)
def test_merging_lt_with_gt_continuous_rules(self): """Merging `x > 1` and `x < 2` should produce `1 < x < 2`.""" rule1 = ContinuousRule("Rule", True, 1) rule2 = ContinuousRule("Rule", False, 2) new_rule = rule1.merge_with(rule2) self.assertIsInstance(new_rule, IntervalRule) self.assertEqual(new_rule.left_rule, rule1) self.assertEqual(new_rule.right_rule, rule2)
def test_merging_lt_with_gt_continuous_rules(self): """Merging `x > 1` and `x < 2` should produce `1 < x < 2`.""" rule1 = ContinuousRule('Rule', True, 1) rule2 = ContinuousRule('Rule', False, 2) new_rule = rule1.merge_with(rule2) self.assertIsInstance(new_rule, IntervalRule) self.assertEqual(new_rule.left_rule, rule1) self.assertEqual(new_rule.right_rule, rule2)
def test_merging_lt_with_lte_rule(self): """Merging `x < 1` and `x ≤ 1` should produce `x < 1`.""" rule1 = ContinuousRule("Rule", False, 1, inclusive=True) rule2 = ContinuousRule("Rule", False, 1, inclusive=False) new_rule = rule1.merge_with(rule2) self.assertEqual(new_rule.inclusive, False)
def test_merging_two_lt_continuous_rules(self): """Merging `x < 1` and `x < 2` should produce `x < 1`.""" rule1 = ContinuousRule("Rule", False, 1) rule2 = ContinuousRule("Rule", False, 2) new_rule = rule1.merge_with(rule2) self.assertEqual(new_rule.value, 1)
def test_merge_keeps_attr_name_on_continuous_rules(self): """Merging continuous rules should keep the name of the rule.""" rule1 = ContinuousRule("Rule1", True, 1) rule2 = ContinuousRule("Rule1", True, 2) new_rule = rule1.merge_with(rule2) self.assertEqual(new_rule.attr_name, "Rule1")
def test_merge_keeps_gt_on_continuous_rules(self): """Merging ccontinuous rules should keep GT property.""" rule1 = ContinuousRule("Rule1", True, 1) rule2 = ContinuousRule("Rule1", True, 2) new_rule = rule1.merge_with(rule2) self.assertEqual(new_rule.greater, True)
def test_merging_lt_with_lte_rule(self): """Merging `x < 1` and `x ≤ 1` should produce `x < 1`.""" rule1 = ContinuousRule('Rule', False, 1, inclusive=True) rule2 = ContinuousRule('Rule', False, 1, inclusive=False) new_rule = rule1.merge_with(rule2) self.assertEqual(new_rule.inclusive, False)
def test_merging_two_lt_continuous_rules(self): """Merging `x < 1` and `x < 2` should produce `x < 1`.""" rule1 = ContinuousRule('Rule', False, 1) rule2 = ContinuousRule('Rule', False, 2) new_rule = rule1.merge_with(rule2) self.assertEqual(new_rule.value, 1)
def test_merging_gt_with_gte_continuous_rule(self): """Merging `x > 1` and `x ≥ 1` should produce `x > 1`.""" rule1 = ContinuousRule('Rule', True, 1, inclusive=True) rule2 = ContinuousRule('Rule', True, 1, inclusive=False) new_rule = rule1.merge_with(rule2) self.assertEqual(new_rule.inclusive, False)
def test_merging_two_gt_continuous_rules(self): """Merging `x > 1` and `x > 2` should produce `x > 2`.""" rule1 = ContinuousRule('Rule', True, 1) rule2 = ContinuousRule('Rule', True, 2) new_rule = rule1.merge_with(rule2) self.assertEqual(new_rule.value, 2)
def test_merge_keeps_attr_name_on_continuous_rules(self): """Merging continuous rules should keep the name of the rule.""" rule1 = ContinuousRule('Rule1', True, 1) rule2 = ContinuousRule('Rule1', True, 2) new_rule = rule1.merge_with(rule2) self.assertEqual(new_rule.attr_name, 'Rule1')
def test_merge_keeps_gt_on_continuous_rules(self): """Merging ccontinuous rules should keep GT property.""" rule1 = ContinuousRule('Rule1', True, 1) rule2 = ContinuousRule('Rule1', True, 2) new_rule = rule1.merge_with(rule2) self.assertEqual(new_rule.greater, True)