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")} ), )
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") }), )
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)
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), ])
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), ])
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"), ])
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), ])
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 ), ] )
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), ])
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 ), ] )
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" ), ] )
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 ), ] )
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 ), ] )
def test_returns_empty_report_on_valid_option(self): self.assertEqual([], validate.value_cond("a", self.predicate, "test")({ "a": "b" }))
def setUp(self): self.validator = validate.value_cond("a", lambda a: a == "b", "test")
def test_returns_empty_report_on_valid_option(self): self.assertEqual( [], validate.value_cond("a", self.predicate, "test")({"a": "b"}) )