Merge lp:~savoirfairelinux-openerp/partner-contact-management/add_tests_for_passport into lp:~savoirfairelinux-openerp/partner-contact-management/base_contact_by_functions

Status: Merged
Merged at revision: 42
Proposed branch: lp:~savoirfairelinux-openerp/partner-contact-management/add_tests_for_passport
Merge into: lp:~savoirfairelinux-openerp/partner-contact-management/base_contact_by_functions
Diff against target: 146 lines (+136/-0)
2 files modified
passport/tests/__init__.py (+27/-0)
passport/tests/test_passport.py (+109/-0)
To merge this branch: bzr merge lp:~savoirfairelinux-openerp/partner-contact-management/add_tests_for_passport
Reviewer Review Type Date Requested Status
Sandy Carter (http://www.savoirfairelinux.com) Pending
Review via email: mp+204091@code.launchpad.net

Description of the change

Add tests directory for passport module.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'passport/tests'
2=== added file 'passport/tests/__init__.py'
3--- passport/tests/__init__.py 1970-01-01 00:00:00 +0000
4+++ passport/tests/__init__.py 2014-01-30 20:05:35 +0000
5@@ -0,0 +1,27 @@
6+# -*- encoding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# This module copyright (C) 2013 Savoir-faire Linux
11+# (<http://www.savoirfairelinux.com>).
12+#
13+# This program is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU Affero General Public License as
15+# published by the Free Software Foundation, either version 3 of the
16+# License, or (at your option) any later version.
17+#
18+# This program is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU Affero General Public License for more details.
22+#
23+# You should have received a copy of the GNU Affero General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+##############################################################################
27+
28+from . import test_passport
29+
30+checks = [
31+ test_passport,
32+]
33
34=== added file 'passport/tests/test_passport.py'
35--- passport/tests/test_passport.py 1970-01-01 00:00:00 +0000
36+++ passport/tests/test_passport.py 2014-01-30 20:05:35 +0000
37@@ -0,0 +1,109 @@
38+# -*- encoding: utf-8 -*-
39+##############################################################################
40+#
41+# OpenERP, Open Source Management Solution
42+# This module copyright (C) 2013 Savoir-faire Linux
43+# (<http://www.savoirfairelinux.com>).
44+#
45+# This program is free software: you can redistribute it and/or modify
46+# it under the terms of the GNU Affero General Public License as
47+# published by the Free Software Foundation, either version 3 of the
48+# License, or (at your option) any later version.
49+#
50+# This program is distributed in the hope that it will be useful,
51+# but WITHOUT ANY WARRANTY; without even the implied warranty of
52+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53+# GNU Affero General Public License for more details.
54+#
55+# You should have received a copy of the GNU Affero General Public License
56+# along with this program. If not, see <http://www.gnu.org/licenses/>.
57+#
58+##############################################################################
59+
60+from openerp.tests.common import TransactionCase
61+from openerp.osv.orm import browse_record
62+from datetime import date
63+
64+
65+class Base_Test_passport(TransactionCase):
66+ """
67+ Simple test creating a passport
68+ This is a base class for passport test cases.
69+ Inherit from this and setup values.
70+ """
71+
72+ def setUp(self, vals={}):
73+ """
74+ Setting up passport.
75+ """
76+ # Default test values
77+ self.vals = {'name': 'This is a test passport name',
78+ 'number': 'A200124789',
79+ 'country_id': 1,
80+ 'expiration_date': date(2013, 11, 14),
81+ 'birth_date': date(1980, 11, 21),
82+ 'gender': 'male',
83+ }
84+ super(Base_Test_passport, self).setUp()
85+ # Overwrite vals if needed
86+ self.vals = dict(self.vals.items() + vals.items())
87+ # Create the passport object; we will be testing this, so store in self
88+ res_passport = self.registry('res.passport')
89+ self.passport_id = res_passport.create(self.cr, self.uid, self.vals, context=None)
90+
91+ def test_passport(self):
92+ """
93+ Checking the passport creation.
94+ """
95+ res_passport = self.registry('res.passport')
96+ passport_obj = res_passport.browse(self.cr, self.uid, self.passport_id, context=None)
97+ for field in self.vals:
98+ val = passport_obj[field]
99+ if type(val) == browse_record:
100+ self.assertEquals(self.vals[field], val.id,
101+ "IDs for %s don't match: (%i != %i)" %
102+ (field, self.vals[field], val.id))
103+ else:
104+ self.assertEquals(str(self.vals[field]), str(val),
105+ "Values for %s don't match: (%s != %s)" %
106+ (field, str(self.vals[field]), str(val)))
107+
108+
109+class Test_passport_bad(Base_Test_passport):
110+ """
111+ Simple test creating a passport, test against bad values
112+ """
113+ def setUp(self):
114+ """
115+ Setting up passport, then changing the values to test against.
116+ """
117+ super(Test_passport_bad, self).setUp()
118+ # Change vals to something wrong
119+ self.vals = {
120+ 'name': 'This is the wrong passport name',
121+ 'number': 'A111111111',
122+ 'country_id': 0,
123+ 'expiration_date': date(1999, 11, 14),
124+ 'birth_date': date(1999, 11, 21),
125+ 'gender': '',
126+ }
127+
128+ def test_passport(self):
129+ """
130+ Checking the passport creation, assertions should all be false.
131+ """
132+ res_passport = self.registry('res.passport')
133+ passport_obj = res_passport.browse(self.cr, self.uid, self.passport_id, context=None)
134+ for field in self.vals:
135+ val = passport_obj[field]
136+ if type(val) == browse_record:
137+ self.assertNotEqual(self.vals[field], val.id,
138+ "IDs for %s don't match: (%i != %i)" %
139+ (field, self.vals[field], val.id))
140+ else:
141+ self.assertNotEqual(str(self.vals[field]), str(val),
142+ "Values for %s don't match: (%s != %s)" %
143+ (field, str(self.vals[field]), str(val)))
144+
145+
146+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches

to all changes: