diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2019-09-30 19:46:58 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2019-09-30 19:46:58 +0100 |
commit | 3fd0dec3a124df0c95dfd5843cdafc19abed6eca (patch) | |
tree | 6257d975658c2496b04c125ae64a14b8a092dd5d /datamaps/tests/test_cli.py | |
parent | 24240cdf548e4c047e81a0c8c4be0268c9fe044a (diff) |
starting to test cli now - starting with expected error from missing sheet in importable template
Diffstat (limited to '')
-rw-r--r-- | datamaps/tests/test_cli.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/datamaps/tests/test_cli.py b/datamaps/tests/test_cli.py new file mode 100644 index 0000000..506e4d6 --- /dev/null +++ b/datamaps/tests/test_cli.py @@ -0,0 +1,35 @@ +import os +import shutil +from pathlib import Path + +import pytest +from click.testing import CliRunner + +from datamaps.main import cli, _import + + +def test_no_expected_sheet_in_batch_import_to_master(mock_config, resource_dir): + """If there is a batch of spreadsheet files present + in the input directory, and at least one file is present + that does not have a sheet as named by the datamap, we want + the good files to process and the error file to be flagged, + but the process to continue where it can. + + KeyError thrown by engine.parsing.query_key() needs to be handled. + """ + runner = CliRunner() + mock_config.initialise() + for fl in os.listdir(resource_dir): + if os.path.isfile(os.path.join(resource_dir, fl)): + shutil.copy( + Path.cwd() / "tests" / "resources" / fl, + (Path(mock_config.PLATFORM_DOCS_DIR) / "input"), + ) + dm_file = mock_config.PLATFORM_DOCS_DIR / "input" / "datamap.csv" + result = runner.invoke(_import, ["templates", "-m"]) + assert "No sheet named Introduction in test_template.xlsm, which is expected from" \ + " datamap.csv. Not processing that file until fixed." in result.output + assert "Imported data from input/dft1_temp.xlsm to output/master.xlsx." in result.output + assert "Finished." in result.output + + |