2021-11-11 16:20:50 +01:00
|
|
|
from logging import DEBUG
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2022-03-02 08:59:57 +01:00
|
|
|
from mobilizon_reshare.cli.commands.recap.main import recap
|
2021-11-11 16:20:50 +01:00
|
|
|
from mobilizon_reshare.models.publication import PublicationStatus
|
2021-11-24 23:58:06 +01:00
|
|
|
|
|
|
|
spec = {
|
|
|
|
# We need three events since recap will print only
|
|
|
|
# future events, but the 0th event happens at today + 0.
|
|
|
|
"event": 3,
|
|
|
|
"publications": [
|
|
|
|
{"event_idx": 1, "publisher_idx": 0, "status": PublicationStatus.COMPLETED},
|
|
|
|
{"event_idx": 2, "publisher_idx": 0, "status": PublicationStatus.COMPLETED},
|
|
|
|
],
|
|
|
|
"publisher": ["zulip"],
|
|
|
|
}
|
2021-11-11 16:20:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"publisher_class", [pytest.lazy_fixture("mock_publisher_invalid_class")]
|
|
|
|
)
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
async def test_start_event_from_db(
|
2021-11-24 23:58:06 +01:00
|
|
|
caplog, mock_publisher_config, mock_now, message_collector, generate_models
|
2021-11-11 16:20:50 +01:00
|
|
|
):
|
2021-11-24 23:58:06 +01:00
|
|
|
await generate_models(spec)
|
2021-11-11 16:20:50 +01:00
|
|
|
|
|
|
|
with caplog.at_level(DEBUG):
|
|
|
|
# calling the recap command
|
|
|
|
report = await recap()
|
|
|
|
assert report.successful
|
|
|
|
|
|
|
|
assert "Found 2 events to recap" in caplog.text
|
|
|
|
|
|
|
|
recap_message = """Upcoming
|
|
|
|
|
2021-11-24 23:58:06 +01:00
|
|
|
event_1
|
2021-11-11 16:20:50 +01:00
|
|
|
|
2021-11-24 23:58:06 +01:00
|
|
|
event_2"""
|
|
|
|
assert message_collector == [recap_message]
|