Add removed unittests

(grafted from ec21693af87e82819e233507b2db81efd9f58104)
This commit is contained in:
Sergi Almacellas Abellana 2015-12-09 22:22:52 +01:00
parent 87f1c80ed1
commit f2b514951d
1 changed files with 40 additions and 1 deletions

View File

@ -1,18 +1,57 @@
# This file is part of the account_code_digits module for Tryton.
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
import doctest
import unittest
import trytond.tests.test_tryton
from trytond.exceptions import UserError
from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT
from trytond.transaction import Transaction
class AccountCodeDigitsTestCase(ModuleTestCase):
'Test Account Code Digits module'
module = 'account_code_digits'
def setUp(self):
super(AccountCodeDigitsTestCase, self).setUp()
self.account = POOL.get('account.account')
self.config = POOL.get('account.configuration')
def test0010_force_digits(self):
'Test force digits'
with Transaction().start(DB_NAME, USER, context=CONTEXT):
config = self.config.get_singleton() or self.config()
config.default_account_code_digits = 6
config.force_digits = True
config.save()
view, = self.account.search([
('kind', '=', 'view'),
], limit=1)
non_view, = self.account.search([
('kind', '!=', 'view'),
], limit=1)
self.assertRaises(UserError, self.account.write, [non_view],
{'code': '000'})
self.account.write([view], {'code': '0'})
self.account.write([non_view], {'code': '000000'})
self.assertEqual(view.code, '0')
self.assertEqual(non_view.code, '000000')
config.force_digits = False
config.save()
self.account.write([non_view], {'code': '0000'})
self.assertEqual(non_view.code, '0000')
def suite():
suite = trytond.tests.test_tryton.suite()
from trytond.modules.account.tests import test_account
for test in test_account.suite():
if test not in suite and not isinstance(test, doctest.DocTestCase):
suite.addTest(test)
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
AccountCodeDigitsTestCase))
return suite
return suite