Skip to content

Commit 8244b2a

Browse files
committed
Fix coderabbit issues
1 parent 476fae6 commit 8244b2a

3 files changed

Lines changed: 18 additions & 31 deletions

File tree

elementary/monitor/alerts/alert.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,20 @@ def get_report_link(self) -> Optional[ReportLinkData]:
100100
@property
101101
def orchestrator_info(self) -> Optional[Dict[str, str]]:
102102
"""Returns structured orchestrator metadata if available."""
103-
if not any([self.job_name, self.job_run_id, self.orchestrator]):
103+
if not any(
104+
[
105+
self.job_name,
106+
self.job_run_id,
107+
self.orchestrator,
108+
self.job_url,
109+
self.job_run_url,
110+
]
111+
):
104112
return None
105113

106114
info = {}
115+
if self.job_id:
116+
info["job_id"] = self.job_id
107117
if self.job_name:
108118
info["job_name"] = self.job_name
109119
if self.job_run_id:

tests/unit/alerts/alert_messages/test_orchestrator_message_simple.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def test_alert_message_includes_orchestrator_link(self):
6767
slack_json = str(slack_message)
6868

6969
# Should contain orchestrator link
70-
assert "View in Dbt Cloud" in slack_json
7170
assert "cloud.getdbt.com/run/12345" in slack_json
7271

7372
def test_alert_without_orchestrator_data_works_normally(self):
@@ -121,7 +120,6 @@ def test_model_alert_with_orchestrator_data(self):
121120
# Should contain model orchestrator info
122121
assert "nightly_build" in slack_json
123122
assert "github_actions" in slack_json
124-
assert "View in Github Actions" in slack_json
125123

126124
def test_orchestrator_info_property_integration(self):
127125
"""Test that the orchestrator_info property works correctly."""

tests/unit/alerts/test_orchestrator_integration.py

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,9 @@ def test_create_orchestrator_link_with_valid_data(self):
2525
link = create_orchestrator_link(orchestrator_info)
2626

2727
assert link is not None
28-
assert link.text == "View in Airflow"
2928
assert link.url == "https://airflow.example.com/run/12345"
3029
assert link.orchestrator == "airflow"
31-
assert link.icon == Icon.INFO
32-
33-
def test_create_orchestrator_link_formats_orchestrator_names(self):
34-
test_cases = [
35-
("airflow", "View in Airflow"),
36-
("dbt_cloud", "View in Dbt Cloud"),
37-
("github_actions", "View in Github Actions"),
38-
("custom_orchestrator", "View in Custom Orchestrator"),
39-
]
40-
41-
for orchestrator, expected_text in test_cases:
42-
orchestrator_info = {
43-
"orchestrator": orchestrator,
44-
"run_url": "https://example.com/run/123", # noqa: E231
45-
}
46-
47-
link = create_orchestrator_link(orchestrator_info)
48-
49-
assert link is not None
50-
assert link.text == expected_text
51-
assert link.orchestrator == orchestrator
30+
assert link.icon == Icon.LINK
5231

5332
def test_create_orchestrator_link_without_url_returns_none(self):
5433
orchestrator_info = {
@@ -290,20 +269,20 @@ class TestOrchestratorLinkDataModel:
290269
def test_orchestrator_link_data_creation(self):
291270
link = OrchestratorLinkData(
292271
url="https://airflow.example.com/run/123",
293-
text="View in Airflow",
272+
text="View in airflow",
294273
orchestrator="airflow",
295-
icon=Icon.INFO,
274+
icon=Icon.LINK,
296275
)
297276

298277
assert link.url == "https://airflow.example.com/run/123"
299-
assert link.text == "View in Airflow"
278+
assert link.text == "View in airflow"
300279
assert link.orchestrator == "airflow"
301-
assert link.icon == Icon.INFO
280+
assert link.icon == Icon.LINK
302281

303282
def test_orchestrator_link_data_without_icon(self):
304283
link = OrchestratorLinkData(
305284
url="https://airflow.example.com/run/123",
306-
text="View in Airflow",
285+
text="View in airflow",
307286
orchestrator="airflow"
308287
# icon is optional
309288
)
@@ -315,5 +294,5 @@ def test_orchestrator_link_data_required_fields(self):
315294
with pytest.raises((TypeError, ValueError)):
316295
OrchestratorLinkData(
317296
# Missing required fields
318-
icon=Icon.INFO
297+
icon=Icon.LINK
319298
)

0 commit comments

Comments
 (0)