@@ -2,6 +2,7 @@ import xml.dom.expatbuilder
|
||||
|
||||
from repo_cloner.lib.repo_dir_structure import RepoDirStructure
|
||||
from repo_cloner.lib.dir_not_found_error import DirNotFoundError
|
||||
from repo_cloner.lib.config_file_not_found_error import ConfigFileNotFoundError
|
||||
from pathlib import PosixPath
|
||||
import pytest
|
||||
|
||||
@@ -14,6 +15,11 @@ def test_init():
|
||||
assert X._cache_dir == "/tmp/cache"
|
||||
|
||||
|
||||
def test_config_filename():
|
||||
X = RepoDirStructure("/tmp")
|
||||
assert X._RepoDirStructure__config_filename == "/tmp/config/cloner.cfg"
|
||||
|
||||
|
||||
def test_no_base_dir(tmp_path: PosixPath):
|
||||
x = tmp_path.joinpath("nonexistent")
|
||||
X = RepoDirStructure(x)
|
||||
@@ -81,3 +87,18 @@ def test_config_dir():
|
||||
def test_repos_dir():
|
||||
X = RepoDirStructure("/a/c")
|
||||
assert X.repos_dir == "/a/c/repos"
|
||||
|
||||
|
||||
def test_has_config(tmp_path: PosixPath):
|
||||
tmp_path.joinpath("config").mkdir()
|
||||
tmp_path.joinpath("cache").mkdir()
|
||||
tmp_path.joinpath("repos").mkdir()
|
||||
|
||||
X = RepoDirStructure(tmp_path)
|
||||
with pytest.raises(ConfigFileNotFoundError) as excinfo:
|
||||
X.has_config
|
||||
assert "Config file does not exist: " in excinfo.exconly()
|
||||
assert "config/cloner.cfg" in excinfo.exconly()
|
||||
|
||||
tmp_path.joinpath("config", "cloner.cfg").touch()
|
||||
assert X.has_config
|
||||
|
||||
Reference in New Issue
Block a user