Adapted the tests for missing tools to the new mechanism

This commit is contained in:
Salvador E. Tropea 2022-07-05 13:49:01 -03:00
parent 0635a249f3
commit 420757880f
2 changed files with 21 additions and 3 deletions

View File

@ -67,7 +67,7 @@ def run_compress(ctx, test_import_fail=False):
init_globals()
# Create a compress object with the dummy file as source
out = RegOutput.get_class_for('compress')()
out.set_tree({'options': {'format': 'RAR', 'files': [{'source': ctx.get_out_path('*')}]}})
out.set_tree({'type': 'compress', 'options': {'format': 'RAR', 'files': [{'source': ctx.get_out_path('*')}]}})
out.config(None)
# Setup the GS output dir, needed for the output path
GS.out_dir = '.'
@ -169,6 +169,7 @@ def test_ibom_parse_fail(test_dir, caplog, monkeypatch):
# Create an ibom object
out = RegOutput.get_class_for('ibom')()
out.set_tree({})
out.type = 'ibom'
out.config(None)
with pytest.raises(SystemExit) as pytest_wrapped_e:
out.run('')
@ -227,6 +228,7 @@ def test_pre_xrc_fail(test_dir, caplog, monkeypatch):
out = RegOutput.get_class_for('pdf_pcb_print')()
out.set_tree({'layers': 'all'})
out.config(None)
out.type = 'pdf_pcb_print'
with pytest.raises(SystemExit) as e3:
out.run('')
assert e1.type == SystemExit
@ -268,6 +270,7 @@ def test_step_fail(test_dir, caplog, monkeypatch):
out = RegOutput.get_class_for('step')()
out.set_tree({})
out.config(None)
out.type = 'step'
with pytest.raises(SystemExit) as e:
out.run('')
# Check we exited because rar isn't installed

View File

@ -76,6 +76,16 @@ def platform_system_bogus():
return 'Bogus'
class DummyPcbDraw(object):
def __init__(self):
self.type = 'pcbdraw'
DEPS = {'Dependencies': [{'name': 'pcbdraw', 'command': 'pcbdraw', 'role': 'mandatory'},
{'name': 'RSVG', 'command': 'rsvg-convert', 'role': 'XXXX', 'debian': 'librsvg2-bin'},
{'name': 'ImageMagick', 'command': 'convert', 'role': 'XXXX', 'debian': 'imagemagick'}]}
def test_pcbdraw_miss_rsvg(caplog, monkeypatch):
""" Check missing rsvg-convert """
with monkeypatch.context() as m:
@ -88,7 +98,9 @@ def test_pcbdraw_miss_rsvg(caplog, monkeypatch):
# Make platform.system() return a bogus OS
m.setattr("platform.system", platform_system_bogus)
# Reload the module so we get the above patches
reload(kibot.dep_downloader)
mod = reload(kibot.dep_downloader)
mod.register_deps('pcbdraw', DEPS)
logging.error(mod.used_deps)
old_lev = kibot.log.debug_level
kibot.log.debug_level = 2
o = PcbDrawOptions()
@ -96,6 +108,7 @@ def test_pcbdraw_miss_rsvg(caplog, monkeypatch):
o.remap = None
o.format = 'jpg'
o.config(None)
o._parent = DummyPcbDraw()
cov.load()
cov.start()
o.run('')
@ -115,12 +128,14 @@ def test_pcbdraw_miss_convert(caplog, monkeypatch):
# Make platform.system() return a bogus OS
m.setattr("platform.system", platform_system_bogus)
# Reload the module so we get the above patches
reload(kibot.dep_downloader)
mod = reload(kibot.dep_downloader)
mod.register_deps('pcbdraw', DEPS)
o = PcbDrawOptions()
o.style = ''
o.remap = None
o.format = 'jpg'
o.config(None)
o._parent = DummyPcbDraw()
cov.load()
cov.start()
o.run('')