aboutsummaryrefslogtreecommitdiffstats
path: root/datamaps/tests/test_cli.py
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2019-10-02 08:26:00 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2019-10-02 08:26:00 +0100
commit9a387339e1933cb7255b8dd1c8175a42be19b24d (patch)
tree679f696e0ad2fac0c91f94cc7692a78e3df96adc /datamaps/tests/test_cli.py
parenta15fd3fe7bead9599fbfe49d8b81ab227fd55259 (diff)
parent240e9d6dbb8b1e26c50889e3f91765f943b78740 (diff)
Merge branch 'master' of github.com:hammerheadlemon/datamaps
Diffstat (limited to '')
-rw-r--r--datamaps/tests/test_cli.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/datamaps/tests/test_cli.py b/datamaps/tests/test_cli.py
new file mode 100644
index 0000000..3857626
--- /dev/null
+++ b/datamaps/tests/test_cli.py
@@ -0,0 +1,34 @@
+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"),
+ )
+ result = runner.invoke(_import, ["templates", "-m"])
+ assert "Expected Sheet Missing: sheet Introduction in test_template.xlsm 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
+
+