From 420757880f339087a9435de8dd700e24bb331a56 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 5 Jul 2022 13:49:01 -0300 Subject: [PATCH] Adapted the tests for missing tools to the new mechanism --- tests/test_plot/test_misc_2.py | 5 ++++- tests/test_plot/test_pcbdraw.py | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/test_plot/test_misc_2.py b/tests/test_plot/test_misc_2.py index 2016f554..e31d1697 100644 --- a/tests/test_plot/test_misc_2.py +++ b/tests/test_plot/test_misc_2.py @@ -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 diff --git a/tests/test_plot/test_pcbdraw.py b/tests/test_plot/test_pcbdraw.py index 4f6699bb..c42965b3 100644 --- a/tests/test_plot/test_pcbdraw.py +++ b/tests/test_plot/test_pcbdraw.py @@ -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('')