Browse Source

[PORT][9.0] Adapt tests to take new constraint raising IntegrityError

pull/238/head
Yannick Vaucher 9 years ago
parent
commit
05015ef5ff
  1. 11
      partner_firstname/tests/test_empty.py

11
partner_firstname/tests/test_empty.py

@ -1,10 +1,12 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2014-2015 Grupo ESOC <www.grupoesoc.es> # © 2014-2015 Grupo ESOC <www.grupoesoc.es>
# © 2016 Yannick Vaucher (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
"""Test situations where names are empty. """Test situations where names are empty.
To have more accurate results, remove the ``mail`` module before testing. To have more accurate results, remove the ``mail`` module before testing.
""" """
import psycopg2
from openerp.tests.common import TransactionCase from openerp.tests.common import TransactionCase
from .base import MailInstalled from .base import MailInstalled
@ -19,8 +21,13 @@ class CompanyCase(TransactionCase):
def tearDown(self): def tearDown(self):
try: try:
data = {"name": self.name} data = {"name": self.name}
with self.assertRaises(ex.EmptyNamesError):
self.env[self.model].with_context(**self.context).create(data)
model = self.env[self.model].with_context(**self.context)
if self.name is False:
with self.assertRaises(psycopg2.IntegrityError):
model.create(data)
else:
with self.assertRaises(ex.EmptyNamesError):
model.create(data)
finally: finally:
super(CompanyCase, self).tearDown() super(CompanyCase, self).tearDown()

Loading…
Cancel
Save