From be8339ddff8bd5070d7552d91f87cb407c104b54 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 30 Jun 2020 22:57:59 -0300 Subject: [PATCH] Added tests to cover all the out_any_drill.py errors. --- tests/test_plot/test_yaml_errors.py | 57 +++++++++++++++++-- tests/yaml_samples/drill_legacy.kiplot.yaml | 2 +- .../error_drill_map_no_type.kiplot.yaml | 3 +- .../error_drill_map_no_type_2.kiplot.yaml | 28 +++++++++ .../error_drill_map_wrong_type_2.kiplot.yaml | 28 +++++++++ .../error_drill_map_wrong_type_3.kiplot.yaml | 27 +++++++++ .../error_drill_report_no_type.kiplot.yaml | 26 +++++++++ .../error_drill_report_no_type_2.kiplot.yaml | 28 +++++++++ ...rror_drill_report_wrong_type_2.kiplot.yaml | 28 +++++++++ ...rror_drill_report_wrong_type_3.kiplot.yaml | 26 +++++++++ 10 files changed, 246 insertions(+), 7 deletions(-) create mode 100644 tests/yaml_samples/error_drill_map_no_type_2.kiplot.yaml create mode 100644 tests/yaml_samples/error_drill_map_wrong_type_2.kiplot.yaml create mode 100644 tests/yaml_samples/error_drill_map_wrong_type_3.kiplot.yaml create mode 100644 tests/yaml_samples/error_drill_report_no_type.kiplot.yaml create mode 100644 tests/yaml_samples/error_drill_report_no_type_2.kiplot.yaml create mode 100644 tests/yaml_samples/error_drill_report_wrong_type_2.kiplot.yaml create mode 100644 tests/yaml_samples/error_drill_report_wrong_type_3.kiplot.yaml diff --git a/tests/test_plot/test_yaml_errors.py b/tests/test_plot/test_yaml_errors.py index 9d0b008c..c7be3266 100644 --- a/tests/test_plot/test_yaml_errors.py +++ b/tests/test_plot/test_yaml_errors.py @@ -83,20 +83,69 @@ def test_wrong_version_3(): ctx.clean_up() -def test_drill_map_no_type(): - ctx = context.TestContext('ErrorDrillMapNoType', '3Rs', 'error_drill_map_no_type', None) +def test_drill_map_no_type_1(): + ctx = context.TestContext('ErrorDrillMapNoType1', '3Rs', 'error_drill_map_no_type', None) ctx.run(EXIT_BAD_CONFIG) assert ctx.search_err("Empty drill `map` section") ctx.clean_up() -def test_drill_map_wrong_type(): - ctx = context.TestContext('ErrorDrillMapWrongType', '3Rs', 'error_drill_map_wrong_type', None) +def test_drill_map_no_type_2(): + ctx = context.TestContext('ErrorDrillMapNoType2', '3Rs', 'error_drill_map_no_type_2', None) + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("drill `map` must contain a `type`") + ctx.clean_up() + + +def test_drill_map_wrong_type_1(): + ctx = context.TestContext('ErrorDrillMapWrongType1', '3Rs', 'error_drill_map_wrong_type', None) ctx.run(EXIT_BAD_CONFIG) assert ctx.search_err("Unknown drill `map` `type`: bogus") ctx.clean_up() +def test_drill_map_wrong_type_2(): + ctx = context.TestContext('ErrorDrillMapWrongType2', '3Rs', 'error_drill_map_wrong_type_2', None) + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("drill `map` `type` must be a string") + ctx.clean_up() + + +def test_drill_map_wrong_type_3(): + ctx = context.TestContext('ErrorDrillMapWrongType3', '3Rs', 'error_drill_map_wrong_type_3', None) + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("drill `map` must be a string") + ctx.clean_up() + + +def test_drill_report_no_type_1(): + ctx = context.TestContext('ErrorDrillReportNoType1', '3Rs', 'error_drill_report_no_type', None) + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("Empty drill `report` section") + ctx.clean_up() + + +def test_drill_report_no_type_2(): + ctx = context.TestContext('ErrorDrillReportNoType2', '3Rs', 'error_drill_report_no_type_2', None) + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("drill `report` must contain a `filename`") + ctx.clean_up() + + +def test_drill_report_wrong_type_2(): + ctx = context.TestContext('ErrorDrillReportWrongType2', '3Rs', 'error_drill_report_wrong_type_2', None) + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("drill `report` `filename` must be a string") + ctx.clean_up() + + +def test_drill_report_wrong_type_3(): + ctx = context.TestContext('ErrorDrillReportWrongType3', '3Rs', 'error_drill_report_wrong_type_3', None) + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("drill `report` must be a string") + ctx.clean_up() + + def test_wrong_layer_1(): ctx = context.TestContext('ErrorWrongLayer1', '3Rs', 'error_wrong_layer_1', None) ctx.run(PLOT_ERROR) diff --git a/tests/yaml_samples/drill_legacy.kiplot.yaml b/tests/yaml_samples/drill_legacy.kiplot.yaml index 82c808a1..e7ca00af 100644 --- a/tests/yaml_samples/drill_legacy.kiplot.yaml +++ b/tests/yaml_samples/drill_legacy.kiplot.yaml @@ -11,7 +11,7 @@ outputs: options: metric_units: true pth_and_npth_single_file: false - use_aux_axis_as_origin: false + use_aux_axis_as_origin: true minimal_header: false mirror_y_axis: false report: diff --git a/tests/yaml_samples/error_drill_map_no_type.kiplot.yaml b/tests/yaml_samples/error_drill_map_no_type.kiplot.yaml index b78469bf..c436b236 100644 --- a/tests/yaml_samples/error_drill_map_no_type.kiplot.yaml +++ b/tests/yaml_samples/error_drill_map_no_type.kiplot.yaml @@ -14,8 +14,7 @@ outputs: use_aux_axis_as_origin: false minimal_header: false mirror_y_axis: false - report: - filename: 'report.rpt' + report: None map: - name: gerber_drills diff --git a/tests/yaml_samples/error_drill_map_no_type_2.kiplot.yaml b/tests/yaml_samples/error_drill_map_no_type_2.kiplot.yaml new file mode 100644 index 00000000..b4ed62c1 --- /dev/null +++ b/tests/yaml_samples/error_drill_map_no_type_2.kiplot.yaml @@ -0,0 +1,28 @@ +# Drills and Gerber drills +kiplot: + version: 1 + +outputs: + + - name: excellon_drill + comment: "Excellon drill files" + type: excellon + dir: Drill + options: + metric_units: true + pth_and_npth_single_file: false + use_aux_axis_as_origin: false + minimal_header: false + mirror_y_axis: false + report: + filename: 'report.rpt' + map: + types: 'bogus' + + - name: gerber_drills + comment: "Gerber drill files" + type: gerb_drill + dir: Drill + options: + use_aux_axis_as_origin: false + diff --git a/tests/yaml_samples/error_drill_map_wrong_type_2.kiplot.yaml b/tests/yaml_samples/error_drill_map_wrong_type_2.kiplot.yaml new file mode 100644 index 00000000..c98b307c --- /dev/null +++ b/tests/yaml_samples/error_drill_map_wrong_type_2.kiplot.yaml @@ -0,0 +1,28 @@ +# Drills and Gerber drills +kiplot: + version: 1 + +outputs: + + - name: excellon_drill + comment: "Excellon drill files" + type: excellon + dir: Drill + options: + metric_units: true + pth_and_npth_single_file: false + use_aux_axis_as_origin: false + minimal_header: false + mirror_y_axis: false + report: + filename: 'report.rpt' + map: + type: 5 + + - name: gerber_drills + comment: "Gerber drill files" + type: gerb_drill + dir: Drill + options: + use_aux_axis_as_origin: false + diff --git a/tests/yaml_samples/error_drill_map_wrong_type_3.kiplot.yaml b/tests/yaml_samples/error_drill_map_wrong_type_3.kiplot.yaml new file mode 100644 index 00000000..085679a8 --- /dev/null +++ b/tests/yaml_samples/error_drill_map_wrong_type_3.kiplot.yaml @@ -0,0 +1,27 @@ +# Drills and Gerber drills +kiplot: + version: 1 + +outputs: + + - name: excellon_drill + comment: "Excellon drill files" + type: excellon + dir: Drill + options: + metric_units: true + pth_and_npth_single_file: false + use_aux_axis_as_origin: false + minimal_header: false + mirror_y_axis: false + report: + filename: 'report.rpt' + map: true + + - name: gerber_drills + comment: "Gerber drill files" + type: gerb_drill + dir: Drill + options: + use_aux_axis_as_origin: false + diff --git a/tests/yaml_samples/error_drill_report_no_type.kiplot.yaml b/tests/yaml_samples/error_drill_report_no_type.kiplot.yaml new file mode 100644 index 00000000..196c8e93 --- /dev/null +++ b/tests/yaml_samples/error_drill_report_no_type.kiplot.yaml @@ -0,0 +1,26 @@ +# Drills and Gerber drills +kiplot: + version: 1 + +outputs: + + - name: excellon_drill + comment: "Excellon drill files" + type: excellon + dir: Drill + options: + metric_units: true + pth_and_npth_single_file: false + use_aux_axis_as_origin: false + minimal_header: false + mirror_y_axis: false + map: None + report: + + - name: gerber_drills + comment: "Gerber drill files" + type: gerb_drill + dir: Drill + options: + use_aux_axis_as_origin: false + diff --git a/tests/yaml_samples/error_drill_report_no_type_2.kiplot.yaml b/tests/yaml_samples/error_drill_report_no_type_2.kiplot.yaml new file mode 100644 index 00000000..8181270c --- /dev/null +++ b/tests/yaml_samples/error_drill_report_no_type_2.kiplot.yaml @@ -0,0 +1,28 @@ +# Drills and Gerber drills +kiplot: + version: 1 + +outputs: + + - name: excellon_drill + comment: "Excellon drill files" + type: excellon + dir: Drill + options: + metric_units: true + pth_and_npth_single_file: false + use_aux_axis_as_origin: false + minimal_header: false + mirror_y_axis: false + report: + filenames: 'report.rpt' + map: + type: 'bogus' + + - name: gerber_drills + comment: "Gerber drill files" + type: gerb_drill + dir: Drill + options: + use_aux_axis_as_origin: false + diff --git a/tests/yaml_samples/error_drill_report_wrong_type_2.kiplot.yaml b/tests/yaml_samples/error_drill_report_wrong_type_2.kiplot.yaml new file mode 100644 index 00000000..d32e69e7 --- /dev/null +++ b/tests/yaml_samples/error_drill_report_wrong_type_2.kiplot.yaml @@ -0,0 +1,28 @@ +# Drills and Gerber drills +kiplot: + version: 1 + +outputs: + + - name: excellon_drill + comment: "Excellon drill files" + type: excellon + dir: Drill + options: + metric_units: true + pth_and_npth_single_file: false + use_aux_axis_as_origin: false + minimal_header: false + mirror_y_axis: false + report: + filename: 5 + map: + type: 'pdf' + + - name: gerber_drills + comment: "Gerber drill files" + type: gerb_drill + dir: Drill + options: + use_aux_axis_as_origin: false + diff --git a/tests/yaml_samples/error_drill_report_wrong_type_3.kiplot.yaml b/tests/yaml_samples/error_drill_report_wrong_type_3.kiplot.yaml new file mode 100644 index 00000000..db710f11 --- /dev/null +++ b/tests/yaml_samples/error_drill_report_wrong_type_3.kiplot.yaml @@ -0,0 +1,26 @@ +# Drills and Gerber drills +kiplot: + version: 1 + +outputs: + + - name: excellon_drill + comment: "Excellon drill files" + type: excellon + dir: Drill + options: + metric_units: true + pth_and_npth_single_file: false + use_aux_axis_as_origin: false + minimal_header: false + mirror_y_axis: false + map: 'pdf' + report: 5 + + - name: gerber_drills + comment: "Gerber drill files" + type: gerb_drill + dir: Drill + options: + use_aux_axis_as_origin: false +