|
9 | 9 | from unittest.mock import MagicMock |
10 | 10 | from dotenv import dotenv_values |
11 | 11 |
|
| 12 | +from src.rhdh_dynamic_plugin_factory.config import PluginFactoryConfig |
| 13 | + |
12 | 14 |
|
13 | 15 | @pytest.fixture |
14 | 16 | def mock_logger(): |
@@ -114,7 +116,7 @@ def temp_workspace(tmp_path: Path): |
114 | 116 |
|
115 | 117 |
|
116 | 118 | @pytest.fixture |
117 | | -def setup_test_env(tmp_path: Path): |
| 119 | +def setup_test_env(tmp_path: Path, monkeypatch: pytest.MonkeyPatch): |
118 | 120 | """ |
119 | 121 | Set up a complete test environment with all required files and environment variables. |
120 | 122 | |
@@ -142,6 +144,10 @@ def setup_test_env(tmp_path: Path): |
142 | 144 | """ |
143 | 145 | (config_dir / "plugins-list.yaml").write_text(plugins_content) |
144 | 146 |
|
| 147 | + # Set common environment variables |
| 148 | + monkeypatch.setenv("RHDH_CLI_VERSION", "1.7.2") |
| 149 | + monkeypatch.setenv("WORKSPACE_PATH", ".") |
| 150 | + |
145 | 151 | return { |
146 | 152 | "config_dir": str(config_dir), |
147 | 153 | "source_dir": str(source_dir), |
@@ -169,3 +175,24 @@ def clean_env(monkeypatch: pytest.MonkeyPatch): |
169 | 175 |
|
170 | 176 | return monkeypatch |
171 | 177 |
|
| 178 | + |
| 179 | +@pytest.fixture |
| 180 | +def make_config(setup_test_env): |
| 181 | + """Factory fixture to create PluginFactoryConfig with sensible defaults. |
| 182 | + |
| 183 | + Usage: |
| 184 | + config = make_config() # All defaults |
| 185 | + config = make_config(registry_url="quay.io") # With override |
| 186 | + config = make_config(registry_url=None) # Explicitly set to None |
| 187 | + """ |
| 188 | + def _make_config(**overrides): |
| 189 | + config = PluginFactoryConfig() |
| 190 | + config.config_dir = setup_test_env["config_dir"] |
| 191 | + config.repo_path = setup_test_env["source_dir"] |
| 192 | + config.rhdh_cli_version = "1.7.2" |
| 193 | + config.workspace_path = "." |
| 194 | + for key, value in overrides.items(): |
| 195 | + setattr(config, key, value) |
| 196 | + return config |
| 197 | + return _make_config |
| 198 | + |
0 commit comments