-
Notifications
You must be signed in to change notification settings - Fork 29
Mount testing-jiras into agent containers for e2e mock repos #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,7 +89,7 @@ def _load_test_cases(fixtures_dir: str | Path) -> list[BackportAgentTestCase]: | |
| return cases | ||
|
|
||
|
|
||
| test_cases = _load_test_cases(os.getenv("BACKPORT_MOCK_REPOS_DIR", str(DEFAULT_FIXTURES_DIR))) | ||
| test_cases = _load_test_cases(os.getenv("BACKPORT_MOCK_REPOS_DIR") or str(DEFAULT_FIXTURES_DIR)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of repeating the environment variable lookup and fallback logic across multiple functions, define a single module-level FIXTURES_DIR = Path(os.getenv("BACKPORT_MOCK_REPOS_DIR") or DEFAULT_FIXTURES_DIR)
if not FIXTURES_DIR.is_dir():
raise FileNotFoundError(f"Fixtures directory not found: {FIXTURES_DIR}")
test_cases = _load_test_cases(FIXTURES_DIR) |
||
|
|
||
|
|
||
| @pytest.fixture(scope="session", autouse=True) | ||
|
|
@@ -116,7 +116,7 @@ def mock_centos_stream_repos(): | |
| Yields: | ||
| Control to the test session after repos are prepared. | ||
| """ | ||
| fixtures_dir = os.getenv("BACKPORT_MOCK_REPOS_DIR", str(DEFAULT_FIXTURES_DIR)) | ||
| fixtures_dir = os.getenv("BACKPORT_MOCK_REPOS_DIR") or str(DEFAULT_FIXTURES_DIR) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| configs = load_all_fixture_configs(fixtures_dir) | ||
|
|
||
| if SHARED_BARE_REPOS_DIR.exists(): | ||
|
|
@@ -151,7 +151,7 @@ def _load_reference_patch(test_case: "BackportAgentTestCase") -> str | None: | |
| ref_patch_rel = test_case.expected.get("reference_patch") | ||
| if not ref_patch_rel: | ||
| return None | ||
| fixtures_dir = Path(os.getenv("BACKPORT_MOCK_REPOS_DIR", str(DEFAULT_FIXTURES_DIR))) | ||
| fixtures_dir = Path(os.getenv("BACKPORT_MOCK_REPOS_DIR") or str(DEFAULT_FIXTURES_DIR)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ref_patch_path = fixtures_dir / ref_patch_rel | ||
| if ref_patch_path.is_file(): | ||
| return ref_patch_path.read_text() | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -175,7 +175,7 @@ def mock_centos_stream_repos(tmp_path_factory): | |||||||||
| Yields: | ||||||||||
| Control to the test session after repos are prepared. | ||||||||||
| """ | ||||||||||
| fixtures_dir = os.getenv("MOCK_REPOS_DIR", str(DEFAULT_FIXTURES_DIR)) | ||||||||||
| fixtures_dir = os.getenv("MOCK_REPOS_DIR") or str(DEFAULT_FIXTURES_DIR) | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a defensive check to ensure the fixtures directory exists. This prevents confusing downstream errors (like git clone/fetch failures) if
Suggested change
|
||||||||||
| configs = load_all_fixture_configs(fixtures_dir) | ||||||||||
|
|
||||||||||
| if git_repo_basepath := os.getenv("GIT_REPO_BASEPATH"): | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.