コード例 #1
0
    def test_evaluate_assumes__OR_operator__when_first_item_in_array_not_recognized_operator(
            self):
        """ Test that by default OR operator is assumed when the first item in conditions is not
        a recognized operator. """

        leafEvaluator = mock.MagicMock(side_effect=[False, True])

        self.assertStrictTrue(
            evaluate([conditionA, conditionB], lambda a: leafEvaluator()))

        self.assertStrictFalse(
            evaluate([conditionA, conditionB], lambda a: False))
コード例 #2
0
    def test_and_evaluator__returns_null__when_trues_and_null(self):
        """ Test that and_evaluator returns when operands evaluate to trues and null. """

        leafEvaluator = mock.MagicMock(side_effect=[True, None])

        self.assertIsNone(
            evaluate(['and', conditionA, conditionB],
                     lambda a: leafEvaluator()))

        leafEvaluator = mock.MagicMock(side_effect=[None, True])

        self.assertIsNone(
            evaluate(['and', conditionA, conditionB],
                     lambda a: leafEvaluator()))
コード例 #3
0
    def test_and_evaluator__returns_false__when_falses_and_null(self):
        """ Test that and_evaluator returns False when when operands evaluate to falses and null. """

        leafEvaluator = mock.MagicMock(side_effect=[False, None])

        self.assertStrictFalse(
            evaluate(['and', conditionA, conditionB],
                     lambda a: leafEvaluator()))

        leafEvaluator = mock.MagicMock(side_effect=[None, False])

        self.assertStrictFalse(
            evaluate(['and', conditionA, conditionB],
                     lambda a: leafEvaluator()))
コード例 #4
0
  def test_evaluate_assumes__OR_operator__when_first_item_in_array_not_recognized_operator(self):
    """ Test that by default OR operator is assumed when the first item in conditions is not
        a recognized operator. """

    leafEvaluator = mock.MagicMock(side_effect=[False, True])

    self.assertStrictTrue(evaluate(
      [conditionA, conditionB],
      lambda a: leafEvaluator()
    ))

    self.assertStrictFalse(evaluate(
      [conditionA, conditionB],
      lambda a: False
    ))
コード例 #5
0
  def test_and_evaluator__returns_null__when_trues_and_null(self):
    """ Test that and_evaluator returns when operands evaluate to trues and null. """

    leafEvaluator = mock.MagicMock(side_effect=[True, None])

    self.assertIsNone(evaluate(
      ['and', conditionA, conditionB],
      lambda a: leafEvaluator()
    ))

    leafEvaluator = mock.MagicMock(side_effect=[None, True])

    self.assertIsNone(evaluate(
      ['and', conditionA, conditionB],
      lambda a: leafEvaluator()
    ))
コード例 #6
0
  def test_and_evaluator__returns_true(self):
    """ Test that and_evaluator returns True when all conditions evaluate to True. """

    self.assertStrictTrue(evaluate(
      ['and', conditionA, conditionB],
      lambda a: True
    ))
コード例 #7
0
  def test_and_evaluator__returns_false__when_falses_and_null(self):
    """ Test that and_evaluator returns False when when operands evaluate to falses and null. """

    leafEvaluator = mock.MagicMock(side_effect=[False, None])

    self.assertStrictFalse(evaluate(
      ['and', conditionA, conditionB],
      lambda a: leafEvaluator()
    ))

    leafEvaluator = mock.MagicMock(side_effect=[None, False])

    self.assertStrictFalse(evaluate(
      ['and', conditionA, conditionB],
      lambda a: leafEvaluator()
    ))
コード例 #8
0
  def test_or_evaluator__returns_false__when_all_false(self):
    """ Test that or_evaluator returns False when all operands evaluate to False."""

    self.assertStrictFalse(evaluate(
      ['or', conditionA, conditionB],
      lambda a: False
    ))
コード例 #9
0
  def test_not_evaluator__returns_null__when_there_are_no_operands(self):
    """ Test that not_evaluator returns null when there are no conditions. """

    self.assertIsNone(evaluate(
      ['not'],
      lambda a: True
    ))
コード例 #10
0
  def test_not_evaluator__returns_null__when_null(self):
    """ Test that not_evaluator returns null when condition evaluates to null. """

    self.assertIsNone(evaluate(
      ['not', conditionA],
      lambda a: None
    ))
コード例 #11
0
  def test_not_evaluator__returns_false(self):
    """ Test that not_evaluator returns True when condition evaluates to False. """

    self.assertStrictFalse(evaluate(
      ['not', conditionA],
      lambda a: True
    ))
コード例 #12
0
  def test_and_evaluator__returns_null__when_all_null(self):
    """ Test that and_evaluator returns null when all operands evaluate to null. """

    self.assertIsNone(evaluate(
      ['and', conditionA, conditionB],
      lambda a: None
    ))
コード例 #13
0
    def test_or_evaluator__returns_true__when_any_true(self):
        """ Test that or_evaluator returns True when any one condition evaluates to True. """

        leafEvaluator = mock.MagicMock(side_effect=[False, True])

        self.assertStrictTrue(
            evaluate(['or', conditionA, conditionB],
                     lambda a: leafEvaluator()))
コード例 #14
0
    def test_or_evaluator__returns_true__when_trues_falses_and_null(self):
        """ Test that or_evaluator returns True when operands evaluate to trues, falses and null. """

        leafEvaluator = mock.MagicMock(side_effect=[False, None, True])

        self.assertStrictTrue(
            evaluate(['or', conditionA, conditionB, conditionC],
                     lambda a: leafEvaluator()))
コード例 #15
0
    def test_and_evaluator__returns_false(self):
        """ Test that and_evaluator returns False when any one condition evaluates to False. """

        leafEvaluator = mock.MagicMock(side_effect=[True, False])

        self.assertStrictFalse(
            evaluate(['and', conditionA, conditionB],
                     lambda a: leafEvaluator()))
コード例 #16
0
  def test_or_evaluator__returns_true__when_any_true(self):
    """ Test that or_evaluator returns True when any one condition evaluates to True. """

    leafEvaluator = mock.MagicMock(side_effect=[False, True])

    self.assertStrictTrue(evaluate(
      ['or', conditionA, conditionB],
      lambda a: leafEvaluator()
    ))
コード例 #17
0
  def test_and_evaluator__returns_false(self):
    """ Test that and_evaluator returns False when any one condition evaluates to False. """

    leafEvaluator = mock.MagicMock(side_effect=[True, False])

    self.assertStrictFalse(evaluate(
      ['and', conditionA, conditionB],
      lambda a: leafEvaluator()
    ))
コード例 #18
0
  def test_or_evaluator__returns_true__when_trues_falses_and_null(self):
    """ Test that or_evaluator returns True when operands evaluate to trues, falses and null. """

    leafEvaluator = mock.MagicMock(side_effect=[False, None, True])

    self.assertStrictTrue(evaluate(
      ['or', conditionA, conditionB, conditionC],
      lambda a: leafEvaluator()
    ))
コード例 #19
0
    def test_not_evaluator_negates_first_condition__ignores_rest(self):
        """ Test that not_evaluator negates first condition and ignores rest. """
        leafEvaluator = mock.MagicMock(side_effect=[False, True, None])

        self.assertStrictTrue(
            evaluate(['not', conditionA, conditionB, conditionC],
                     lambda a: leafEvaluator()))

        leafEvaluator = mock.MagicMock(side_effect=[True, False, None])

        self.assertStrictFalse(
            evaluate(['not', conditionA, conditionB, conditionC],
                     lambda a: leafEvaluator()))

        leafEvaluator = mock.MagicMock(side_effect=[None, True, False])

        self.assertIsNone(
            evaluate(['not', conditionA, conditionB, conditionC],
                     lambda a: leafEvaluator()))
コード例 #20
0
  def test_not_evaluator_negates_first_condition__ignores_rest(self):
    """ Test that not_evaluator negates first condition and ignores rest. """
    leafEvaluator = mock.MagicMock(side_effect=[False, True, None])

    self.assertStrictTrue(evaluate(
      ['not', conditionA, conditionB, conditionC],
      lambda a: leafEvaluator()
    ))

    leafEvaluator = mock.MagicMock(side_effect=[True, False, None])

    self.assertStrictFalse(evaluate(
      ['not', conditionA, conditionB, conditionC],
      lambda a: leafEvaluator()
    ))

    leafEvaluator = mock.MagicMock(side_effect=[None, True, False])

    self.assertIsNone(evaluate(
      ['not', conditionA, conditionB, conditionC],
      lambda a: leafEvaluator()
    ))
コード例 #21
0
    def test_not_evaluator__returns_null__when_there_are_no_operands(self):
        """ Test that not_evaluator returns null when there are no conditions. """

        self.assertIsNone(evaluate(['not'], lambda a: True))
コード例 #22
0
    def test_and_evaluator__returns_null__when_all_null(self):
        """ Test that and_evaluator returns null when all operands evaluate to null. """

        self.assertIsNone(
            evaluate(['and', conditionA, conditionB], lambda a: None))
コード例 #23
0
  def test_evaluate__returns_true(self):
    """ Test that evaluate returns True when the leaf condition evaluator returns True. """

    self.assertStrictTrue(evaluate(conditionA, lambda a: True))
コード例 #24
0
    def test_and_evaluator__returns_true(self):
        """ Test that and_evaluator returns True when all conditions evaluate to True. """

        self.assertStrictTrue(
            evaluate(['and', conditionA, conditionB], lambda a: True))
コード例 #25
0
    def test_evaluate__returns_false(self):
        """ Test that evaluate returns False when the leaf condition evaluator returns False. """

        self.assertStrictFalse(evaluate(conditionA, lambda a: False))
コード例 #26
0
    def test_evaluate__returns_true(self):
        """ Test that evaluate returns True when the leaf condition evaluator returns True. """

        self.assertStrictTrue(evaluate(conditionA, lambda a: True))
コード例 #27
0
  def test_evaluate__returns_false(self):
    """ Test that evaluate returns False when the leaf condition evaluator returns False. """

    self.assertStrictFalse(evaluate(conditionA, lambda a: False))
コード例 #28
0
    def test_not_evaluator__returns_null__when_null(self):
        """ Test that not_evaluator returns null when condition evaluates to null. """

        self.assertIsNone(evaluate(['not', conditionA], lambda a: None))
コード例 #29
0
    def test_not_evaluator__returns_false(self):
        """ Test that not_evaluator returns True when condition evaluates to False. """

        self.assertStrictFalse(evaluate(['not', conditionA], lambda a: True))
コード例 #30
0
    def test_or_evaluator__returns_false__when_all_false(self):
        """ Test that or_evaluator returns False when all operands evaluate to False."""

        self.assertStrictFalse(
            evaluate(['or', conditionA, conditionB], lambda a: False))