Retries when testing fetching message from Peppyrus

The process of the message may be delayed by Peppyrus so we must retry until
the message is fetched.
This commit is contained in:
Cédric Krier
2025-12-31 11:32:52 +01:00
parent ce7e973e85
commit b0763c081e
@@ -5,6 +5,7 @@ EDocument Peppol Peppyrus Scenario
Imports::
>>> import os
>>> import time
>>> from unittest.mock import patch
>>> from proteus import Model
@@ -13,6 +14,8 @@ Imports::
>>> from trytond.tests.tools import activate_modules
>>> from trytond.tools import file_open
>>> FETCH_SLEEP, MAX_SLEEP = 1, 20
Patch Peppol::
>>> _validate = patch.object(Peppol, '_validate').start()
@@ -69,10 +72,13 @@ Check Peppol status::
Fetch messages::
>>> cron, = Cron.find([
... ('method', '=', 'edocument.peppol.service|peppyrus_fetch'),
... ], limit=1)
>>> cron.click('run_once')
>>> for _ in range(MAX_SLEEP):
... cron, = Cron.find([
... ('method', '=', 'edocument.peppol.service|peppyrus_fetch'),
... ], limit=1)
... cron.click('run_once')
... if bool(Peppol.find([('direction', '=', 'in')])):
... break
... time.sleep(FETCH_SLEEP)
>>> bool(Peppol.find([('direction', '=', 'in')]))
True