From e0de652105a4c067f0c2e349cefd4a2045235a45 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 1 Sep 2020 18:49:38 -0300 Subject: [PATCH] Added more tests for the filters and variants. --- tests/test_plot/test_int_bom.py | 19 +++++++++ tests/test_plot/test_yaml_errors.py | 14 +++++++ .../yaml_samples/error_unk_variant.kibot.yaml | 11 ++++++ .../error_wrong_fil_name.kibot.yaml | 10 +++++ .../int_bom_var_t3_csv.kibot.yaml | 39 +++++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 tests/yaml_samples/error_unk_variant.kibot.yaml create mode 100644 tests/yaml_samples/error_wrong_fil_name.kibot.yaml create mode 100644 tests/yaml_samples/int_bom_var_t3_csv.kibot.yaml diff --git a/tests/test_plot/test_int_bom.py b/tests/test_plot/test_int_bom.py index 316da62b..d1ca4c5d 100644 --- a/tests/test_plot/test_int_bom.py +++ b/tests/test_plot/test_int_bom.py @@ -1283,3 +1283,22 @@ def test_int_bom_fil_1(): rows, header, info = ctx.load_csv('multi.csv') check_kibom_test_netlist(rows, ref_column, 1, None, ['C1-C2']) ctx.clean_up() + + +def test_int_bom_variant_t3(): + """ Test if we can move the filters to the variant. + Also test the '!' filter (always false) """ + prj = 'kibom-variante' + ctx = context.TestContextSCH('test_int_bom_variant_t3', prj, 'int_bom_var_t3_csv', BOM_DIR) + ctx.run() + rows, header, info = ctx.load_csv(prj+'-bom_(V1).csv') + ref_column = header.index(REF_COLUMN_NAME) + check_kibom_test_netlist(rows, ref_column, 2, ['R3', 'R4'], ['R1', 'R2']) + VARIANTE_PRJ_INFO[1] = 't1_v1' + check_csv_info(info, VARIANTE_PRJ_INFO, [4, 20, 2, 1, 2]) + ctx.search_err(r"Creating internal filter(.*)_mechanical") + ctx.search_err(r"Creating internal filter(.*)_kibom_dnf_Config") + ctx.search_err(r"Creating internal filter(.*)_kibom_dnc") + rows, header, info = ctx.load_csv(prj+'-bom_(V1b).csv') + # Here we remove the DNC, so R1 and R2 becomes identical + check_kibom_test_netlist(rows, ref_column, 1, ['R3', 'R4'], ['R1', 'R2']) diff --git a/tests/test_plot/test_yaml_errors.py b/tests/test_plot/test_yaml_errors.py index 864c3621..523b53c6 100644 --- a/tests/test_plot/test_yaml_errors.py +++ b/tests/test_plot/test_yaml_errors.py @@ -578,3 +578,17 @@ def test_error_fil_unknown(): ctx.run(EXIT_BAD_CONFIG) assert ctx.search_err("Unknown filter (.*) used for ") ctx.clean_up() + + +def test_error_var_unknown(): + ctx = context.TestContextSCH('test_error_var_unknown', 'links', 'error_unk_variant', '') + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("Unknown variant name") + ctx.clean_up() + + +def test_error_wrong_fil_name(): + ctx = context.TestContextSCH('test_error_wrong_fil_name', 'links', 'error_wrong_fil_name', '') + ctx.run(EXIT_BAD_CONFIG) + assert ctx.search_err("Filter names starting with (.*) are reserved") + ctx.clean_up() diff --git a/tests/yaml_samples/error_unk_variant.kibot.yaml b/tests/yaml_samples/error_unk_variant.kibot.yaml new file mode 100644 index 00000000..497a617f --- /dev/null +++ b/tests/yaml_samples/error_unk_variant.kibot.yaml @@ -0,0 +1,11 @@ +# Example KiBot config file +kibot: + version: 1 + +outputs: + - name: 'no_inductor' + comment: "Inductors removed" + type: sch_variant + dir: no_inductor + options: + variant: 'no_inductor' diff --git a/tests/yaml_samples/error_wrong_fil_name.kibot.yaml b/tests/yaml_samples/error_wrong_fil_name.kibot.yaml new file mode 100644 index 00000000..0fa2ccc5 --- /dev/null +++ b/tests/yaml_samples/error_wrong_fil_name.kibot.yaml @@ -0,0 +1,10 @@ +# Example KiBot config file +kibot: + version: 1 + +filters: + - name: '_no_inductor' + comment: 'Inductors removed' + type: generic + exclude_refs: + - L* diff --git a/tests/yaml_samples/int_bom_var_t3_csv.kibot.yaml b/tests/yaml_samples/int_bom_var_t3_csv.kibot.yaml new file mode 100644 index 00000000..15bbe700 --- /dev/null +++ b/tests/yaml_samples/int_bom_var_t3_csv.kibot.yaml @@ -0,0 +1,39 @@ +# Example KiBot config file +kibot: + version: 1 + + +variants: + - name: 't1_v1' + comment: 'Test 1 Variant V1' + type: kibom + file_id: '_(V1)' + variant: V1 + dnc_filter: '_kibom_dnc' + dnf_filter: '_kibom_dnf_Config' + exclude_filter: '_mechanical' + + - name: 't1_v1b' + comment: 'Test 1 Variant V1' + type: kibom + file_id: '_(V1b)' + variant: V1 + +outputs: + - name: 'bom_internal_v1' + comment: "Bill of Materials in CSV format for variant t1_v1" + type: bom + dir: BoM + options: + variant: t1_v1 + dnc_filter: '_none' + dnf_filter: '_none' + exclude_filter: '_none' + + - name: 'bom_internal_v1b' + comment: "Bill of Materials in CSV format for variant t1_v1" + type: bom + dir: BoM + options: + variant: t1_v1b + dnc_filter: '!'