From 89552e4a3eb158e390ef5053bfddf957deae7611 Mon Sep 17 00:00:00 2001 From: Jos De Graeve Date: Thu, 4 Jun 2015 08:17:00 +0200 Subject: [PATCH] Added testcase for orm constraint --- pos_require_customer/tests/__init__.py | 1 + pos_require_customer/tests/test_pos.py | 42 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 pos_require_customer/tests/__init__.py create mode 100644 pos_require_customer/tests/test_pos.py diff --git a/pos_require_customer/tests/__init__.py b/pos_require_customer/tests/__init__.py new file mode 100644 index 00000000..ff3270cd --- /dev/null +++ b/pos_require_customer/tests/__init__.py @@ -0,0 +1 @@ +from . import test_pos \ No newline at end of file diff --git a/pos_require_customer/tests/test_pos.py b/pos_require_customer/tests/test_pos.py new file mode 100644 index 00000000..f627297e --- /dev/null +++ b/pos_require_customer/tests/test_pos.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +import openerp.tests.common as common +from openerp import exceptions + + +class TestPosRequireCustomer(common.TransactionCase): + + def setUp(self): + super(TestPosRequireCustomer, self).setUp() + + def test_customer_not_required(self): + + posconfig = self.env.ref('point_of_sale.pos_config_main') + posconfig.require_customer = False + + pos_session = self.env['pos.session'].create({'config_id': + posconfig.id}) + + # should not raise any exception + self.env['pos.order'].create({ + 'session_id': pos_session.id, + 'partner_id': False, + }) + + def test_customer_is_required(self): + + posconfig = self.env.ref('point_of_sale.pos_config_main') + posconfig.require_customer = True + + pos_session = self.env['pos.session'].create({'config_id': + posconfig.id}) + + # should raise exceptions.ValidationError + self.assertRaises( + exceptions.ValidationError, + self.env['pos.order'].create({ + 'session_id': pos_session.id, + 'partner_id': False, + }) + ) +