Added more tests for the filters and variants

This commit is contained in:
Salvador E. Tropea 2020-08-30 11:55:35 -03:00
parent 41c66b1ab4
commit 0f0aa71baa
16 changed files with 442 additions and 2 deletions

View File

@ -0,0 +1,116 @@
EESchema Schematic File Version 4
EELAYER 30 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title "KiBot Filters Test Schematic"
Date "2020-08-30"
Rev "r1"
Comp "https://github.com/INTI-CMNB/KiBot"
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L Device:R R1
U 1 1 5E6A2873
P 2200 2550
F 0 "R1" V 2280 2550 50 0000 C CNN
F 1 " " V 2200 2550 50 0000 C CNN
F 2 "Resistor_SMD:R_0805_2012Metric" V 2130 2550 50 0001 C CNN
F 3 "~" H 2200 2550 50 0001 C CNN
1 2200 2550
1 0 0 -1
$EndComp
$Comp
L Device:R R2
U 1 1 5E6A330D
P 2500 2550
F 0 "R2" V 2580 2550 50 0000 C CNN
F 1 "~" V 2500 2550 50 0000 C CNN
F 2 "Resistor_SMD:R_0805_2012Metric" V 2430 2550 50 0001 C CNN
F 3 "~" H 2500 2550 50 0001 C CNN
1 2500 2550
1 0 0 -1
$EndComp
Text Notes 2750 2600 0 50 ~ 0
Empty value
$Comp
L Device:R R3
U 1 1 5E6A3CA0
P 2200 3100
F 0 "R3" V 2280 3100 50 0000 C CNN
F 1 "4K7" V 2200 3100 50 0000 C CNN
F 2 "Resistor_SMD:R_0805_2012Metric" V 2130 3100 50 0001 C CNN
F 3 "~" H 2200 3100 50 0001 C CNN
F 4 "" V 2200 3100 50 0001 C CNN "K K"
1 2200 3100
1 0 0 -1
$EndComp
$Comp
L Device:R R4
U 1 1 5E6A3F38
P 2500 3100
F 0 "R4" V 2580 3100 50 0000 C CNN
F 1 "4700" V 2500 3100 50 0000 C CNN
F 2 "Resistor_SMD:R_0805_2012Metric" V 2430 3100 50 0001 C CNN
F 3 "http://www.google.com/" H 2500 3100 50 0001 C CNN
F 4 "" V 2500 3100 50 0001 C CNN "Q,Q"
1 2500 3100
1 0 0 -1
$EndComp
Text Notes 2750 3150 0 50 ~ 0
With "K K" and "Q,Q" field
$Comp
L Device:R R5
U 1 1 5E6A448B
P 2200 3650
F 0 "R5" V 2280 3650 50 0000 C CNN
F 1 "1k" V 2200 3650 50 0000 C CNN
F 2 "Resistor_SMD:R_0603_1608Metric" V 2130 3650 50 0001 C CNN
F 3 "~" H 2200 3650 50 0001 C CNN
F 4 "K K" V 2200 3650 50 0001 C CNN "BB"
1 2200 3650
1 0 0 -1
$EndComp
$Comp
L Device:R R6
U 1 1 5E6A491A
P 2500 3650
F 0 "R6" V 2580 3650 50 0000 C CNN
F 1 "1000" V 2500 3650 50 0000 C CNN
F 2 "Resistor_SMD:R_0603_1608Metric" V 2430 3650 50 0001 C CNN
F 3 "~" H 2500 3650 50 0001 C CNN
F 4 "Q,Q" V 2500 3650 50 0001 C CNN "BB"
1 2500 3650
1 0 0 -1
$EndComp
Text Notes 2750 3700 0 50 ~ 0
BB field containing "K K" and "Q,Q"
Text Notes 600 1250 0 157 ~ 0
This schematic serves as a test-file for the KiBot export script.\n\nHere we play with filters.
$Comp
L Device:C C1
U 1 1 5E6A62CC
P 6650 2550
F 0 "C1" H 6675 2650 50 0000 L CNN
F 1 "10nF" H 6675 2450 50 0000 L CNN
F 2 "Capacitor_SMD:C_0603_1608Metric" H 6688 2400 50 0001 C CNN
F 3 "This is a long text, wrap check" H 6650 2550 50 0001 C CNN
1 6650 2550
1 0 0 -1
$EndComp
$Comp
L Device:C C2
U 1 1 5E6A6854
P 7050 2550
F 0 "C2" H 7075 2650 50 0000 L CNN
F 1 "10n" H 7075 2450 50 0000 L CNN
F 2 "Capacitor_SMD:C_0603_1608Metric" H 7088 2400 50 0001 C CNN
F 3 "~" H 7050 2550 50 0001 C CNN
1 7050 2550
1 0 0 -1
$EndComp
$EndSCHEMATC

View File

@ -31,9 +31,7 @@ Tests of Internal BoM files
- No XLSX support
Missing:
- Variants
- number_boards
- XLSX/HTML colors (for real)
For debug information use:
@ -1212,6 +1210,18 @@ def test_int_bom_variant_t2():
ctx.clean_up()
def test_int_bom_variant_t2s():
prj = 'kibom-variant_2'
ctx = context.TestContextSCH('test_int_bom_variant_t2s', prj, 'int_bom_var_t2s_csv', BOM_DIR)
ctx.run(extra_debug=True)
rows, header, info = ctx.load_csv(prj+'-bom_(dummy).csv')
ref_column = header.index(REF_COLUMN_NAME)
check_kibom_test_netlist(rows, ref_column, 1, ['C1', 'C2'], ['R1', 'R2'])
rows, header, info = ctx.load_csv(prj+'-bom_(dummy2).csv')
check_kibom_test_netlist(rows, ref_column, 1, ['C1', 'C2'], ['R1', 'R2'])
ctx.clean_up()
def test_int_bom_variant_t2i():
prj = 'kibom-variant_3'
ctx = context.TestContextSCH('test_int_bom_variant_t2i', prj, 'int_bom_var_t2i_csv', BOM_DIR)
@ -1226,3 +1236,50 @@ def test_int_bom_variant_t2i():
rows, header, info = ctx.load_csv(prj+'-bom_(test).csv')
check_kibom_test_netlist(rows, ref_column, 2, ['R2'], ['R1', 'C1', 'C2'])
ctx.clean_up()
def test_int_bom_variant_t2is():
prj = 'kibom-variant_3'
ctx = context.TestContextSCH('test_int_bom_variant_t2is', prj, 'int_bom_var_t2is_csv', BOM_DIR)
ctx.run(extra_debug=True)
rows, header, info = ctx.load_csv('filter_R1.csv')
ref_column = header.index(REF_COLUMN_NAME)
check_kibom_test_netlist(rows, ref_column, 1, ['R2', 'R1'], ['C1', 'C2'])
ctx.clean_up()
def test_int_bom_wrong_variant():
ctx = context.TestContextSCH('test_int_bom_wrong_variant', 'links', 'int_bom_wrong_variant', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("Unknown variant name")
ctx.clean_up()
def test_int_bom_fil_dummy():
prj = 'kibom-test-4'
ctx = context.TestContextSCH('test_int_bom_fil_dummy', prj, 'int_bom_fil_dummy', BOM_DIR)
ctx.run()
rows, header, info = ctx.load_csv(prj+'-bom.csv')
ref_column = header.index(REF_COLUMN_NAME)
check_kibom_test_netlist(rows, ref_column, 4, None, ['R1-R2', 'R3-R4', 'R5-R6', 'C1-C2'])
ctx.clean_up()
def test_int_bom_fil_1():
prj = 'kibom-test-4'
ctx = context.TestContextSCH('test_int_bom_fil_1', prj, 'int_bom_fil_1', BOM_DIR)
ctx.run()
rows, header, info = ctx.load_csv('empty_val.csv')
ref_column = header.index(REF_COLUMN_NAME)
check_kibom_test_netlist(rows, ref_column, 3, None, ['R3-R4', 'R5-R6', 'C1-C2'])
rows, header, info = ctx.load_csv('by_prefix.csv')
check_kibom_test_netlist(rows, ref_column, 3, None, ['R2', 'R3-R4', 'R5-R6'])
rows, header, info = ctx.load_csv('no_kk.csv')
check_kibom_test_netlist(rows, ref_column, 3, None, ['R1-R2', 'R5-R6', 'C1-C2'])
rows, header, info = ctx.load_csv('no_conf_kk.csv')
check_kibom_test_netlist(rows, ref_column, 3, None, ['R1-R2', 'R3-R4', 'C1-C2'])
rows, header, info = ctx.load_csv('no_by_prefix.csv')
check_kibom_test_netlist(rows, ref_column, 2, None, ['R1', 'C1-C2'])
rows, header, info = ctx.load_csv('multi.csv')
check_kibom_test_netlist(rows, ref_column, 1, None, ['C1-C2'])
ctx.clean_up()

View File

@ -529,3 +529,52 @@ def test_error_int_bom_logo_format():
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("Only PNG images are supported for the logo")
ctx.clean_up()
def test_error_var_no_name():
ctx = context.TestContextSCH('test_error_var_no_name', 'links', 'error_var_no_name', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("Variant needs a name in:")
ctx.clean_up()
def test_error_var_empty_name():
ctx = context.TestContextSCH('test_error_var_empty_name', 'links', 'error_var_empty_name', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("Variant needs a name in:")
ctx.clean_up()
def test_error_var_wrong_type():
ctx = context.TestContextSCH('test_error_var_wrong_type', 'links', 'error_var_wrong_type', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("Unknown variant type")
ctx.clean_up()
def test_error_var_no_type():
ctx = context.TestContextSCH('test_error_var_no_type', 'links', 'error_var_no_type', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("Variant (.*) needs a type")
ctx.clean_up()
def test_error_var_no_list():
ctx = context.TestContextSCH('test_error_var_no_list', 'links', 'error_var_no_list', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err(".?variants.? must be a list")
ctx.clean_up()
def test_error_fil_no_list():
ctx = context.TestContextSCH('test_error_fil_no_list', 'links', 'error_fil_no_list', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err(".?filters.? must be a list")
ctx.clean_up()
def test_error_fil_unknown():
ctx = context.TestContextSCH('test_error_fil_unknown', 'links', 'error_fil_unknown', '')
ctx.run(EXIT_BAD_CONFIG)
assert ctx.search_err("Unknown filter (.*) used for ")
ctx.clean_up()

View File

@ -0,0 +1,6 @@
kibot:
version: 1
filters:
name: ok
type: 'generic'

View File

@ -0,0 +1,14 @@
# Example KiBot config file
kibot:
version: 1
outputs:
- name: 'empty_val'
comment: "BoM no empty val"
type: bom
dir: BoM
options:
output: 'empty_val.csv'
use_alt: true
exclude_filter: 'empty val'

View File

@ -0,0 +1,6 @@
kibot:
version: 1
variants:
- name: ''
- type: 'generic'

View File

@ -0,0 +1,6 @@
kibot:
version: 1
variants:
name: ok
type: 'generic'

View File

@ -0,0 +1,5 @@
kibot:
version: 1
variants:
- type: 'generic'

View File

@ -0,0 +1,6 @@
kibot:
version: 1
variants:
- name: ok

View File

@ -0,0 +1,6 @@
kibot:
version: 1
variants:
- name: ok
type: ''

View File

@ -0,0 +1,86 @@
# Example KiBot config file
kibot:
version: 1
filters:
- name: 'empty val'
type: 'generic'
comment: 'Remove components with empty value'
exclude_empty_val: true
- name: 'by prefix'
type: 'generic'
comment: 'Remove components by prefix'
exclude_refs:
- R1
- C*
- name: no_KK_Q,Q
type: 'generic'
comment: 'Remove components with K K and Q,Q fields'
keys: ['K K', 'Q,Q']
exclude_field: true
- name: no Conf KK
type: 'generic'
comment: 'Remove components with K K and Q,Q in config'
keys: ['K K', 'Q,Q']
exclude_config: true
config_separators: ''
config_field: BB
outputs:
- name: 'empty_val'
comment: "BoM no empty val"
type: bom
dir: BoM
options:
output: 'empty_val.csv'
use_alt: true
exclude_filter: 'empty val'
- name: 'by_prefix'
comment: "BoM no R1 C*"
type: bom
dir: BoM
options:
output: 'by_prefix.csv'
use_alt: true
exclude_filter: 'by prefix'
- name: 'no_KK'
comment: "BoM no K K/Q,Q"
type: bom
dir: BoM
options:
output: 'no_kk.csv'
use_alt: true
exclude_filter: 'no_KK_Q,Q'
- name: 'no conf KK'
comment: "BoM no K K/Q,Q in config"
type: bom
dir: BoM
options:
output: 'no_conf_kk.csv'
use_alt: true
exclude_filter: 'no Conf KK'
- name: 'no_by_prefix'
comment: "BoM R1 C*"
type: bom
dir: BoM
options:
output: 'no_by_prefix.csv'
use_alt: true
exclude_filter: '!by prefix'
- name: 'multi'
comment: "BoM C*"
type: bom
dir: BoM
options:
output: 'multi.csv'
use_alt: true
exclude_filter: ['!by prefix', 'empty val']

View File

@ -0,0 +1,13 @@
# Example KiBot config file
kibot:
version: 1
outputs:
- name: 'bom_internal'
comment: "Bill of Materials in CSV format"
type: bom
dir: BoM
options:
use_alt: true
exclude_filter: ''

View File

@ -19,6 +19,7 @@ variants:
comment: 'Default variant'
type: ibom
variants_blacklist: T2,T3
variants_whitelist: ''
- name: 'default2'
comment: 'Default variant 2'

View File

@ -0,0 +1,27 @@
# Example KiBot config file
kibot:
version: 1
filters:
- name: 'no R1'
type: 'generic'
comment: 'Remove components by prefix'
exclude_refs:
- R1
variants:
- name: 'test'
comment: 'Test variant'
type: ibom
file_id: '_(test)'
variants_blacklist: T1
outputs:
- name: 'bom filtered'
comment: "Bill of Materials test, no R1"
type: bom
dir: BoM
options:
exclude_filter: no R1
variant: test
output: filter_R1.csv

View File

@ -0,0 +1,31 @@
# Example KiBot config file
kibot:
version: 1
variants:
- name: 'dummy'
comment: 'Dummy variant'
type: kibom
file_id: '_(dummy)'
variant: ''
- name: 'dummy2'
comment: 'Dummy 2 variant'
type: kibom
file_id: '_(dummy2)'
outputs:
- name: 'bom_internal_dummy'
comment: "Bill of Materials in CSV format"
type: bom
dir: BoM
options:
variant: dummy
- name: 'bom_internal_dummy2'
comment: "Bill of Materials in CSV format"
type: bom
dir: BoM
options:
variant: dummy2

View File

@ -0,0 +1,11 @@
# Example KiBot config file
kibot:
version: 1
outputs:
- name: 'bom_internal2'
comment: "Bill of Materials in CSV format (2)"
type: bom
dir: BoM
options:
variant: foobar