aboutsummaryrefslogtreecommitdiffstats
path: root/datamaps/tests/test_cli.py
diff options
context:
space:
mode:
Diffstat (limited to 'datamaps/tests/test_cli.py')
-rw-r--r--datamaps/tests/test_cli.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/datamaps/tests/test_cli.py b/datamaps/tests/test_cli.py
index 6dd5154..827d690 100644
--- a/datamaps/tests/test_cli.py
+++ b/datamaps/tests/test_cli.py
@@ -1,3 +1,4 @@
+import logging
import os
import shutil
from pathlib import Path
@@ -18,6 +19,37 @@ def _copy_resources_to_input(config, directory):
)
+def test_can_select_datamap_when_importing(mock_config, resource_dir, caplog):
+ """
+ This should fail with exit code one as we are not providing a valid datamap file.
+ :param mock_config:
+ :param resource_dir:
+ :return:
+ """
+ runner = CliRunner()
+ mock_config.initialise()
+ caplog.set_level(logging.INFO)
+ _copy_resources_to_input(mock_config, resource_dir)
+ _alt_datamap_file = os.path.join(mock_config.PLATFORM_DOCS_DIR, "input", "datamap_alternate.csv")
+ result = runner.invoke(_import, ["templates", "-m", "-d", _alt_datamap_file])
+ assert result.exit_code == 0
+ assert "Reading datamap \\tmp\\Documents\\datamaps\\input\\datamap_alternate.csv" in [x[2] for x in caplog.record_tuples]
+
+
+def test_wrong_datamap_given(mock_config, resource_dir):
+ """
+ This should fail with exit code one as we are not providing a valid datamap file.
+ :param mock_config:
+ :param resource_dir:
+ :return:
+ """
+ runner = CliRunner()
+ mock_config.initialise()
+ _copy_resources_to_input(mock_config, resource_dir)
+ result = runner.invoke(_import, ["templates", "-m", "-d", "C:/tmp/non-existant-file.txt"])
+ assert result.exit_code == 1
+
+
@pytest.mark.skip("Not currently passing - need to investigate")
def test_error_report(mock_config, resource_dir):
runner = CliRunner()
@@ -29,7 +61,6 @@ def test_error_report(mock_config, resource_dir):
assert "\tNo sheet named Introduction in test_template.xlsm" in output
-
@pytest.mark.skip("Complete after error report code complete")
def test_no_expected_sheet_in_batch_import_to_master(mock_config, resource_dir):
"""If there is a batch of spreadsheet files present