From 31e461ca9ca99a9878a82e81e421452b8697e087 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 26 May 2020 13:27:49 -0300 Subject: [PATCH] Added 3 tests for wrong layer names. --- tests/test_plot/test_yaml_errors.py | 27 ++++++++++++++++- .../error_wrong_layer_1.kiplot.yaml | 29 +++++++++++++++++++ .../error_wrong_layer_2.kiplot.yaml | 29 +++++++++++++++++++ .../error_wrong_layer_3.kiplot.yaml | 29 +++++++++++++++++++ 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 tests/yaml_samples/error_wrong_layer_1.kiplot.yaml create mode 100644 tests/yaml_samples/error_wrong_layer_2.kiplot.yaml create mode 100644 tests/yaml_samples/error_wrong_layer_3.kiplot.yaml diff --git a/tests/test_plot/test_yaml_errors.py b/tests/test_plot/test_yaml_errors.py index cd74e4bc..5226ae0f 100644 --- a/tests/test_plot/test_yaml_errors.py +++ b/tests/test_plot/test_yaml_errors.py @@ -5,6 +5,10 @@ Tests various errors in the config file - Wrong kiplot.version - Missing drill map type - Wrong drill map type +- Wrong layer: + - Incorrect name + - Inner.1, but no inner layers + - Inner_1 (malformed) For debug information use: pytest-3 --log-cli-level debug @@ -18,7 +22,7 @@ sys.path.insert(0, os.path.dirname(prev_dir)) # Utils import from utils import context sys.path.insert(0, os.path.dirname(prev_dir)) -from kiplot.misc import (EXIT_BAD_CONFIG) +from kiplot.misc import (EXIT_BAD_CONFIG, PLOT_ERROR) def test_no_version(): @@ -47,3 +51,24 @@ def test_drill_map_wrong_type(): ctx.run(EXIT_BAD_CONFIG) assert ctx.search_err("Unknown drill map type: bogus") ctx.clean_up() + + +def test_wrong_layer_1(): + ctx = context.TestContext('ErrorWrongLayer1', '3Rs', 'error_wrong_layer_1', None) + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("Unknown layer name: F.Bogus") + ctx.clean_up() + + +def test_wrong_layer_2(): + ctx = context.TestContext('ErrorWrongLayer2', '3Rs', 'error_wrong_layer_2', None) + ctx.run(PLOT_ERROR) + assert ctx.search_err("Inner layer 1 is not valid for this board") + ctx.clean_up() + + +def test_wrong_layer_3(): + ctx = context.TestContext('ErrorWrongLayer3', '3Rs', 'error_wrong_layer_3', None) + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("Malformed inner layer name: Inner_1,") + ctx.clean_up() diff --git a/tests/yaml_samples/error_wrong_layer_1.kiplot.yaml b/tests/yaml_samples/error_wrong_layer_1.kiplot.yaml new file mode 100644 index 00000000..43822375 --- /dev/null +++ b/tests/yaml_samples/error_wrong_layer_1.kiplot.yaml @@ -0,0 +1,29 @@ +kiplot: + version: 1 + +outputs: + - name: PDF + comment: "PDF files" + type: pdf + dir: PDF + options: + exclude_edge_layer: false + exclude_pads_from_silkscreen: false + use_aux_axis_as_origin: false + plot_sheet_reference: false + plot_footprint_refs: true + plot_footprint_values: true + force_plot_invisible_refs_vals: false + tent_vias: true + check_zone_fills: true + + # PDF options + drill_marks: small + mirror_plot: false + negative_plot: false + line_width: 0.01 + layers: + - layer: F.Cu + suffix: F_Cu + - layer: F.Bogus + suffix: B_Silks diff --git a/tests/yaml_samples/error_wrong_layer_2.kiplot.yaml b/tests/yaml_samples/error_wrong_layer_2.kiplot.yaml new file mode 100644 index 00000000..e97d3ccb --- /dev/null +++ b/tests/yaml_samples/error_wrong_layer_2.kiplot.yaml @@ -0,0 +1,29 @@ +kiplot: + version: 1 + +outputs: + - name: PDF + comment: "PDF files" + type: pdf + dir: PDF + options: + exclude_edge_layer: false + exclude_pads_from_silkscreen: false + use_aux_axis_as_origin: false + plot_sheet_reference: false + plot_footprint_refs: true + plot_footprint_values: true + force_plot_invisible_refs_vals: false + tent_vias: true + check_zone_fills: true + + # PDF options + drill_marks: small + mirror_plot: false + negative_plot: false + line_width: 0.01 + layers: + - layer: F.Cu + suffix: F_Cu + - layer: Inner.1 + suffix: B_Silks diff --git a/tests/yaml_samples/error_wrong_layer_3.kiplot.yaml b/tests/yaml_samples/error_wrong_layer_3.kiplot.yaml new file mode 100644 index 00000000..6a325e0a --- /dev/null +++ b/tests/yaml_samples/error_wrong_layer_3.kiplot.yaml @@ -0,0 +1,29 @@ +kiplot: + version: 1 + +outputs: + - name: PDF + comment: "PDF files" + type: pdf + dir: PDF + options: + exclude_edge_layer: false + exclude_pads_from_silkscreen: false + use_aux_axis_as_origin: false + plot_sheet_reference: false + plot_footprint_refs: true + plot_footprint_values: true + force_plot_invisible_refs_vals: false + tent_vias: true + check_zone_fills: true + + # PDF options + drill_marks: small + mirror_plot: false + negative_plot: false + line_width: 0.01 + layers: + - layer: F.Cu + suffix: F_Cu + - layer: Inner_1 + suffix: B_Silks