first commit
This commit is contained in:
2
modules/currency_rs/tests/__init__.py
Normal file
2
modules/currency_rs/tests/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
BIN
modules/currency_rs/tests/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/currency_rs/tests/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
61
modules/currency_rs/tests/scenario_currency_rs.rst
Normal file
61
modules/currency_rs/tests/scenario_currency_rs.rst
Normal file
@@ -0,0 +1,61 @@
|
||||
====================
|
||||
Currency RS Scenario
|
||||
====================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime as dt
|
||||
>>> import os
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
>>> today = dt.date.today()
|
||||
>>> previous_week = today - dt.timedelta(days=7)
|
||||
>>> before_previous_week = previous_week - dt.timedelta(days=1)
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('currency_rs')
|
||||
|
||||
Import models::
|
||||
|
||||
>>> Currency = Model.get('currency.currency')
|
||||
>>> Cron = Model.get('currency.cron')
|
||||
|
||||
Create some currencies::
|
||||
|
||||
>>> eur = Currency(name="Euro", code='EUR', symbol="€")
|
||||
>>> eur.save()
|
||||
>>> rsd = Currency(name="Serbian Dinar", code='RSD', symbol="din.")
|
||||
>>> rsd.save()
|
||||
|
||||
Setup cron::
|
||||
|
||||
>>> cron = Cron()
|
||||
>>> cron.source = 'nbs_rs'
|
||||
>>> cron.rs_username = os.getenv('NBS_RS_USERNAME')
|
||||
>>> cron.rs_password = os.getenv('NBS_RS_PASSWORD')
|
||||
>>> cron.rs_license_id = os.getenv('NBS_RS_LICENSE_ID')
|
||||
>>> cron.rs_list_type = '3'
|
||||
>>> cron.frequency = 'daily'
|
||||
>>> cron.day = None
|
||||
>>> cron.currency = rsd
|
||||
>>> cron.currencies.append(Currency(eur.id))
|
||||
>>> cron.last_update = before_previous_week
|
||||
>>> cron.save()
|
||||
|
||||
Run update::
|
||||
|
||||
>>> cron.click('run')
|
||||
>>> cron.last_update >= previous_week
|
||||
True
|
||||
|
||||
>>> rsd.reload()
|
||||
>>> rate = [r for r in rsd.rates if r.date < today][0]
|
||||
>>> rate.rate
|
||||
Decimal('1.000000')
|
||||
>>> eur.reload()
|
||||
>>> rate = [r for r in eur.rates if r.date < today][0]
|
||||
>>> bool(rate.rate)
|
||||
True
|
||||
12
modules/currency_rs/tests/test_module.py
Normal file
12
modules/currency_rs/tests/test_module.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class CurrencyRsTestCase(ModuleTestCase):
|
||||
'Test Currency Rs module'
|
||||
module = 'currency_rs'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
15
modules/currency_rs/tests/test_scenario.py
Normal file
15
modules/currency_rs/tests/test_scenario.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
import os
|
||||
|
||||
from trytond.tests.test_tryton import TEST_NETWORK, load_doc_tests
|
||||
|
||||
|
||||
def load_tests(*args, **kwargs):
|
||||
if (not TEST_NETWORK
|
||||
or not (os.getenv('NBS_RS_USERNAME')
|
||||
and os.getenv('NBS_RS_PASSWORD')
|
||||
and os.getenv('NBS_RS_LICENSE_ID'))):
|
||||
kwargs.setdefault('skips', set()).add('scenario_currency_rs.rst')
|
||||
return load_doc_tests(__name__, __file__, *args, **kwargs)
|
||||
Reference in New Issue
Block a user