2021-08-14 18:23:55 +02:00
|
|
|
from datetime import datetime, timezone, timedelta
|
|
|
|
from uuid import UUID
|
|
|
|
|
2021-08-16 10:49:52 +02:00
|
|
|
from mobilizon_reshare.models.publication import Publication
|
2021-08-27 23:45:24 +02:00
|
|
|
from mobilizon_reshare.models.publication import PublicationStatus
|
2021-08-14 18:23:55 +02:00
|
|
|
|
|
|
|
today = datetime(
|
2021-08-28 13:17:39 +02:00
|
|
|
year=2021,
|
|
|
|
month=6,
|
|
|
|
day=6,
|
|
|
|
hour=5,
|
|
|
|
minute=0,
|
|
|
|
tzinfo=timezone(timedelta(hours=2)),
|
2021-08-14 18:23:55 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
complete_specification = {
|
|
|
|
"event": 4,
|
|
|
|
"publications": [
|
|
|
|
{"event_idx": 0, "publisher_idx": 0, "status": PublicationStatus.COMPLETED},
|
|
|
|
{"event_idx": 0, "publisher_idx": 1, "status": PublicationStatus.COMPLETED},
|
|
|
|
{"event_idx": 0, "publisher_idx": 2, "status": PublicationStatus.COMPLETED},
|
|
|
|
{"event_idx": 1, "publisher_idx": 0, "status": PublicationStatus.WAITING},
|
|
|
|
{"event_idx": 1, "publisher_idx": 1, "status": PublicationStatus.WAITING},
|
|
|
|
{"event_idx": 1, "publisher_idx": 2, "status": PublicationStatus.COMPLETED},
|
|
|
|
{"event_idx": 2, "publisher_idx": 0, "status": PublicationStatus.FAILED},
|
|
|
|
{"event_idx": 2, "publisher_idx": 1, "status": PublicationStatus.COMPLETED},
|
|
|
|
{"event_idx": 2, "publisher_idx": 2, "status": PublicationStatus.WAITING},
|
|
|
|
{"event_idx": 3, "publisher_idx": 0, "status": PublicationStatus.WAITING},
|
|
|
|
{"event_idx": 3, "publisher_idx": 1, "status": PublicationStatus.WAITING},
|
|
|
|
{"event_idx": 3, "publisher_idx": 2, "status": PublicationStatus.WAITING},
|
|
|
|
],
|
2021-08-27 23:45:24 +02:00
|
|
|
"publisher": ["telegram", "twitter", "mastodon"],
|
2021-08-14 18:23:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def _make_test_publication(publication_id, status, event_id, publisher_id):
|
|
|
|
return Publication(
|
|
|
|
id=UUID(int=publication_id),
|
|
|
|
status=status,
|
|
|
|
timestamp=today + timedelta(hours=publication_id),
|
|
|
|
event_id=UUID(int=event_id),
|
|
|
|
publisher_id=UUID(int=publisher_id),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
result_publication = {
|
|
|
|
i: _make_test_publication(
|
|
|
|
i,
|
|
|
|
publisher_id=publication["publisher_idx"],
|
|
|
|
event_id=publication["event_idx"],
|
|
|
|
status=publication["status"],
|
|
|
|
)
|
|
|
|
for i, publication in enumerate(complete_specification["publications"])
|
|
|
|
}
|