refactoring
This commit is contained in:
parent
fa4c840374
commit
1faaf4700a
1 changed files with 12 additions and 13 deletions
|
|
@ -7,31 +7,30 @@ from tests_wordpress.runner_wordpress import RunnerWordpress
|
|||
|
||||
|
||||
class TestRunner(Protocol):
|
||||
def __init__(self, dotenv_path: Path):
|
||||
...
|
||||
|
||||
def run_tests():
|
||||
pass
|
||||
...
|
||||
|
||||
|
||||
RUNNER_DICT: dict[str, type[TestRunner]] = {"wordpress": RunnerWordpress}
|
||||
|
||||
|
||||
class TestWrapper:
|
||||
class Wrapper:
|
||||
def __init__(self, dotenv_path: Path):
|
||||
self.dotenv_path = dotenv_path
|
||||
self.config = self.load_config_from_dotenv(dotenv_path)
|
||||
runner = self.load_runner()
|
||||
assert dotenv_path.is_file()
|
||||
config = dotenv_values(dotenv_path)
|
||||
runner = self.load_runner(config, dotenv_path)
|
||||
runner.run_tests()
|
||||
|
||||
def load_config_from_dotenv(self, dotenv_path: Path):
|
||||
assert dotenv_path.is_file()
|
||||
return dotenv_values(self.dotenv_path)
|
||||
|
||||
def load_runner(self):
|
||||
config_type = self.config["TYPE"]
|
||||
def load_runner(self, config, dotenv_path):
|
||||
config_type = config["TYPE"]
|
||||
ic(config_type)
|
||||
RunnerClass = RUNNER_DICT[config_type]
|
||||
return RunnerClass(self.dotenv_path)
|
||||
return RunnerClass(dotenv_path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
dotenv_path = Path(__file__).parent / "./blog.dev.local-it.cloud.env"
|
||||
t = TestWrapper(dotenv_path)
|
||||
t = Wrapper(dotenv_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue