mirror of
https://github.com/Tech-Workers-Coalition-Italia/mobilizon-reshare.git
synced 2025-02-18 12:40:44 +01:00
* mobilizon_bots: query: Add create_publisher. * Move PublicationStatus to models.publication. * Move NotificationStatus to models.notification. * storage: query: Add events_with_status. * storage: query: Add get_unpublished_events. * storage: query: Add create_unpublished events. This function takes care of looking into the database to store only the events whose is not already present. * event: event: Support multiple publications. This patch changes the public interface of `MobilizonEvent` to support multiple publications. This mainly entails two changes: - When instancing a `MobilizonEvent` from an `Event` model the `publication_status` will be computed by looking at the statuses of all the related publications. - Now the `publication_time` is a `dict[str, Arrow]`. This enables tracking multiple social platforms publication time. * Update main. * Minor fixes * Better definition of MobilizonEvent.publication_status. Co-authored-by: Giacomo Leidi <goodoldpaul@autistici.org>
31 lines
884 B
Python
31 lines
884 B
Python
import pytest
|
|
|
|
from datetime import datetime
|
|
from tortoise import timezone
|
|
|
|
from mobilizon_bots.models.publication import Publication, PublicationStatus
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_publication_create(
|
|
publication_model_generator, event_model_generator, publisher_model_generator
|
|
):
|
|
event = event_model_generator()
|
|
await event.save()
|
|
publisher = publisher_model_generator()
|
|
await publisher.save()
|
|
publication_model = await publication_model_generator(
|
|
event_id=event.id, publisher_id=publisher.id
|
|
)
|
|
await publication_model.save()
|
|
publication_db = await Publication.all().first()
|
|
assert publication_db.status == PublicationStatus.WAITING
|
|
assert publication_db.timestamp == datetime(
|
|
year=2021,
|
|
month=1,
|
|
day=1,
|
|
hour=11,
|
|
minute=30,
|
|
tzinfo=timezone.get_default_timezone(),
|
|
)
|