cashbook/tests/test_type.py

51 lines
1.5 KiB
Python
Raw Normal View History

2022-08-09 13:08:41 +00:00
# -*- 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.tests.test_tryton import ModuleTestCase, with_transaction
from trytond.pool import Pool
from trytond.transaction import Transaction
from trytond.exceptions import UserError
2022-08-08 12:31:42 +00:00
class TypeTestCase(ModuleTestCase):
'Test cashbook type module'
module = 'cashbook'
@with_transaction()
2022-08-08 12:31:42 +00:00
def test_type_read_existing(self):
""" read predefined types
"""
AccType = Pool().get('cashbook.type')
t_lst = AccType.search([], order=[('name', 'ASC')])
self.assertEqual(len(t_lst), 3)
self.assertEqual(t_lst[0].rec_name, 'CAS - Cash')
self.assertEqual(t_lst[1].rec_name, 'FTD - Fixed-term deposit')
self.assertEqual(t_lst[2].rec_name, 'GIR - Giro')
@with_transaction()
def test_type_create(self):
""" create account type
"""
AccType = Pool().get('cashbook.type')
at, = AccType.create([{
'name': 'Test 1',
'short': 'T1',
}])
self.assertEqual(at.name, 'Test 1')
self.assertEqual(at.short, 'T1')
# check unique of short
self.assertRaisesRegex(UserError,
'The Abbreviation must be unique.',
AccType.create,
[{
'name': 'Test 2',
'short': 'T1',
}])
2022-08-08 12:31:42 +00:00
# end TypeTestCase