Added tests for global and command line variant selection.
This commit is contained in:
parent
2c98b2b634
commit
257b9fdd3f
|
|
@ -1317,3 +1317,69 @@ def test_int_bom_variant_t3():
|
|||
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'])
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_int_bom_variant_cli():
|
||||
""" Assing t1_v1 to default from cli. Make sure t1_v3 isn't affected """
|
||||
prj = 'kibom-variante'
|
||||
ctx = context.TestContextSCH('test_int_bom_variant_cli', prj, 'int_bom_var_t1_cli', BOM_DIR)
|
||||
ctx.run(extra=['--global-redef', 'variant=t1_v1'])
|
||||
# No variant -> t1_v1
|
||||
logging.debug("* No variant -> t1_v1")
|
||||
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])
|
||||
# V3
|
||||
logging.debug("* t1_v3 variant")
|
||||
rows, header, info = ctx.load_csv(prj+'-bom_V3.csv')
|
||||
check_kibom_test_netlist(rows, ref_column, 1, ['R2', 'R3'], ['R1', 'R4'])
|
||||
VARIANTE_PRJ_INFO[1] = 't1_v3'
|
||||
check_csv_info(info, VARIANTE_PRJ_INFO, [3, 20, 2, 1, 2])
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_int_bom_variant_glb():
|
||||
""" Assing t1_v1 to default from global. Make sure t1_v3 isn't affected """
|
||||
prj = 'kibom-variante'
|
||||
ctx = context.TestContextSCH('test_int_bom_variant_glb', prj, 'int_bom_var_t1_glb', BOM_DIR)
|
||||
ctx.run()
|
||||
# No variant -> t1_v1
|
||||
logging.debug("* No variant -> t1_v1")
|
||||
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])
|
||||
# V3
|
||||
logging.debug("* t1_v3 variant")
|
||||
rows, header, info = ctx.load_csv(prj+'-bom_V3.csv')
|
||||
check_kibom_test_netlist(rows, ref_column, 1, ['R2', 'R3'], ['R1', 'R4'])
|
||||
VARIANTE_PRJ_INFO[1] = 't1_v3'
|
||||
check_csv_info(info, VARIANTE_PRJ_INFO, [3, 20, 2, 1, 2])
|
||||
|
||||
|
||||
def test_int_bom_variant_cl_gl():
|
||||
""" Assing t1_v1 to default from global.
|
||||
Overwrite it from cli to t1_v2.
|
||||
Make sure t1_v3 isn't affected """
|
||||
prj = 'kibom-variante'
|
||||
ctx = context.TestContextSCH('test_int_bom_variant_cl_gl', prj, 'int_bom_var_t1_glb', BOM_DIR)
|
||||
ctx.run(extra=['--global-redef', 'variant=t1_v2'])
|
||||
ctx.search_err(r'Using command line value .?t1_v2.? for global option .?variant.?')
|
||||
# No variant -> t1_v2
|
||||
logging.debug("* No variant -> t1_v2")
|
||||
rows, header, info = ctx.load_csv(prj+'-bom_(V2).csv')
|
||||
ref_column = header.index(REF_COLUMN_NAME)
|
||||
check_kibom_test_netlist(rows, ref_column, 1, ['R2', 'R4'], ['R1', 'R3'])
|
||||
VARIANTE_PRJ_INFO[1] = 't1_v2'
|
||||
check_csv_info(info, VARIANTE_PRJ_INFO, [3, 20, 2, 1, 2])
|
||||
# V3
|
||||
logging.debug("* t1_v3 variant")
|
||||
rows, header, info = ctx.load_csv(prj+'-bom_V3.csv')
|
||||
check_kibom_test_netlist(rows, ref_column, 1, ['R2', 'R3'], ['R1', 'R4'])
|
||||
VARIANTE_PRJ_INFO[1] = 't1_v3'
|
||||
check_csv_info(info, VARIANTE_PRJ_INFO, [3, 20, 2, 1, 2])
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
|
|
@ -498,3 +498,10 @@ def test_import_no_fail():
|
|||
if os.path.isfile(cache_file):
|
||||
os.remove(cache_file)
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_wrong_global_redef():
|
||||
ctx = context.TestContext('test_wrong_global_redef', '3Rs', 'pre_and_position', POS_DIR)
|
||||
ctx.run(EXIT_BAD_ARGS, extra=['--global-redef', 'bogus'])
|
||||
assert ctx.search_err('Malformed global-redef option')
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
|
||||
variants:
|
||||
- name: 't1_v1'
|
||||
comment: 'Test 1 Variant V1'
|
||||
type: kibom
|
||||
file_id: '_(V1)'
|
||||
variant: V1
|
||||
|
||||
- name: 't1_v2'
|
||||
comment: 'Test 1 Variant V2'
|
||||
type: kibom
|
||||
file_id: '_(V2)'
|
||||
variant: V2
|
||||
|
||||
- name: 't1_v3'
|
||||
comment: 'Test 1 Variant V3'
|
||||
type: kibom
|
||||
file_id: '_V3'
|
||||
variant: V3
|
||||
|
||||
- name: 'bla bla'
|
||||
comment: 'Test 1 Variant V1+V3'
|
||||
type: kibom
|
||||
file_id: '_bla_bla'
|
||||
variant: ['V1', 'V3']
|
||||
|
||||
outputs:
|
||||
- name: 'bom_internal'
|
||||
comment: "Bill of Materials in CSV format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
|
||||
- name: 'bom_internal_v3'
|
||||
comment: "Bill of Materials in CSV format for variant t1_v3"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
variant: t1_v3
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
global:
|
||||
variant: t1_v1
|
||||
|
||||
variants:
|
||||
- name: 't1_v1'
|
||||
comment: 'Test 1 Variant V1'
|
||||
type: kibom
|
||||
file_id: '_(V1)'
|
||||
variant: V1
|
||||
|
||||
- name: 't1_v2'
|
||||
comment: 'Test 1 Variant V2'
|
||||
type: kibom
|
||||
file_id: '_(V2)'
|
||||
variant: V2
|
||||
|
||||
- name: 't1_v3'
|
||||
comment: 'Test 1 Variant V3'
|
||||
type: kibom
|
||||
file_id: '_V3'
|
||||
variant: V3
|
||||
|
||||
- name: 'bla bla'
|
||||
comment: 'Test 1 Variant V1+V3'
|
||||
type: kibom
|
||||
file_id: '_bla_bla'
|
||||
variant: ['V1', 'V3']
|
||||
|
||||
outputs:
|
||||
- name: 'bom_internal'
|
||||
comment: "Bill of Materials in CSV format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
|
||||
- name: 'bom_internal_v3'
|
||||
comment: "Bill of Materials in CSV format for variant t1_v3"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
variant: t1_v3
|
||||
Loading…
Reference in New Issue