move copy_env_files to env_manager

This commit is contained in:
Daniel 2023-12-04 15:31:06 +01:00
parent a077afa92a
commit 9a7606a740
2 changed files with 11 additions and 9 deletions

View file

@ -1,4 +1,3 @@
import shutil
from pathlib import Path
from loguru import logger
@ -24,14 +23,7 @@ class Coordinator:
def setup_test(self) -> None:
logger.info("calling setup_test()")
self.DIR.create_all_dirs()
self._copy_env_files()
def _copy_env_files(self) -> None:
"""Copies all env files to STATES/env_files. Files will be renamed to their own TYPE value."""
env_files_dir = self.DIR.STATES / "env_files"
env_files_dir.mkdir(exist_ok=True)
for env_file in self.ENV.env_files:
shutil.copy(env_file.env_path, env_files_dir / env_file.env_type)
self.ENV.copy_env_files(self.DIR)
def run_test(self) -> None:
logger.info("calling run_test()")

View file

@ -1,9 +1,12 @@
import shutil
from pathlib import Path
from typing import NamedTuple
from dotenv import dotenv_values
from loguru import logger
from src.dirmanager import DirManager
class EnvFile(NamedTuple):
env_path: Path
@ -87,3 +90,10 @@ class EnvManager:
dependency_rule = DependencyRule(child=child_runner_class.name, dependency=dependency.name)
dependency_rules.append(dependency_rule)
return dependency_rules
def copy_env_files(self, DIR: DirManager) -> None:
"""Copies all env files to STATES/env_files. Files will be renamed to their own TYPE value."""
env_files_dir = DIR.STATES / "env_files"
env_files_dir.mkdir(exist_ok=True)
for env_file in self.env_files:
shutil.copy(env_file.env_path, env_files_dir / env_file.env_type)