# 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, requests from trytond.tests.test_tryton import ModuleTestCase, with_transaction from trytond.pool import Pool from trytond.transaction import Transaction from trytond.exceptions import UserError class TypeTestCase(ModuleTestCase): 'Test cashbook type module' module = 'cashbook' @with_transaction() 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', }]) # end TypeTestCase