
config: Felder catnamelong+cataccno neu + tests, line: feld category_view neu für spaltenansicht in kassenbuch + tests,
103 lines
3.5 KiB
Python
103 lines
3.5 KiB
Python
# -*- 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
|
|
from datetime import date
|
|
|
|
|
|
class ConfigTestCase(ModuleTestCase):
|
|
'Test config type module'
|
|
module = 'cashbook'
|
|
|
|
@with_transaction()
|
|
def test_config_create(self):
|
|
""" create config
|
|
"""
|
|
Configuration = Pool().get('cashbook.configuration')
|
|
|
|
cfg1 = Configuration()
|
|
cfg1.save()
|
|
|
|
cfg2 = Configuration.get_singleton()
|
|
self.assertEqual(cfg2.date_from, None)
|
|
self.assertEqual(cfg2.date_to, None)
|
|
self.assertEqual(cfg2.checked, True)
|
|
self.assertEqual(cfg2.done, False)
|
|
self.assertEqual(cfg2.catnamelong, True)
|
|
self.assertEqual(cfg2.cataccno, True)
|
|
|
|
@with_transaction()
|
|
def test_config_create_multi_user(self):
|
|
""" create config, multi-user
|
|
"""
|
|
pool = Pool()
|
|
Configuration = pool.get('cashbook.configuration')
|
|
ResUser = pool.get('res.user')
|
|
ResGroup = pool.get('res.group')
|
|
|
|
grp_cb, = ResGroup.search([('name', '=', 'Cashbook')])
|
|
|
|
usr_lst = ResUser.create([{
|
|
'login': 'frida',
|
|
'name': 'Frida',
|
|
'groups': [('add', [grp_cb.id])],
|
|
}, {
|
|
'login': 'diego',
|
|
'name': 'Diego',
|
|
'groups': [('add', [grp_cb.id])],
|
|
}])
|
|
self.assertEqual(len(usr_lst), 2)
|
|
self.assertEqual(usr_lst[0].name, 'Frida')
|
|
self.assertEqual(usr_lst[1].name, 'Diego')
|
|
|
|
with Transaction().set_context({
|
|
'_check_access': True,
|
|
}):
|
|
# change to user 'frida'
|
|
with Transaction().set_user(usr_lst[0].id):
|
|
cfg1 = Configuration()
|
|
cfg1.save()
|
|
|
|
cfg2 = Configuration.get_singleton()
|
|
self.assertEqual(cfg2.date_from, None)
|
|
self.assertEqual(cfg2.date_to, None)
|
|
self.assertEqual(cfg2.checked, True)
|
|
self.assertEqual(cfg2.done, False)
|
|
|
|
cfg2.date_from = date(2022, 4, 1)
|
|
cfg2.date_to = date(2022, 5, 30)
|
|
cfg2.checked = False
|
|
cfg2.save()
|
|
|
|
# change to user 'diego'
|
|
with Transaction().set_user(usr_lst[1].id):
|
|
cfg1 = Configuration()
|
|
cfg1.save()
|
|
|
|
cfg2 = Configuration.get_singleton()
|
|
self.assertEqual(cfg2.date_from, None)
|
|
self.assertEqual(cfg2.date_to, None)
|
|
self.assertEqual(cfg2.checked, True)
|
|
self.assertEqual(cfg2.done, False)
|
|
|
|
cfg2.date_from = date(2022, 4, 15)
|
|
cfg2.date_to = date(2022, 5, 15)
|
|
cfg2.save()
|
|
|
|
# change to user 'frida' - check
|
|
with Transaction().set_user(usr_lst[0].id):
|
|
cfg1 = Configuration()
|
|
cfg1.save()
|
|
|
|
cfg2 = Configuration.get_singleton()
|
|
self.assertEqual(cfg2.date_from, date(2022, 4, 1))
|
|
self.assertEqual(cfg2.date_to, date(2022, 5, 30))
|
|
self.assertEqual(cfg2.checked, False)
|
|
self.assertEqual(cfg2.done, False)
|
|
|
|
# end ConfigTestCase
|