formatting

This commit is contained in:
Frederik Jaeckel 2023-06-08 14:00:59 +02:00
parent 6c1fac8672
commit ad067475f8
13 changed files with 1126 additions and 709 deletions

View file

@ -4,25 +4,14 @@
import trytond.tests.test_tryton
import unittest
from trytond.modules.cashbook_investment.tests.test_book import CbInvTestCase
from trytond.modules.cashbook_investment.tests.test_reconciliation import ReconTestCase
from trytond.modules.cashbook_investment.tests.test_yield import YieldTestCase
from .test_module import CashbookInvestmentTestCase
__all__ = ['suite']
class CashbookInvestmentTestCase(\
CbInvTestCase,\
ReconTestCase,\
YieldTestCase,\
):
'Test cashbook-investment module'
module = 'cashbook_investment'
# end CashbookInvestmentTestCase
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(CashbookInvestmentTestCase))
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
CashbookInvestmentTestCase))
return suite

File diff suppressed because it is too large Load diff

View file

@ -3,18 +3,15 @@
# 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.tests.test_tryton import with_transaction
from trytond.pool import Pool
from trytond.transaction import Transaction
from trytond.exceptions import UserError
from datetime import date
from decimal import Decimal
class ReconTestCase(ModuleTestCase):
'Test quantity reconciliation module'
module = 'cashbook_investment'
class ReconTestCase(object):
""" test reconciliation
"""
@with_transaction()
def test_recon_set_start_quantity_by_cashbook(self):
""" set start-quantity of reconciliation from cashbook-setting
@ -33,7 +30,7 @@ class ReconTestCase(ModuleTestCase):
}])
asset = self.prep_asset_item(
company=company,
product = self.prep_asset_product(name='Product 1'))
product=self.prep_asset_product(name='Product 1'))
self.assertEqual(asset.symbol, 'usd/u')
book, = Book.create([{
@ -53,12 +50,16 @@ class ReconTestCase(ModuleTestCase):
}])
self.assertEqual(book.name, 'Asset-Book')
self.assertEqual(book.reconciliations[0].feature, 'asset')
self.assertEqual(book.reconciliations[0].rec_name,
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] | 0.0000 u - 0.0000 u')
self.assertEqual(
book.reconciliations[0].rec_name,
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] ' +
'| 0.0000 u - 0.0000 u')
Reconciliation.wfcheck(list(book.reconciliations))
self.assertEqual(book.reconciliations[0].rec_name,
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] | 0.0000 u - 0.0000 u')
self.assertEqual(
book.reconciliations[0].rec_name,
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] ' +
'| 0.0000 u - 0.0000 u')
@with_transaction()
def test_recon_set_start_quantity_by_predecessor(self):
@ -79,7 +80,7 @@ class ReconTestCase(ModuleTestCase):
}])
asset = self.prep_asset_item(
company=company,
product = self.prep_asset_product(name='Product 1'))
product=self.prep_asset_product(name='Product 1'))
self.assertEqual(asset.symbol, 'usd/u')
category = self.prep_category(cattype='in')
@ -119,8 +120,10 @@ class ReconTestCase(ModuleTestCase):
}])
self.assertEqual(book.name, 'Asset-Book')
self.assertEqual(len(book.reconciliations), 1)
self.assertEqual(book.reconciliations[0].rec_name,
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] | 0.000 u - 0.000 u')
self.assertEqual(
book.reconciliations[0].rec_name,
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0] | ' +
'0.000 u - 0.000 u')
self.assertEqual(len(book.reconciliations[0].lines), 0)
Lines.wfcheck(list(book.lines))
@ -134,8 +137,10 @@ class ReconTestCase(ModuleTestCase):
self.assertEqual(book.lines[1].quantity_balance, Decimal('4.0'))
self.assertEqual(book.reconciliations[0].state, 'check')
self.assertEqual(book.reconciliations[0].rec_name,
'05/01/2022 - 05/31/2022 | 0.00 usd - 12.00 usd [2] | 0.000 u - 4.000 u')
self.assertEqual(
book.reconciliations[0].rec_name,
'05/01/2022 - 05/31/2022 | 0.00 usd - 12.00 usd [2] ' +
'| 0.000 u - 4.000 u')
Reconciliation.wfdone(list(book.reconciliations))
self.assertEqual(book.reconciliations[0].state, 'done')
@ -144,10 +149,14 @@ class ReconTestCase(ModuleTestCase):
'date_from': date(2022, 5, 31),
'date_to': date(2022, 6, 30),
}])
self.assertEqual(recons[0].rec_name,
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0] | 0.000 u - 0.000 u')
self.assertEqual(
recons[0].rec_name,
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0] | ' +
'0.000 u - 0.000 u')
Reconciliation.wfcheck(recons)
self.assertEqual(recons[0].rec_name,
'05/31/2022 - 06/30/2022 | 12.00 usd - 12.00 usd [0] | 4.000 u - 4.000 u')
self.assertEqual(
recons[0].rec_name,
'05/31/2022 - 06/30/2022 | 12.00 usd - 12.00 usd [0] | ' +
'4.000 u - 4.000 u')
# end ReconTestCase

28
tests/test_module.py Normal file
View file

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# This file is part of the cashbook-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.modules.cashbook.tests import CashbookTestCase
from trytond.modules.investment.tests import InvestmentTestCase
from .yieldtest import YieldTestCase
from .book import CbInvTestCase
from .reconciliation import ReconTestCase
class CashbookInvestmentTestCase(
CashbookTestCase,
InvestmentTestCase,
CbInvTestCase,
ReconTestCase,
YieldTestCase):
'Test cashbook-investment module'
module = 'cashbook_investment'
# end CashbookInvestmentTestCase
del CashbookTestCase
del InvestmentTestCase

View file

@ -7,13 +7,12 @@ from decimal import Decimal
from datetime import date
from trytond.pool import Pool
from trytond.transaction import Transaction
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
from trytond.tests.test_tryton import with_transaction
class YieldTestCase(ModuleTestCase):
'Test yield calculation module'
module = 'cashbook_investment'
class YieldTestCase(object):
""" test yield
"""
def prep_yield_config(self, fee, dividend, gainloss, company):
""" add config for yield-calculation
fee: name of fee-category,