Add event name to notifications. (#136)
This commit is contained in:
parent
3ef8b1f97b
commit
ad8647704d
|
@ -43,7 +43,8 @@ class EventPublicationReport(BasePublicationReport):
|
|||
return (
|
||||
f"Publication {self.publication.id} failed with status: {self.status}.\n"
|
||||
f"Reason: {self.reason}\n"
|
||||
f"Publisher: {self.publication.publisher.name}"
|
||||
f"Publisher: {self.publication.publisher.name}\n"
|
||||
f"Event: {self.publication.event.name}"
|
||||
)
|
||||
|
||||
|
||||
|
@ -193,13 +194,15 @@ class RecapCoordinator:
|
|||
recap_publication.publisher.send(message)
|
||||
reports.append(
|
||||
BasePublicationReport(
|
||||
status=PublicationStatus.COMPLETED, reason=None,
|
||||
status=PublicationStatus.COMPLETED,
|
||||
reason=None,
|
||||
)
|
||||
)
|
||||
except PublisherError as e:
|
||||
reports.append(
|
||||
BasePublicationReport(
|
||||
status=PublicationStatus.FAILED, reason=str(e),
|
||||
status=PublicationStatus.FAILED,
|
||||
reason=str(e),
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ from mobilizon_reshare.models.publication import PublicationStatus
|
|||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"elements", [[]],
|
||||
"elements",
|
||||
[[]],
|
||||
)
|
||||
async def test_start_no_event(
|
||||
mock_mobilizon_success_answer, mobilizon_answer, caplog, elements
|
||||
|
@ -84,7 +85,8 @@ async def test_start_new_event(
|
|||
"publisher_class", [pytest.lazy_fixture("mock_publisher_class")]
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"elements", [[]],
|
||||
"elements",
|
||||
[[]],
|
||||
)
|
||||
async def test_start_event_from_db(
|
||||
mock_mobilizon_success_answer,
|
||||
|
@ -129,7 +131,8 @@ async def test_start_event_from_db(
|
|||
"publisher_class", [pytest.lazy_fixture("mock_publisher_invalid_class")]
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"elements", [[]],
|
||||
"elements",
|
||||
[[]],
|
||||
)
|
||||
async def test_start_publisher_failure(
|
||||
mock_mobilizon_success_answer,
|
||||
|
@ -163,7 +166,7 @@ async def test_start_publisher_failure(
|
|||
assert "Event to publish found" in caplog.text
|
||||
assert message_collector == [
|
||||
f"Publication {p.id} failed with status: 0."
|
||||
f"\nReason: credentials error\nPublisher: mock"
|
||||
f"\nReason: credentials error\nPublisher: mock\nEvent: test event"
|
||||
for p in publications
|
||||
for _ in range(2)
|
||||
] # 2 publications failed * 2 notifiers
|
||||
|
@ -209,7 +212,8 @@ def second_event_element():
|
|||
"publisher_class", [pytest.lazy_fixture("mock_publisher_class")]
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"elements", [[second_event_element()]],
|
||||
"elements",
|
||||
[[second_event_element()]],
|
||||
)
|
||||
async def test_start_second_execution(
|
||||
mock_mobilizon_success_answer,
|
||||
|
|
|
@ -23,12 +23,15 @@ from tests import today
|
|||
|
||||
|
||||
@pytest.fixture()
|
||||
def failure_report(mock_publisher_invalid):
|
||||
def failure_report(mock_publisher_invalid, event):
|
||||
return EventPublicationReport(
|
||||
status=PublicationStatus.FAILED,
|
||||
reason="some failure",
|
||||
publication=EventPublication(
|
||||
publisher=mock_publisher_invalid, formatter=None, event=None, id=UUID(int=1)
|
||||
publisher=mock_publisher_invalid,
|
||||
formatter=None,
|
||||
event=event,
|
||||
id=UUID(int=1),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue