1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
from unittest.mock import ANY, MagicMock
from ...utils import NoMatchString, PartialMatchString
def test_no_test_dir(convert_command, monkeypatch):
mock_text_question = MagicMock()
monkeypatch.setattr(convert_command.console, "text_question", mock_text_question)
convert_command.input_test_source_dir("app_name", None)
intro_content = "\n\nBased on your project's folder structure, we believe 'test' might be your test directory"
mock_text_question.assert_called_once_with(
intro=NoMatchString(intro_content),
description="Test Source Directory",
default="tests",
validator=ANY,
override_value=None,
)
def test_test_dir(convert_command, monkeypatch):
mock_text_question = MagicMock()
monkeypatch.setattr(convert_command.console, "text_question", mock_text_question)
(convert_command.base_path / "test").mkdir()
convert_command.input_test_source_dir("app_name", None)
intro_content = "\n\nBased on your project's folder structure, we believe 'test' might be your test directory"
mock_text_question.assert_called_once_with(
intro=PartialMatchString(intro_content),
description="Test Source Directory",
default="test",
validator=ANY,
override_value=None,
)
def test_tests_dir(convert_command, monkeypatch):
mock_text_question = MagicMock()
monkeypatch.setattr(convert_command.console, "text_question", mock_text_question)
(convert_command.base_path / "tests").mkdir()
convert_command.input_test_source_dir("app_name", None)
intro_content = "\n\nBased on your project's folder structure, we believe 'tests' might be your test directory"
mock_text_question.assert_called_once_with(
intro=PartialMatchString(intro_content),
description="Test Source Directory",
default="tests",
validator=ANY,
override_value=None,
)
def test_tests_dir_is_prefered_over_test_dir(convert_command, monkeypatch):
mock_text_question = MagicMock()
monkeypatch.setattr(convert_command.console, "text_question", mock_text_question)
(convert_command.base_path / "tests").mkdir()
(convert_command.base_path / "test").mkdir()
convert_command.input_test_source_dir("app_name", None)
intro_content = "\n\nBased on your project's folder structure, we believe 'tests' might be your test directory"
mock_text_question.assert_called_once_with(
intro=PartialMatchString(intro_content),
description="Test Source Directory",
default="tests",
validator=ANY,
override_value=None,
)
def test_override_is_used(convert_command):
(convert_command.base_path / "test_dir").mkdir()
assert convert_command.input_test_source_dir("app_name", "test_dir") == "test_dir"
def test_prompted_test_source_dir(convert_command):
"""You can type in the test source dir."""
(convert_command.base_path / "mytest").mkdir(parents=True)
convert_command.console.values = ["mytest"]
assert convert_command.input_test_source_dir("app_name", None) == "mytest"
|