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),
    )
Esempio n. 2
0
async def failed_publication(stored_event) -> Publication:

    p = Publication(
        event=stored_event,
        status=PublicationStatus.FAILED,
        timestamp=arrow.now().datetime,
        publisher=await get_publisher_by_name("mock"),
    )
    await p.save()
    return p
Esempio n. 3
0
 async def build_publication_by_publisher_name(
         self,
         publisher_name: str,
         status: PublicationStatus = PublicationStatus.FAILED
 ) -> Publication:
     publisher = await Publisher.filter(name=publisher_name).first()
     return Publication(
         status=status,
         event_id=self.id,
         publisher_id=publisher.id,
         publisher=publisher,
     )
Esempio n. 4
0
 def _publication_model_generator(
     status=PublicationStatus.COMPLETED,
     publication_time=datetime(year=2021, month=1, day=1, hour=11, minute=30),
     event_id=None,
     publisher_id=None,
 ):
     return Publication(
         status=status,
         timestamp=publication_time,
         event_id=event_id,
         publisher_id=publisher_id,
     )
Esempio n. 5
0
                        status=PublicationStatus.COMPLETED,
                        reason="",
                        publication=EventPublication(
                            id=UUID(int=6),
                            formatter=TelegramFormatter(),
                            event=event_1,
                            publisher=TelegramPublisher(),
                        ),
                    ),
                ],
            ),
            event_1,
            {
                UUID(int=6):
                Publication(id=UUID(int=6),
                            status=PublicationStatus.COMPLETED,
                            reason=""),
            },
        ],
    ],
)
async def test_save_publication_report(
    specification,
    report,
    event,
    expected_result,
    generate_models,
):
    await generate_models(specification)
    known_publication_ids = set(p.id for p in await Publication.all())