trytond-party_company/tests/test_party_company.py

59 lines
1.9 KiB
Python
Raw Normal View History

2017-05-25 15:59:45 +02:00
# This file is part party_company module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
from trytond.pool import Pool
2017-05-26 13:46:50 +02:00
from trytond.modules.company.tests import create_company, set_company
2017-05-25 15:59:45 +02:00
class PartyCompanyTestCase(ModuleTestCase):
'Test Party Company module'
module = 'party_company'
2017-05-26 13:46:50 +02:00
@with_transaction()
def test_party(self):
'Create party'
pool = Pool()
Party = pool.get('party.party')
party1, = Party.create([{
'name': 'Party 1',
}])
self.assert_(party1.id)
self.assertEqual(party1.companies, ())
2017-05-26 13:46:50 +02:00
@with_transaction()
def test_party_company(self):
'Create party company'
pool = Pool()
Party = pool.get('party.party')
Address = pool.get('party.address')
User = pool.get('res.user')
2017-05-26 13:46:50 +02:00
company = create_company()
with set_company(company):
party = Party()
party.name = 'Party 2'
party.companies = [company]
party.save()
self.assert_(party.id)
self.assertEqual(len(party.companies), 1)
address, = Address.create([{
'party': party.id,
'street': 'St sample, 15',
'city': 'City',
}])
self.assertEqual(address.companies == (company,), True)
2017-05-26 13:46:50 +02:00
address1, address2 = Address.search([])
self.assertEqual(address1.companies, ())
self.assertEqual(address2.companies == (company,), True)
2017-05-26 13:46:50 +02:00
2017-05-25 15:59:45 +02:00
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
PartyCompanyTestCase))
return suite