aayushbisen commented on code in PR #54203:
URL: https://github.com/apache/airflow/pull/54203#discussion_r2266321405
##########
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:
@ashb I have remove the network call from the test. Let me know if the
changes looks okay.
--
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]