Skip to content

Commit

Permalink
test: move test fixtures out as regular free fixture whenever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
lieryan committed Mar 14, 2024
1 parent 61d1699 commit ddde3a0
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@
from gitops import core


class TestMixin:
@fixture(autouse=True)
def mock_invoke_run(self, monkeypatch):
monkeypatch.setattr(core, "run", lambda cmd: None)
@fixture(autouse=True)
def mock_invoke_run(monkeypatch):
monkeypatch.setattr(core, "run", lambda cmd: None)

@fixture
def confirm_yes(self, monkeypatch):
monkeypatch.setattr(apps, "confirm", lambda: True)
@fixture
def confirm_yes(monkeypatch):
monkeypatch.setattr(apps, "confirm", lambda: True)

@fixture
def sample_app(self, tmp_path, monkeypatch):
monkeypatch.setattr(apps, "get_apps_directory", lambda: tmp_path)
(tmp_path / "sample_app").mkdir(parents=True, exist_ok=True)
(tmp_path / "sample_app/deployment.yml").write_text("{}")
(tmp_path / "sample_app/secrets.yml").write_text("{}")
return tmp_path / "sample_app/"
@fixture
def sample_app(tmp_path, monkeypatch):
monkeypatch.setattr(apps, "get_apps_directory", lambda: tmp_path)
(tmp_path / "sample_app").mkdir(parents=True, exist_ok=True)
(tmp_path / "sample_app/deployment.yml").write_text("{}")
(tmp_path / "sample_app/secrets.yml").write_text("{}")
return tmp_path / "sample_app/"


class TestMixin:
@fixture
def deployment_yml(self, sample_app):
def _deployment_yml(content):
Expand Down

0 comments on commit ddde3a0

Please sign in to comment.