form optimiert, regex-konvertierung ok + test
This commit is contained in:
parent
517746b4e9
commit
b57c69abf0
6 changed files with 328 additions and 84 deletions
|
@ -6,12 +6,14 @@ import unittest
|
|||
|
||||
from trytond.modules.investment.tests.test_asset import AssetTestCase
|
||||
from trytond.modules.investment.tests.test_rate import RateTestCase
|
||||
from trytond.modules.investment.tests.test_source import SourceTestCase
|
||||
|
||||
|
||||
__all__ = ['suite']
|
||||
|
||||
|
||||
class InvestmentTestCase(\
|
||||
SourceTestCase, \
|
||||
RateTestCase,\
|
||||
AssetTestCase,\
|
||||
):
|
||||
|
|
56
tests/test_source.py
Normal file
56
tests/test_source.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
# -*- 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
|
Loading…
Add table
Add a link
Reference in a new issue