ashb commented on code in PR #54203:
URL: https://github.com/apache/airflow/pull/54203#discussion_r2266210721
##########
providers/slack/tests/unit/slack/notifications/test_slack.py:
##########
@@ -28,6 +30,32 @@
DEFAULT_HOOKS_PARAMETERS = {"base_url": None, "timeout": None, "proxy": None,
"retry_handlers": None}
+RAW_GITHUB_ICON_URL =
"https://raw.githubusercontent.com/apache/airflow/main/airflow-core/src/airflow/ui/public/pin_100.png"
+GITHUB_API_ICON_URL =
"https://api.github.com/repos/apache/airflow/contents/airflow-core/src/airflow/ui/public/pin_100.png"
+
+def fetch_raw_url(link: str, fallback_link: str) -> str:
+ """
+ Fetch the image url from GitHub
+ """
+ token = os.environ.get("GITHUB_TOKEN")
+ headers = {}
+ if token:
+ headers["Authorization"] = f"token {token}"
+ else:
+ print("Warning: GITHUB_TOKEN not found, making unauthenticated
request")
+
+ response = requests.get(link, headers=headers)
+ if response.status_code == 200:
+ content = response.json()
+ if "download_url" in content:
+ return content["download_url"]
+ else:
+ return fallback_link
+ else:
+ print(f"Failed to fetch URL: {link} {response.status_code} -
{response.text}")
+ return fallback_link
+
+ICON_URL = fetch_raw_url(GITHUB_API_ICON_URL, RAW_GITHUB_ICON_URL)
Review Comment:
Needing a Github Token for this test doesn't seem worth it -- all we are
testing here is that the URL is "right" -- we don't care what value it is, so I
don't even see why we need to make any network requests in this test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]