예제 #1
0
    def test_includes_expected_fields(self):
        variable, value, operator = self.txt(), self.txt(), EqualityOperator()

        check = Check(variable, value, operator)

        self.assertEqual(
            {"variable": variable, "value": value, "operator": operator.SYMBOL},
            check.to_dict(),
        )
예제 #2
0
    def test_calls_operator_with_correct_arguments(self):
        initial_value = self.txt()
        operator = MagicMock(return_value=True)
        check = Check(self.txt(), initial_value, operator)

        compared_value = self.txt()

        check.check(compared_value)

        operator.compare.assert_called_once_with(compared_value, initial_value)
예제 #3
0
    def test_includes_expected_fields(self):
        variable, value, operator = self.txt(), self.txt(), EqualityOperator()

        json = {"variable": variable, "value": value, "operator": operator.SYMBOL}

        check = Check.from_dict(json)

        self.assertEqual(json, check.to_dict())
예제 #4
0
 def test_returns_instance_of_set_membership_operator(self):
     check = Check.factory("foo__in", [1])
     self.assertIsInstance(check.operator, SetMembershipOperator)
예제 #5
0
 def test_returns_instance_of_negation_operator(self):
     check = Check.factory("foo__ne", 1)
     self.assertIsInstance(check.operator, NegationOperator)
예제 #6
0
 def test_returns_instance_of_less_than_or_equal_to_operator(self):
     check = Check.factory("foo__lte", 1)
     self.assertIsInstance(check.operator, LessThanOrEqualToOperator)
예제 #7
0
 def test_returns_instance_of_greater_than_or_equal_to_operator(self):
     check = Check.factory("foo__gte", 1)
     self.assertIsInstance(check.operator, GreaterThanOrEqualToOperator)
예제 #8
0
 def test_returns_instance_of_equality_operator(self):
     check = Check.factory("foo", 1)
     self.assertIsInstance(check.operator, EqualityOperator)
예제 #9
0
 def test_returns_instance_of_check(self):
     check = Check.factory("foo", 1)
     self.assertIsInstance(check, Check)
예제 #10
0
 def test_returns_variable_only_when_operator_is_none(self):
     variable, operator = self.txt(), None
     key = Check.make_check_key(variable, operator)
     self.assertEqual(variable, key)
예제 #11
0
 def test_returns_variable_and_operator_with_delimiter(self):
     variable, operator = self.txt(), "gt"
     key = Check.make_check_key(variable, operator)
     self.assertEqual(OPERATOR_DELIMITER.join([variable, operator]), key)