Пример #1
0
 def test_returns_empty_report_on_valid_normalized_option(self):
     self.assertEqual(
         [],
         validate.value_cond("a", self.predicate, "test")(
             {"a": validate.ValuePair(original="C", normalized="b")}
         ),
     )
Пример #2
0
 def test_returns_empty_report_on_valid_normalized_option(self):
     self.assertEqual(
         [],
         validate.value_cond("a", self.predicate, "test")({
             "a":
             validate.ValuePair(original="C", normalized="b")
         }),
     )
Пример #3
0
def _value_host_netmask(option_name, force_options):
    return validate.value_cond(
        option_name,
        lambda value: validate.is_integer(value, 1, 32),
        "a number of bits of the mask (1-32)",
        # Leaving a possibility to force this validation, if pacemaker
        # starts supporting IPv6 or other format of the netmask
        code_to_allow_extra_values=report_codes.FORCE_OPTIONS,
        allow_extra_values=force_options)
Пример #4
0
 def test_returns_report_about_invalid_option(self):
     assert_report_item_list_equal(
         validate.value_cond("a", self.predicate, "test")({
             "a": "c"
         }), [
             (severities.ERROR, report_codes.INVALID_OPTION_VALUE, {
                 "option_name": "a",
                 "option_value": "c",
                 "allowed_values": "test",
             }, None),
         ])
Пример #5
0
 def test_support_OptionValuePair(self):
     assert_report_item_list_equal(
         validate.value_cond("a", self.predicate, "test")({
             "a":
             validate.ValuePair(original="b", normalized="c")
         }), [
             (severities.ERROR, report_codes.INVALID_OPTION_VALUE, {
                 "option_name": "a",
                 "option_value": "b",
                 "allowed_values": "test",
             }, None),
         ])
Пример #6
0
 def test_supports_forceable_errors(self):
     assert_report_item_list_equal(
         validate.value_cond("a",
                             self.predicate,
                             "test",
                             code_to_allow_extra_values="FORCE")({
                                 "a": "c"
                             }),
         [
             (severities.ERROR, report_codes.INVALID_OPTION_VALUE, {
                 "option_name": "a",
                 "option_value": "c",
                 "allowed_values": "test",
             }, "FORCE"),
         ])
Пример #7
0
 def test_supports_another_report_option_name(self):
     assert_report_item_list_equal(
         validate.value_cond("a",
                             self.predicate,
                             "test",
                             option_name_for_report="option a")({
                                 "a": "c"
                             }),
         [
             (severities.ERROR, report_codes.INVALID_OPTION_VALUE, {
                 "option_name": "option a",
                 "option_value": "c",
                 "allowed_values": "test",
             }, None),
         ])
Пример #8
0
 def test_returns_report_about_invalid_option(self):
     assert_report_item_list_equal(
         validate.value_cond("a", self.predicate, "test")({"a": "c"}),
         [
             (
                 severities.ERROR,
                 report_codes.INVALID_OPTION_VALUE,
                 {
                     "option_name": "a",
                     "option_value": "c",
                     "allowed_values": "test",
                 },
                 None
             ),
         ]
     )
Пример #9
0
 def test_supports_warning(self):
     assert_report_item_list_equal(
         validate.value_cond("a",
                             self.predicate,
                             "test",
                             code_to_allow_extra_values="FORCE",
                             allow_extra_values=True)({
                                 "a": "c"
                             }),
         [
             (severities.WARNING, report_codes.INVALID_OPTION_VALUE, {
                 "option_name": "a",
                 "option_value": "c",
                 "allowed_values": "test",
             }, None),
         ])
Пример #10
0
 def test_support_option_value_pair(self):
     assert_report_item_list_equal(
         validate.value_cond("a", self.predicate, "test")(
             {"a": validate.ValuePair(original="b", normalized="c")}
         ),
         [
             (
                 severities.ERROR,
                 report_codes.INVALID_OPTION_VALUE,
                 {
                     "option_name": "a",
                     "option_value": "b",
                     "allowed_values": "test",
                 },
                 None
             ),
         ]
     )
Пример #11
0
 def test_supports_forceable_errors(self):
     assert_report_item_list_equal(
         validate.value_cond(
             "a", self.predicate, "test", code_to_allow_extra_values="FORCE"
         )(
             {"a": "c"}
         ),
         [
             (
                 severities.ERROR,
                 report_codes.INVALID_OPTION_VALUE,
                 {
                     "option_name": "a",
                     "option_value": "c",
                     "allowed_values": "test",
                 },
                 "FORCE"
             ),
         ]
     )
Пример #12
0
 def test_supports_another_report_option_name(self):
     assert_report_item_list_equal(
         validate.value_cond(
             "a", self.predicate, "test", option_name_for_report="option a"
         )(
             {"a": "c"}
         ),
         [
             (
                 severities.ERROR,
                 report_codes.INVALID_OPTION_VALUE,
                 {
                     "option_name": "option a",
                     "option_value": "c",
                     "allowed_values": "test",
                 },
                 None
             ),
         ]
     )
Пример #13
0
 def test_supports_warning(self):
     assert_report_item_list_equal(
         validate.value_cond(
             "a",
             self.predicate,
             "test",
             code_to_allow_extra_values="FORCE",
             extra_values_allowed=True
         )(
             {"a": "c"}
         ),
         [
             (
                 severities.WARNING,
                 report_codes.INVALID_OPTION_VALUE,
                 {
                     "option_name": "a",
                     "option_value": "c",
                     "allowed_values": "test",
                 },
                 None
             ),
         ]
     )
Пример #14
0
 def test_returns_empty_report_on_valid_option(self):
     self.assertEqual([],
                      validate.value_cond("a", self.predicate, "test")({
                          "a":
                          "b"
                      }))
Пример #15
0
 def setUp(self):
     self.validator = validate.value_cond("a", lambda a: a == "b", "test")
Пример #16
0
 def setUp(self):
     self.validator = validate.value_cond("a", lambda a: a == "b", "test")
Пример #17
0
 def test_returns_empty_report_on_valid_option(self):
     self.assertEqual(
         [],
         validate.value_cond("a", self.predicate, "test")({"a": "b"})
     )