Add test condition for every dir possible

Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
2022-06-26 00:05:36 +02:00
parent e500c775d4
commit 69151619f7
2 changed files with 35 additions and 8 deletions

View File

@@ -15,18 +15,40 @@ class RepoDirStructure():
self._repos_dir = os.path.join(self._base_dir, "repos")
@property
def exists(self) -> bool:
def base_dir_exists(self):
if not os.path.isdir(self._base_dir):
raise DirNotFoundError(self._base_dir)
return True
@property
def conf_dir_exists(self):
if not os.path.isdir(self._conf_dir):
raise DirNotFoundError(self._conf_dir)
return True
@property
def cache_dir_exists(self):
if not os.path.isdir(self._cache_dir):
raise DirNotFoundError(self._cache_dir)
return True
@property
def repos_dir_exists(self):
if not os.path.isdir(self._repos_dir):
raise DirNotFoundError(self._repos_dir)
return True
@property
def dirs_exist(self) -> bool:
return all(
[
self.base_dir_exists,
self.conf_dir_exists,
self.cache_dir_exists,
self.repos_dir_exists,
]
)
@property
def base_dir(self) -> str:
return self._base_dir