Added tests for the missing lines in out_ibom.py.
This commit is contained in:
parent
10f0706482
commit
d5a31c6d87
|
|
@ -589,7 +589,10 @@ def test_makefile_1(test_dir):
|
||||||
deps = targets['interactive_bom'].split(' ')
|
deps = targets['interactive_bom'].split(' ')
|
||||||
assert len(deps) == 1, deps
|
assert len(deps) == 1, deps
|
||||||
assert ctx.get_out_path(os.path.join('ibom', prj+'-ibom.html')) in deps
|
assert ctx.get_out_path(os.path.join('ibom', prj+'-ibom.html')) in deps
|
||||||
assert os.path.abspath(targets[targets['interactive_bom']]) == ctx.board_file
|
deps = targets[targets['interactive_bom']].split(' ')
|
||||||
|
assert len(deps) == 2
|
||||||
|
assert os.path.relpath(ctx.board_file) in deps
|
||||||
|
assert 'tests/board_samples/kicad_5/bom.xml' in deps
|
||||||
logging.debug('- Target `interactive_bom` OK')
|
logging.debug('- Target `interactive_bom` OK')
|
||||||
# pcb_render target
|
# pcb_render target
|
||||||
deps = targets['pcb_render'].split(' ')
|
deps = targets['pcb_render'].split(' ')
|
||||||
|
|
@ -651,6 +654,7 @@ def test_makefile_1(test_dir):
|
||||||
assert ctx.get_out_path('gerbers') in deps
|
assert ctx.get_out_path('gerbers') in deps
|
||||||
logging.debug('- Target `archive` OK')
|
logging.debug('- Target `archive` OK')
|
||||||
ctx.search_err(r'\(kibom_external\) \[kibom\] uses a name generated by the external tool')
|
ctx.search_err(r'\(kibom_external\) \[kibom\] uses a name generated by the external tool')
|
||||||
|
ctx.search_err(r'\(ibom_external\) \[ibom\] uses a name generated by the external tool')
|
||||||
ctx.search_err(r'Wrong character in file name `(.*)/test_makefile_1/test_v5-top\$.svg')
|
ctx.search_err(r'Wrong character in file name `(.*)/test_makefile_1/test_v5-top\$.svg')
|
||||||
ctx.clean_up()
|
ctx.clean_up()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,12 @@ from kibot.out_base import BaseOutput
|
||||||
from kibot.gs import GS
|
from kibot.gs import GS
|
||||||
from kibot.kiplot import load_actions, _import
|
from kibot.kiplot import load_actions, _import
|
||||||
from kibot.registrable import RegOutput
|
from kibot.registrable import RegOutput
|
||||||
from kibot.misc import (MISSING_TOOL, WRONG_INSTALL)
|
from kibot.misc import (MISSING_TOOL, WRONG_INSTALL, BOM_ERROR)
|
||||||
|
|
||||||
|
|
||||||
cov = coverage.Coverage()
|
cov = coverage.Coverage()
|
||||||
mocked_check_output_FNF = True
|
mocked_check_output_FNF = True
|
||||||
|
mocked_check_output_retOK = ''
|
||||||
|
|
||||||
|
|
||||||
# Important note:
|
# Important note:
|
||||||
|
|
@ -33,6 +34,8 @@ def mocked_check_output(cmd, stderr=None):
|
||||||
if mocked_check_output_FNF:
|
if mocked_check_output_FNF:
|
||||||
raise FileNotFoundError()
|
raise FileNotFoundError()
|
||||||
else:
|
else:
|
||||||
|
if mocked_check_output_retOK:
|
||||||
|
return mocked_check_output_retOK
|
||||||
e = CalledProcessError(10, 'rar')
|
e = CalledProcessError(10, 'rar')
|
||||||
e.output = b'THE_ERROR'
|
e.output = b'THE_ERROR'
|
||||||
raise e
|
raise e
|
||||||
|
|
@ -127,3 +130,34 @@ def test_no_get_targets(caplog):
|
||||||
cov.save()
|
cov.save()
|
||||||
assert "Output 'Fake' (dummy) [none] doesn't implement get_targets(), plese report it" in caplog.text
|
assert "Output 'Fake' (dummy) [none] doesn't implement get_targets(), plese report it" in caplog.text
|
||||||
assert files == [GS.sch_file]
|
assert files == [GS.sch_file]
|
||||||
|
|
||||||
|
|
||||||
|
def test_ibom_parse_fail(test_dir, caplog, monkeypatch):
|
||||||
|
global mocked_check_output_FNF
|
||||||
|
mocked_check_output_FNF = False
|
||||||
|
global mocked_check_output_retOK
|
||||||
|
mocked_check_output_retOK = b'ERROR Parsing failed'
|
||||||
|
# We will patch subprocess.check_output to make ibom fail
|
||||||
|
with monkeypatch.context() as m:
|
||||||
|
m.setattr("subprocess.check_output", mocked_check_output)
|
||||||
|
# Start coverage
|
||||||
|
cov.load()
|
||||||
|
cov.start()
|
||||||
|
# Load the plug-ins
|
||||||
|
load_actions()
|
||||||
|
# Create an ibom object
|
||||||
|
out = RegOutput.get_class_for('ibom')()
|
||||||
|
out.set_tree({})
|
||||||
|
out.config()
|
||||||
|
# Setup the GS output dir, needed for the output path
|
||||||
|
#GS.out_dir = '.'
|
||||||
|
with pytest.raises(SystemExit) as pytest_wrapped_e:
|
||||||
|
out.run('')
|
||||||
|
# Stop coverage
|
||||||
|
cov.stop()
|
||||||
|
cov.save()
|
||||||
|
assert pytest_wrapped_e.type == SystemExit
|
||||||
|
assert pytest_wrapped_e.value.code == BOM_ERROR
|
||||||
|
# logging.debug(caplog.text)
|
||||||
|
assert "Failed to create BoM" in caplog.text
|
||||||
|
mocked_check_output_retOK = ''
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,15 @@ outputs:
|
||||||
comment: 'Interactive assembly guide'
|
comment: 'Interactive assembly guide'
|
||||||
type: ibom
|
type: ibom
|
||||||
dir: ibom
|
dir: ibom
|
||||||
|
options:
|
||||||
|
netlist_file: 'tests/board_samples/kicad_5/bom.xml'
|
||||||
|
|
||||||
|
- name: 'ibom_external'
|
||||||
|
comment: 'Interactive assembly guide w/external name'
|
||||||
|
type: ibom
|
||||||
|
dir: ibom
|
||||||
|
options:
|
||||||
|
output: ''
|
||||||
|
|
||||||
- name: '3D'
|
- name: '3D'
|
||||||
comment: 'STEP 3D model'
|
comment: 'STEP 3D model'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue