From f7af2901130ac2ef3e0ca95e91280dfe9f073d1b Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 20 May 2020 11:34:47 -0300 Subject: [PATCH] Added update_xml test --- tests/test_plot/test_preflight.py | 21 +++++++++++++++++++++ tests/yaml_samples/update_xml.kiplot.yaml | 8 ++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/yaml_samples/update_xml.kiplot.yaml diff --git a/tests/test_plot/test_preflight.py b/tests/test_plot/test_preflight.py index 46303d2c..692ebc0f 100644 --- a/tests/test_plot/test_preflight.py +++ b/tests/test_plot/test_preflight.py @@ -4,6 +4,7 @@ Tests for the preflight options We test: - ERC - DRC +- XML update For debug information use: pytest-3 --log-cli-level debug @@ -12,6 +13,7 @@ pytest-3 --log-cli-level debug import os import sys +import logging # Look for the 'utils' module from where the script is running script_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.dirname(script_dir)) @@ -35,3 +37,22 @@ def test_drc(): # Check all outputs are there ctx.expect_out_file('drc_result.rpt') ctx.clean_up() + + +def test_update_xml(): + prj = 'bom' + ctx = context.TestContext('Update_XML', prj, 'update_xml', '') + # The XML should be created where the schematic is located + xml = os.path.abspath(os.path.join(ctx.get_board_dir(), prj+'.xml')) + os.rename(xml, xml+'-bak') + try: + ctx.run() + # Check all outputs are there + ctx.expect_out_file(prj+'.csv') + assert os.path.isfile(xml) + assert os.path.getsize(xml) > 0 + logging.debug(os.path.basename(xml)+' OK') + finally: + os.remove(xml) + os.rename(xml+'-bak', xml) + ctx.clean_up() diff --git a/tests/yaml_samples/update_xml.kiplot.yaml b/tests/yaml_samples/update_xml.kiplot.yaml new file mode 100644 index 00000000..8ed4c86c --- /dev/null +++ b/tests/yaml_samples/update_xml.kiplot.yaml @@ -0,0 +1,8 @@ +# Example KiPlot config file +kiplot: + version: 1 + +preflight: + update_xml: true + +