-
-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by sergiocorato
- Loading branch information
Showing
1 changed file
with
10 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# Copyright 2023 Giuseppe Borruso ([email protected]) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from datetime import date | ||
from datetime import date, timedelta | ||
from unittest import mock | ||
|
||
from dateutil.relativedelta import relativedelta | ||
from freezegun import freeze_time | ||
|
||
from odoo import fields | ||
from odoo import api, fields | ||
from odoo.tests import tagged | ||
|
||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon | ||
|
@@ -48,18 +48,21 @@ def setUpClass(cls): | |
) | ||
cls.CurrencyRate.search([]).unlink() | ||
|
||
@api.model | ||
def _get_no_weekend_date(self, compute_date): | ||
if compute_date.weekday() in [5, 6]: | ||
days_to_friday = 4 - compute_date.weekday() | ||
return compute_date + timedelta(days=days_to_friday) | ||
else: | ||
return compute_date | ||
|
||
def test_supported_currencies_BOI(self): | ||
self.ecb_provider._get_supported_currencies() | ||
|
||
def test_error_BOI(self): | ||
with mock.patch(_BOI_provider_class + "._obtain_rates", return_value=None): | ||
self.ecb_provider._update(self.today, self.today) | ||
|
||
def _get_no_weekend_date(self, compute_date): | ||
if compute_date.weekday() == 5 or compute_date.weekday() == 6: | ||
compute_date -= relativedelta(days=1) | ||
return compute_date | ||
|
||
def test_update_BOI_yesterday(self): | ||
compute_date = self._get_no_weekend_date(self.today - relativedelta(days=1)) | ||
self.ecb_provider._update(compute_date, self.today) | ||
|