diff options
Diffstat (limited to 'datamaps/tests')
-rw-r--r-- | datamaps/tests/conftest.py | 8 | ||||
-rw-r--r-- | datamaps/tests/test_cli.py | 24 |
2 files changed, 32 insertions, 0 deletions
diff --git a/datamaps/tests/conftest.py b/datamaps/tests/conftest.py index aa59301..4faed8c 100644 --- a/datamaps/tests/conftest.py +++ b/datamaps/tests/conftest.py @@ -1,5 +1,7 @@ import os import shutil +import tempfile + from pathlib import Path import pytest @@ -13,6 +15,12 @@ def master() -> Path: @pytest.fixture +def temp_input_dir() -> Path: + pth = tempfile.mkdtemp() + yield pth + + +@pytest.fixture def mock_config(monkeypatch): monkeypatch.setattr(Config, "PLATFORM_DOCS_DIR", Path("/tmp/Documents/datamaps")) monkeypatch.setattr( diff --git a/datamaps/tests/test_cli.py b/datamaps/tests/test_cli.py index aef977c..a3a832f 100644 --- a/datamaps/tests/test_cli.py +++ b/datamaps/tests/test_cli.py @@ -20,6 +20,30 @@ def _copy_resources_to_input(config, directory): ) +def test_import_from_user_defined_source_dir( + mock_config, resource_dir, caplog, temp_input_dir +): + runner = CliRunner() + mock_config.initialise() + caplog.set_level(logging.INFO) + for fl in os.listdir(resource_dir): + shutil.copy( + Path.cwd() / "datamaps" / "tests" / "resources" / fl, temp_input_dir + ) + result = runner.invoke(_import, ["templates", "-m", "--inputdir", temp_input_dir]) + assert result.exit_code == 0 + output = [x[2] for x in caplog.record_tuples] + found = False + for o in output: + if f"Reading datamap {temp_input_dir}/" in o: + found = True + break + if found: + assert True + else: + assert False, "Cannot find correct string" + + @pytest.mark.parametrize( "rowlimit,expected,exit_code", [ |