def test_no_reports_for_valid_time_interval(self): for interval in ["0", "1s", "2sec", "3m", "4min", "5h", "6hr"]: with self.subTest(value=interval): assert_report_item_list_equal( validate.ValueTimeInterval("a").validate({"a": interval}), [], )
def validate_set_as_guest(tree, existing_nodes_names, existing_nodes_addrs, node_name, options): validator_list = [ validate.NamesIn(GUEST_OPTIONS, option_type="guest"), validate.ValueTimeInterval("remote-connect-timeout"), validate.ValuePortNumber("remote-port"), ] return (validate.ValidatorAll(validator_list).validate(options) + validate.ValueNotEmpty("node name", None).validate( {"node name": node_name.strip()}) + validate_conflicts(tree, existing_nodes_names, existing_nodes_addrs, node_name, options))
def test_reports_about_invalid_interval(self): assert_report_item_list_equal( validate.ValueTimeInterval("a").validate({"a": "invalid_value"}), [ fixture.error( report_codes.INVALID_OPTION_VALUE, option_name="a", option_value="invalid_value", allowed_values="time interval (e.g. 1, 2s, 3m, 4h, ...)", cannot_be_empty=False, forbidden_characters=None, ), ])