def test_compute_var_help_with_no_allowed_values(): var_data = { "optional": True, "description": "Desc", "type": "boolean" } expected_help = ":param v: Desc\n" \ + ":type v: boolean" assert _compute_var_help("v", var_data) == expected_help
def test_compute_var_help_default_value_falsy(): var_data = { "optional": True, "description": "Desc", "type": "boolean", "value": False, } expected_help = (":param v: Desc\n" + "\n" + " Default value: ``False``\n" + ":type v: boolean") assert _compute_var_help("v", var_data) == expected_help
def test_compute_var_help_with_old_allowed_values(): var_data = { "allowedValues": ["v1"], "optional": True, "description": "variable description", "type": "boolean", } expected_help = (":param v: variable description" + "\n Allowed values:\n" + "\n * v1" + "\n:type v: boolean") assert _compute_var_help("v", var_data) == expected_help
def test_compute_var_help_with_new_and_old_allowed_values(): var_data = { "allowedValues": ["deprecated v1"], "optional": True, "description": "variable description", "values": [{"name": "v1", "description": "allowed value description"}], "type": "boolean" } expected_help = ":param v: variable description" \ + "\n Allowed values:\n" \ + "\n * v1: allowed value description" \ + "\n:type v: boolean" assert _compute_var_help("v", var_data) == expected_help
def test_compute_var_help_with_allowed_values(): var_data = { "optional": True, "description": "variable description", "values": [ {"name": "v1", "description": "v1 description"}, {"name": "v2", "description": "v2 description"} ], "type": "boolean" } expected_help = ":param v: variable description" \ + "\n Allowed values:\n" \ + "\n * v1: v1 description" \ + "\n * v2: v2 description" \ + "\n:type v: boolean" assert _compute_var_help("v", var_data) == expected_help