/usr/lib/python2.7/dist-packages/trytond/modules/company/tests/test_company.py is in tryton-modules-company 3.8.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | # 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 unittest
import doctest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT
from trytond.transaction import Transaction
class CompanyTestCase(ModuleTestCase):
'Test Company module'
module = 'company'
def setUp(self):
super(CompanyTestCase, self).setUp()
self.party = POOL.get('party.party')
self.company = POOL.get('company.company')
self.employee = POOL.get('company.employee')
self.currency = POOL.get('currency.currency')
self.user = POOL.get('res.user')
def test0010company(self):
'Create company'
with Transaction().start(DB_NAME, USER,
context=CONTEXT) as transaction:
currency1, = self.currency.search([
('code', '=', 'cu1'),
], 0, 1, None)
party1, = self.party.create([{
'name': 'Dunder Mifflin',
'addresses': [('create', [{}])],
}])
company1, = self.company.create([{
'party': party1.id,
'currency': currency1.id,
}])
self.assert_(company1)
transaction.cursor.commit()
def test0020company_recursion(self):
'Test company recursion'
with Transaction().start(DB_NAME, USER, context=CONTEXT):
currency1, = self.currency.search([
('code', '=', 'cu1'),
], 0, 1, None)
company1, = self.company.search([
('rec_name', '=', 'Dunder Mifflin'),
], 0, 1, None)
party2, = self.party.create([{
'name': 'Michael Scott Paper Company',
}])
company2, = self.company.create([{
'party': party2.id,
'parent': company1.id,
'currency': currency1.id,
}])
self.assert_(company2)
self.assertRaises(Exception, self.company.write,
[company1], {
'parent': company2.id,
})
def test0030employe(self):
'Create employee'
with Transaction().start(DB_NAME, USER,
context=CONTEXT) as transaction:
company1, = self.company.search([
('rec_name', '=', 'Dunder Mifflin'),
], 0, 1, None)
party, = self.party.create([{
'name': 'Pam Beesly',
}])
self.employee.create([{
'party': party.id,
'company': company1.id,
}])
transaction.cursor.commit()
def test0040user(self):
'Test user company'
with Transaction().start(DB_NAME, USER,
context=CONTEXT) as transaction:
currency1, = self.currency.search([
('code', '=', 'cu1'),
], 0, 1, None)
company1, = self.company.search([
('rec_name', '=', 'Dunder Mifflin'),
], 0, 1, None)
party2, = self.party.create([{
'name': 'Michael Scott Paper Company',
}])
company2, = self.company.create([{
'party': party2.id,
'parent': company1.id,
'currency': currency1.id,
}])
user1, user2 = self.user.create([{
'name': 'Jim Halper',
'login': 'jim',
'main_company': company1.id,
'company': company1.id,
}, {
'name': 'Pam Beesly',
'login': 'pam',
'main_company': company2.id,
'company': company2.id,
}])
self.assert_(user1)
with transaction.set_user(user1.id):
user1, user2 = self.user.browse([user1.id, user2.id])
self.assertEqual(user1.company, company1)
self.assertEqual(user2.company, company2)
with transaction.set_context({'company': company2.id}):
user1, user2 = self.user.browse([user1.id, user2.id])
self.assertEqual(user1.company, company2)
self.assertEqual(user2.company, company2)
with transaction.set_context({'company': None}):
user1, user2 = self.user.browse([user1.id, user2.id])
self.assertEqual(user1.company, None)
self.assertEqual(user2.company, company2)
def suite():
suite = trytond.tests.test_tryton.suite()
from trytond.modules.currency.tests import test_currency
for test in test_currency.suite():
if test not in suite and not isinstance(test, doctest.DocTestCase):
suite.addTest(test)
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
CompanyTestCase))
return suite
|