aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2019-10-02 20:22:53 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2019-10-02 20:22:53 +0100
commitcd83eadb211487857d113896a4b5f860746b034d (patch)
treee021f2ec13a4800232cb8ebec82282f417340305
parent80d26e1a5be3f32fe04154d6edc0de2744c62994 (diff)
cleanup
-rw-r--r--datamaps/tests/conftest.py5
-rw-r--r--datamaps/tests/test_cli.py35
2 files changed, 27 insertions, 13 deletions
diff --git a/datamaps/tests/conftest.py b/datamaps/tests/conftest.py
index 1e9bf07..97d4c76 100644
--- a/datamaps/tests/conftest.py
+++ b/datamaps/tests/conftest.py
@@ -1,8 +1,9 @@
import os
import shutil
+from pathlib import Path
import pytest
-from pathlib import Path
+
from engine.config import Config
@@ -36,4 +37,4 @@ def mock_config(monkeypatch):
@pytest.fixture
def resource_dir():
- return Path.cwd() / "tests" / "resources"
+ return Path.cwd() / "datamaps" / "tests" / "resources"
diff --git a/datamaps/tests/test_cli.py b/datamaps/tests/test_cli.py
index 883f54f..0429a3f 100644
--- a/datamaps/tests/test_cli.py
+++ b/datamaps/tests/test_cli.py
@@ -2,11 +2,34 @@ import os
import shutil
from pathlib import Path
+import pytest
from click.testing import CliRunner
from datamaps.main import _import
+def _copy_resources_to_input(config, directory):
+ """Helper func to move files from resources into temp Docs directories."""
+ for fl in os.listdir(directory):
+ if os.path.isfile(os.path.join(directory, fl)):
+ shutil.copy(
+ Path.cwd() / "datamaps" / "tests" / "resources" / fl,
+ (Path(config.PLATFORM_DOCS_DIR) / "input"),
+ )
+
+
+def test_error_report(mock_config, resource_dir):
+ runner = CliRunner()
+ mock_config.initialise()
+ _copy_resources_to_input(mock_config, resource_dir)
+ result = runner.invoke(_import, ["templates", "-m"])
+ output = result.output.split("\n")
+ assert "Import errors:" in output
+ 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
in the input directory, and at least one file is present
@@ -20,18 +43,8 @@ def test_no_expected_sheet_in_batch_import_to_master(mock_config, resource_dir):
mock_config.initialise()
_copy_resources_to_input(mock_config, resource_dir)
result = runner.invoke(_import, ["templates", "-m"])
+ output = result.output
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
-
-
-def _copy_resources_to_input(mock_config, resource_dir):
- 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"),
- )
-
-