Ignore missing rate for date before today
The test scenario is updated also to ensure that cron is run at least one day that is not an bank holiday. issue10511 review336421002
This commit is contained in:
1 parent
3744324aa8
commit
2cae99ea42
2 files changed
+8
-7
No files matched your search
+2
-1
@@ -381,7 +381,8 @@ class Cron(ModelSQL, ModelView):
|
||||
yield from self._rates(date)
|
||||
except CronFetchError:
|
||||
logger.warning("Could not fetch rates temporary")
|
||||
break
|
||||
if date >= datetime.date.today():
|
||||
break
|
||||
except Exception:
|
||||
logger.error("Fail to fetch rates", exc_info=True)
|
||||
break
|
||||
|
||||
@@ -9,8 +9,8 @@ Imports::
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
>>> today = dt.date.today()
|
||||
>>> yesterday = today - dt.timedelta(days=1)
|
||||
>>> before_yesterday = yesterday - dt.timedelta(days=1)
|
||||
>>> previous_week = today - dt.timedelta(days=7)
|
||||
>>> before_previous_week = previous_week - dt.timedelta(days=1)
|
||||
|
||||
Activate modules::
|
||||
|
||||
@@ -36,19 +36,19 @@ Setup cron::
|
||||
>>> cron.day = None
|
||||
>>> cron.currency = eur
|
||||
>>> cron.currencies.append(Currency(usd.id))
|
||||
>>> cron.last_update = before_yesterday
|
||||
>>> cron.last_update = before_previous_week
|
||||
>>> cron.save()
|
||||
|
||||
Run update::
|
||||
|
||||
>>> cron.click('run')
|
||||
>>> cron.last_update >= yesterday
|
||||
>>> cron.last_update >= previous_week
|
||||
True
|
||||
|
||||
>>> eur.reload()
|
||||
>>> rate, = [r for r in eur.rates if r.date == yesterday]
|
||||
>>> rate = [r for r in eur.rates if r.date < today][0]
|
||||
>>> rate.rate
|
||||
Decimal('1.000000')
|
||||
>>> rate, = [r for r in usd.rates if r.date == yesterday]
|
||||
>>> rate = [r for r in usd.rates if r.date < today][0]
|
||||
>>> bool(rate.rate)
|
||||
True
|
||||
Reference in new issue
Block a user