56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
# This file is part of the investment-module from m-ds for 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, with_transaction
|
|
from trytond.pool import Pool
|
|
from trytond.modules.company.tests import create_company
|
|
from trytond.transaction import Transaction
|
|
from decimal import Decimal
|
|
from datetime import time, date
|
|
|
|
|
|
class SourceTestCase(ModuleTestCase):
|
|
'Test online source module'
|
|
module = 'investment'
|
|
|
|
@with_transaction()
|
|
def test_waitlist_source_check_regex(self):
|
|
""" create source, check convert
|
|
"""
|
|
pool = Pool()
|
|
OSource = pool.get('investment.source')
|
|
|
|
osource, = OSource.create([{
|
|
'name': 'Source 1',
|
|
'rgxdate': 'Course Date (\\d+.\\d+.\\d+) Today',
|
|
'rgxdatefmt': '%d.%m.%Y',
|
|
'rgxrate': 'High (\\d+,\\d+) EUR',
|
|
'rgxdecimal': ',',
|
|
}])
|
|
self.assertEqual(osource.rec_name, 'Source 1')
|
|
self.assertEqual(osource.get_regex_result(
|
|
'The Course Date 14.03.2022 Today, High 13,43 EUR',
|
|
'rgxdate'
|
|
), date(2022, 3, 14))
|
|
|
|
self.assertEqual(osource.get_regex_result(
|
|
'The Course Date 14.03.2022 Today, High 13,43 EUR',
|
|
'rgxrate'
|
|
), Decimal('13.43'))
|
|
|
|
# iso-date
|
|
OSource.write(*[
|
|
[osource],
|
|
{
|
|
'rgxdate': 'Course Date (\\d+-\\d+-\\d+) Today',
|
|
'rgxdatefmt': '%Y-%m-%d',
|
|
}])
|
|
self.assertEqual(osource.get_regex_result(
|
|
'The Course Date 2022-03-14 Today, High 13,43 EUR',
|
|
'rgxdate'
|
|
), date(2022, 3, 14))
|
|
|
|
|
|
# end SourceTestCase
|