Skip to content

Commit 9370dcf

Browse files
authored
Merge pull request #26 from FusRoman/issue/25/bug_empty_skymap
fix bug when skymap is empty in gw_score
2 parents 27c9b20 + bd66e48 commit 9370dcf

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

pdm.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "grandma-gcn"
3-
version = "6.2.1"
3+
version = "6.2.2"
44
description = "Automated ingestion, analysis, and distribution of gravitational wave (GW) alerts for the GRANDMA collaboration. Provides real-time GCN alert processing, observation strategy generation (gwemopt), Slack and OwnCloud integration, and Celery-based automation."
55
authors = [{ name = "Roman", email = "roman.lemontagner@gmail.com" }]
66
dependencies = [

src/grandma_gcn/gcn_stream/gw_alert.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,6 @@ def gw_score(self) -> tuple[int, str, GRANDMA_Action]:
451451
msg = ""
452452
conclusion = self.GRANDMA_Action.NO_GRANDMA
453453

454-
_, size_region, mean_dist, _ = self.get_error_region(0.9)
455-
456454
if not self.is_real_observation():
457455
return score, msg, conclusion
458456

@@ -464,6 +462,7 @@ def gw_score(self) -> tuple[int, str, GRANDMA_Action]:
464462
| self.EventType.INITIAL
465463
| self.EventType.UPDATE
466464
):
465+
_, size_region, mean_dist, _ = self.get_error_region(0.9)
467466
match self.event_class:
468467
case self.CBC_proba.Terrestrial:
469468
msg = (

tests/test_e2e.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import time
88

99

10-
def push_message_for_test(mocker, message_queue, topic, notice_file):
10+
def push_message_for_test(mocker, message_queue: list, topic: str, notice_file: str):
1111
"""
1212
Helper function to push a message to the mocked Kafka consumer for testing.
1313
"""
@@ -19,6 +19,8 @@ def push_message_for_test(mocker, message_queue, topic, notice_file):
1919

2020
message_queue.append(mock_message)
2121

22+
return mock_message
23+
2224

2325
@mark.e2e
2426
def test_e2e_grandma(mocker, logger):

tests/test_gcn_stream.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
from grandma_gcn.gcn_stream.consumer import Consumer
1212
from grandma_gcn.gcn_stream.gcn_logging import init_logging
13-
from tests.conftest import open_notice_file
13+
14+
from tests.test_e2e import push_message_for_test
1415

1516

1617
def test_init_gcn_stream(gcn_config_path, logger):
@@ -173,17 +174,13 @@ def test_gcn_stream_with_real_notice(mocker, gcn_config_path, logger):
173174
# Simulate a message queue
174175
message_queue = []
175176

176-
# Create a mocked message
177-
mock_message = mocker.Mock()
178-
mock_message.topic.return_value = "igwn.gwalert"
179-
mock_message.offset.return_value = 42
180-
mock_message.error.return_value = None
181-
mock_message.value.return_value = open_notice_file(
182-
Path("tests"), "S241102br-update.json"
177+
mock_message_update = push_message_for_test(
178+
mocker, message_queue, "igwn.gwalert", "S241102br-update.json"
183179
)
184180

185-
# Add the mocked message to the queue
186-
message_queue.append(mock_message)
181+
mock_message_retraction = push_message_for_test(
182+
mocker, message_queue, "igwn.gwalert", "retraction.json"
183+
)
187184

188185
# Mock the poll method
189186
def mock_poll(*args, **kwargs):
@@ -246,7 +243,8 @@ def mock_commit(message):
246243

247244
# Assertions
248245
assert mock_poll_method.call_count == 121
249-
mock_commit_method.assert_called_once_with(mock_message)
246+
mock_commit_method.assert_any_call(mock_message_update)
247+
mock_commit_method.assert_any_call(mock_message_retraction)
250248
mock_post_msg_on_slack.assert_called() # Ensure post_msg_on_slack is called
251249
mock_gwemopt_task.s.assert_called() # Ensure gwemopt_task.s is called
252250
mock_gwemopt_post_task.s.assert_called() # Ensure gwemopt_post_task.s is called

0 commit comments

Comments
 (0)