mirror of
https://github.com/Tech-Workers-Coalition-Italia/mobilizon-reshare.git
synced 2025-02-16 19:50:41 +01:00
Add event name to notifications. (#136)
This commit is contained in:
parent
3ef8b1f97b
commit
ad8647704d
@ -43,7 +43,8 @@ class EventPublicationReport(BasePublicationReport):
|
|||||||
return (
|
return (
|
||||||
f"Publication {self.publication.id} failed with status: {self.status}.\n"
|
f"Publication {self.publication.id} failed with status: {self.status}.\n"
|
||||||
f"Reason: {self.reason}\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)
|
recap_publication.publisher.send(message)
|
||||||
reports.append(
|
reports.append(
|
||||||
BasePublicationReport(
|
BasePublicationReport(
|
||||||
status=PublicationStatus.COMPLETED, reason=None,
|
status=PublicationStatus.COMPLETED,
|
||||||
|
reason=None,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except PublisherError as e:
|
except PublisherError as e:
|
||||||
reports.append(
|
reports.append(
|
||||||
BasePublicationReport(
|
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.asyncio
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"elements", [[]],
|
"elements",
|
||||||
|
[[]],
|
||||||
)
|
)
|
||||||
async def test_start_no_event(
|
async def test_start_no_event(
|
||||||
mock_mobilizon_success_answer, mobilizon_answer, caplog, elements
|
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")]
|
"publisher_class", [pytest.lazy_fixture("mock_publisher_class")]
|
||||||
)
|
)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"elements", [[]],
|
"elements",
|
||||||
|
[[]],
|
||||||
)
|
)
|
||||||
async def test_start_event_from_db(
|
async def test_start_event_from_db(
|
||||||
mock_mobilizon_success_answer,
|
mock_mobilizon_success_answer,
|
||||||
@ -129,7 +131,8 @@ async def test_start_event_from_db(
|
|||||||
"publisher_class", [pytest.lazy_fixture("mock_publisher_invalid_class")]
|
"publisher_class", [pytest.lazy_fixture("mock_publisher_invalid_class")]
|
||||||
)
|
)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"elements", [[]],
|
"elements",
|
||||||
|
[[]],
|
||||||
)
|
)
|
||||||
async def test_start_publisher_failure(
|
async def test_start_publisher_failure(
|
||||||
mock_mobilizon_success_answer,
|
mock_mobilizon_success_answer,
|
||||||
@ -163,7 +166,7 @@ async def test_start_publisher_failure(
|
|||||||
assert "Event to publish found" in caplog.text
|
assert "Event to publish found" in caplog.text
|
||||||
assert message_collector == [
|
assert message_collector == [
|
||||||
f"Publication {p.id} failed with status: 0."
|
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 p in publications
|
||||||
for _ in range(2)
|
for _ in range(2)
|
||||||
] # 2 publications failed * 2 notifiers
|
] # 2 publications failed * 2 notifiers
|
||||||
@ -209,7 +212,8 @@ def second_event_element():
|
|||||||
"publisher_class", [pytest.lazy_fixture("mock_publisher_class")]
|
"publisher_class", [pytest.lazy_fixture("mock_publisher_class")]
|
||||||
)
|
)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"elements", [[second_event_element()]],
|
"elements",
|
||||||
|
[[second_event_element()]],
|
||||||
)
|
)
|
||||||
async def test_start_second_execution(
|
async def test_start_second_execution(
|
||||||
mock_mobilizon_success_answer,
|
mock_mobilizon_success_answer,
|
||||||
|
@ -23,12 +23,15 @@ from tests import today
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def failure_report(mock_publisher_invalid):
|
def failure_report(mock_publisher_invalid, event):
|
||||||
return EventPublicationReport(
|
return EventPublicationReport(
|
||||||
status=PublicationStatus.FAILED,
|
status=PublicationStatus.FAILED,
|
||||||
reason="some failure",
|
reason="some failure",
|
||||||
publication=EventPublication(
|
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…
x
Reference in New Issue
Block a user