forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add view_url for DagBundles (apache#45126)
This PR adds view_url to Dagbundles to enable viewing the bundle's version
- Loading branch information
1 parent
39d7f1c
commit adbe4e2
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
import tempfile | ||
from pathlib import Path | ||
from unittest import mock | ||
|
||
import pytest | ||
from git import Repo | ||
|
@@ -265,3 +266,37 @@ def test_subdir(self, git_repo): | |
files_in_repo = {f.name for f in bundle.path.iterdir() if f.is_file()} | ||
assert str(bundle.path).endswith(subdir) | ||
assert {"some_new_file.py"} == files_in_repo | ||
|
||
@pytest.mark.parametrize( | ||
"repo_url, expected_url", | ||
[ | ||
("[email protected]:apache/airflow.git", "https://github.com/apache/airflow/tree/0f0f0f"), | ||
("[email protected]:apache/airflow.git", "https://gitlab.com/apache/airflow/-/tree/0f0f0f"), | ||
("[email protected]:apache/airflow.git", "https://bitbucket.org/apache/airflow/src/0f0f0f"), | ||
( | ||
"[email protected]:apache/airflow.git", | ||
"https://myorg.github.com/apache/airflow/tree/0f0f0f", | ||
), | ||
], | ||
) | ||
@mock.patch("airflow.dag_processing.bundles.git.Repo") | ||
def test_view_url(self, mock_gitrepo, repo_url, expected_url): | ||
bundle = GitDagBundle( | ||
name="test", | ||
refresh_interval=300, | ||
repo_url=repo_url, | ||
tracking_ref="main", | ||
) | ||
view_url = bundle.view_url("0f0f0f") | ||
assert view_url == expected_url | ||
|
||
@mock.patch("airflow.dag_processing.bundles.git.Repo") | ||
def test_view_url_returns_none_when_no_version_in_view_url(self, mock_gitrepo): | ||
bundle = GitDagBundle( | ||
name="test", | ||
refresh_interval=300, | ||
repo_url="[email protected]:apache/airflow.git", | ||
tracking_ref="main", | ||
) | ||
view_url = bundle.view_url(None) | ||
assert view_url is None |