forked from p34709852/monkey
Island UT's: rename methods that return directories from "mocked_..." notation to "temp_..." notation in test_data_dir.py
This commit is contained in:
parent
93adbae2bf
commit
c9335f90a4
|
@ -18,61 +18,61 @@ def mock_version(monkeypatch):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def mocked_data_dir_path(tmpdir) -> Path:
|
||||
def temp_data_dir_path(tmpdir) -> Path:
|
||||
return Path(tmpdir, "data_dir")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mocked_version_file_path(mocked_data_dir_path: Path) -> Path:
|
||||
return mocked_data_dir_path.joinpath(_version_filename)
|
||||
def temp_version_file_path(temp_data_dir_path) -> Path:
|
||||
return temp_data_dir_path.joinpath(_version_filename)
|
||||
|
||||
|
||||
def test_setup_data_dir(mocked_data_dir_path, mocked_version_file_path):
|
||||
data_dir_path = mocked_data_dir_path
|
||||
def test_setup_data_dir(temp_data_dir_path, temp_version_file_path):
|
||||
data_dir_path = temp_data_dir_path
|
||||
setup_data_dir(data_dir_path)
|
||||
assert data_dir_path.is_dir()
|
||||
|
||||
version_file_path = mocked_version_file_path
|
||||
version_file_path = temp_version_file_path
|
||||
assert version_file_path.read_text() == current_version
|
||||
|
||||
|
||||
def test_old_version_present(mocked_data_dir_path, mocked_version_file_path):
|
||||
mocked_data_dir_path.mkdir()
|
||||
mocked_version_file_path.write_text(old_version)
|
||||
bogus_file_path = mocked_data_dir_path.joinpath("test.txt")
|
||||
def test_old_version_present(temp_data_dir_path, temp_version_file_path):
|
||||
temp_data_dir_path.mkdir()
|
||||
temp_version_file_path.write_text(old_version)
|
||||
bogus_file_path = temp_data_dir_path.joinpath("test.txt")
|
||||
bogus_file_path.touch()
|
||||
|
||||
setup_data_dir(mocked_data_dir_path)
|
||||
setup_data_dir(temp_data_dir_path)
|
||||
|
||||
assert mocked_version_file_path.read_text() == current_version
|
||||
assert temp_version_file_path.read_text() == current_version
|
||||
assert not bogus_file_path.is_file()
|
||||
assert _get_backup_path(mocked_data_dir_path).joinpath("test.txt").is_file()
|
||||
assert _get_backup_path(temp_data_dir_path).joinpath("test.txt").is_file()
|
||||
|
||||
|
||||
def test_old_version_and_backup_present(mocked_data_dir_path, mocked_version_file_path):
|
||||
mocked_data_dir_path.mkdir()
|
||||
mocked_version_file_path.write_text(old_version)
|
||||
def test_old_version_and_backup_present(temp_data_dir_path, temp_version_file_path):
|
||||
temp_data_dir_path.mkdir()
|
||||
temp_version_file_path.write_text(old_version)
|
||||
|
||||
old_backup_path = _get_backup_path(mocked_data_dir_path)
|
||||
old_backup_path = _get_backup_path(temp_data_dir_path)
|
||||
old_backup_path.mkdir()
|
||||
bogus_file_path = old_backup_path.joinpath("test.txt")
|
||||
bogus_file_path.touch()
|
||||
|
||||
setup_data_dir(mocked_data_dir_path)
|
||||
setup_data_dir(temp_data_dir_path)
|
||||
new_backup_path = old_backup_path
|
||||
|
||||
# Make sure old backup got deleted and new backup took it's place
|
||||
assert mocked_version_file_path.read_text() == current_version
|
||||
assert temp_version_file_path.read_text() == current_version
|
||||
assert get_version_from_dir(new_backup_path) == old_version
|
||||
assert not _get_backup_path(mocked_data_dir_path).joinpath("test.txt").is_file()
|
||||
assert not _get_backup_path(temp_data_dir_path).joinpath("test.txt").is_file()
|
||||
|
||||
|
||||
def test_data_dir_setup_not_needed(mocked_data_dir_path, mocked_version_file_path):
|
||||
mocked_data_dir_path.mkdir()
|
||||
mocked_version_file_path.write_text(current_version)
|
||||
bogus_file_path = mocked_data_dir_path.joinpath("test.txt")
|
||||
def test_data_dir_setup_not_needed(temp_data_dir_path, temp_version_file_path):
|
||||
temp_data_dir_path.mkdir()
|
||||
temp_version_file_path.write_text(current_version)
|
||||
bogus_file_path = temp_data_dir_path.joinpath("test.txt")
|
||||
bogus_file_path.touch()
|
||||
|
||||
setup_data_dir(mocked_data_dir_path)
|
||||
assert mocked_version_file_path.read_text() == current_version
|
||||
setup_data_dir(temp_data_dir_path)
|
||||
assert temp_version_file_path.read_text() == current_version
|
||||
assert bogus_file_path.is_file()
|
||||
|
|
Loading…
Reference in New Issue