diff --git a/kibot/config_reader.py b/kibot/config_reader.py index 247c924b..a932d081 100644 --- a/kibot/config_reader.py +++ b/kibot/config_reader.py @@ -192,7 +192,7 @@ class CfgYamlReader(object): outputs.extend(outs) logger.debug('Outputs loaded from `{}`: {}'.format(os.path.relpath(fn), list(map(lambda c: c.name, outs)))) else: - logger.warning(W_NOOUTPUTS+" No outputs found in `{}`".format(fn)) + logger.warning(W_NOOUTPUTS+"No outputs found in `{}`".format(fn)) return outputs def load_yaml(self, fstream): diff --git a/tests/test_plot/test_misc.py b/tests/test_plot/test_misc.py index 62336ca6..6772b703 100644 --- a/tests/test_plot/test_misc.py +++ b/tests/test_plot/test_misc.py @@ -785,3 +785,12 @@ def test_compress_fail_deps(test_dir, monkeypatch): ctx.run(INTERNAL_ERROR) ctx.search_err(r"Unable to generate `dummy` from 'Test plug-in, dummy' \(do_test\) \[test\]") ctx.clean_up() + + +def test_import_1(test_dir): + prj = 'test_v5' + ctx = context.TestContext(test_dir, 'test_import_1', prj, 'import_test_1', '') + ctx.run(extra=['-i']) + ctx.search_err(r'Outputs loaded from `tests/yaml_samples/gerber_inner.kibot.yaml`: \[\'gerbers\', \'result\'\]') + ctx.search_err(r'Outputs loaded from `tests/yaml_samples/ibom.kibot.yaml`: \[\'interactive_bom\'\]') + ctx.clean_up() diff --git a/tests/test_plot/test_yaml_errors.py b/tests/test_plot/test_yaml_errors.py index 220a7e99..d131dbb1 100644 --- a/tests/test_plot/test_yaml_errors.py +++ b/tests/test_plot/test_yaml_errors.py @@ -668,3 +668,31 @@ def test_error_aggregate_miss_file(test_dir): ctx.run(EXIT_BAD_CONFIG) assert ctx.search_err("Missing `dummy`") ctx.clean_up() + + +def test_error_wrong_import_type(test_dir): + ctx = context.TestContext(test_dir, 'test_error_wrong_import_type', PRJ, 'error_wrong_import_type', '') + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err(r"Incorrect `import` section \(must be a list\)") + ctx.clean_up() + + +def test_error_import_not_str(test_dir): + ctx = context.TestContext(test_dir, 'test_error_import_not_str', PRJ, 'error_import_not_str', '') + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err(r"`import` items must be strings") + ctx.clean_up() + + +def test_error_import_miss_file(test_dir): + ctx = context.TestContext(test_dir, 'test_error_import_miss_file', PRJ, 'error_import_miss_file', '') + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err(r"missing import file") + ctx.clean_up() + + +def test_error_import_no_outputs(test_dir): + ctx = context.TestContext(test_dir, 'test_error_import_no_outputs', PRJ, 'error_import_no_outputs', '') + ctx.run() + assert ctx.search_err(r"No outputs found in `(.*)drc.kibot.yaml`") + ctx.clean_up() diff --git a/tests/yaml_samples/error_import_miss_file.kibot.yaml b/tests/yaml_samples/error_import_miss_file.kibot.yaml new file mode 100644 index 00000000..69032f2a --- /dev/null +++ b/tests/yaml_samples/error_import_miss_file.kibot.yaml @@ -0,0 +1,18 @@ +# Example KiBot config file for a basic 2-layer board +kibot: + version: 1 + +import: + - foobar + - bogus + +outputs: + - name: 'position' + comment: "Pick and place file" + type: position + dir: positiondir + options: + format: ASCII # CSV or ASCII format + units: millimeters # millimeters or inches + separate_files_for_front_and_back: true + only_smd: true diff --git a/tests/yaml_samples/error_import_no_outputs.kibot.yaml b/tests/yaml_samples/error_import_no_outputs.kibot.yaml new file mode 100644 index 00000000..418b91a5 --- /dev/null +++ b/tests/yaml_samples/error_import_no_outputs.kibot.yaml @@ -0,0 +1,7 @@ +# Example KiBot config file for a basic 2-layer board +kibot: + version: 1 + +import: + - drc.kibot.yaml + diff --git a/tests/yaml_samples/error_import_not_str.kibot.yaml b/tests/yaml_samples/error_import_not_str.kibot.yaml new file mode 100644 index 00000000..b22a3825 --- /dev/null +++ b/tests/yaml_samples/error_import_not_str.kibot.yaml @@ -0,0 +1,18 @@ +# Example KiBot config file for a basic 2-layer board +kibot: + version: 1 + +import: + - 1 + - true + +outputs: + - name: 'position' + comment: "Pick and place file" + type: position + dir: positiondir + options: + format: ASCII # CSV or ASCII format + units: millimeters # millimeters or inches + separate_files_for_front_and_back: true + only_smd: true diff --git a/tests/yaml_samples/error_wrong_import_type.kibot.yaml b/tests/yaml_samples/error_wrong_import_type.kibot.yaml new file mode 100644 index 00000000..25ee53e6 --- /dev/null +++ b/tests/yaml_samples/error_wrong_import_type.kibot.yaml @@ -0,0 +1,17 @@ +# Example KiBot config file for a basic 2-layer board +kibot: + version: 1 + +import: + can_not_use_dict: 1 + +outputs: + - name: 'position' + comment: "Pick and place file" + type: position + dir: positiondir + options: + format: ASCII # CSV or ASCII format + units: millimeters # millimeters or inches + separate_files_for_front_and_back: true + only_smd: true diff --git a/tests/yaml_samples/import_test_1.kibot.yaml b/tests/yaml_samples/import_test_1.kibot.yaml new file mode 100644 index 00000000..8d96604f --- /dev/null +++ b/tests/yaml_samples/import_test_1.kibot.yaml @@ -0,0 +1,18 @@ +# Example KiBot config file for a basic 2-layer board +kibot: + version: 1 + +import: + - gerber_inner.kibot.yaml + - ibom.kibot.yaml + +outputs: + - name: 'position' + comment: "Pick and place file" + type: position + dir: positiondir + options: + format: ASCII # CSV or ASCII format + units: millimeters # millimeters or inches + separate_files_for_front_and_back: true + only_smd: true