Merge lp:~openerp-commiter/openobject-addons/UnitTestCases into lp:openobject-addons
- UnitTestCases
- Merge into trunk
Proposed by
Naresh(OpenERP)
Status: | Rejected |
---|---|
Rejected by: | Harry (OpenERP) |
Proposed branch: | lp:~openerp-commiter/openobject-addons/UnitTestCases |
Merge into: | lp:openobject-addons |
Diff against target: |
11300 lines (has conflicts)
Conflict adding files to account_balance. Created directory. Conflict because account_balance is not versioned, but has versioned children. Versioned directory. Text conflict in base_module_quality/unit_test/__init__.py Text conflict in base_module_quality/unit_test/unit_test.py Conflict adding files to crm_configuration. Created directory. Conflict because crm_configuration is not versioned, but has versioned children. Versioned directory. Text conflict in sale/unit_test/__init__.py Text conflict in sale/unit_test/test.py |
To merge this branch: | bzr merge lp:~openerp-commiter/openobject-addons/UnitTestCases |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+15732@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote : | # |
Revision history for this message
Mantavya Gajjar (Open ERP) (mga) wrote : | # |
hello !!
can you please convert TAB->SPACE(4), as in openerp we use space(4) instead of tab
regards,
mga
- 2588. By Naresh(OpenERP)
-
[IMP]:1 tab--> 4 spaces
Unmerged revisions
- 2588. By Naresh(OpenERP)
-
[IMP]:1 tab--> 4 spaces
- 2587. By Naresh(OpenERP)
-
[IMP]:accounting report
- 2586. By Naresh(OpenERP)
-
[IMP]:warning
- 2585. By Naresh(OpenERP)
-
[FIX]:account_
followup wizard - 2584. By vir (Open ERP)
-
[MOD,IMP] improved code and added reusability
- 2583. By Naresh(OpenERP)
-
[IMP]:crm_
configuration - 2582. By rvo(OpennERP)
-
[ADD]:testcase for hr_holidays
- 2581. By rga(OpenERP)
-
[ADD]:unittest cases for account_report
- 2580. By vir (Open ERP)
-
[MOD] Removed unused lines of code
- 2579. By vir (Open ERP)
-
[ADD] Unit test case for warning module
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'account/unit_test' | |||
2 | === added file 'account/unit_test/__init__.py' | |||
3 | --- account/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
4 | +++ account/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
5 | @@ -0,0 +1,22 @@ | |||
6 | 1 | # -*- coding: utf-8 -*- | ||
7 | 2 | ############################################################################## | ||
8 | 3 | # | ||
9 | 4 | # OpenERP, Open Source Management Solution | ||
10 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
11 | 6 | # | ||
12 | 7 | # This program is free software: you can redistribute it and/or modify | ||
13 | 8 | # it under the terms of the GNU Affero General Public License as | ||
14 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
15 | 10 | # License, or (at your option) any later version. | ||
16 | 11 | # | ||
17 | 12 | # This program is distributed in the hope that it will be useful, | ||
18 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | 15 | # GNU Affero General Public License for more details. | ||
21 | 16 | # | ||
22 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
23 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
24 | 19 | # | ||
25 | 20 | ############################################################################## | ||
26 | 21 | |||
27 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
28 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
29 | 1 | 24 | ||
30 | === added file 'account/unit_test/test.py' | |||
31 | --- account/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
32 | +++ account/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
33 | @@ -0,0 +1,374 @@ | |||
34 | 1 | # -*- coding: utf-8 -*- | ||
35 | 2 | ############################################################################## | ||
36 | 3 | # | ||
37 | 4 | # OpenERP, Open Source Management Solution | ||
38 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
39 | 6 | # | ||
40 | 7 | # This program is free software: you can redistribute it and/or modify | ||
41 | 8 | # it under the terms of the GNU Affero General Public License as | ||
42 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
43 | 10 | # License, or (at your option) any later version. | ||
44 | 11 | # | ||
45 | 12 | # This program is distributed in the hope that it will be useful, | ||
46 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
47 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
48 | 15 | # GNU Affero General Public License for more details. | ||
49 | 16 | # | ||
50 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
51 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
52 | 19 | # | ||
53 | 20 | ############################################################################## | ||
54 | 21 | import unittest | ||
55 | 22 | import pooler | ||
56 | 23 | from osv import osv | ||
57 | 24 | import netsvc | ||
58 | 25 | import time | ||
59 | 26 | import product.unit_test.test as prod | ||
60 | 27 | |||
61 | 28 | invoice_invoice_ids=None | ||
62 | 29 | invoice_line_ids=None | ||
63 | 30 | period_id=None | ||
64 | 31 | case_journal_id=None | ||
65 | 32 | sale_journal_id=None | ||
66 | 33 | purchase_journal_id=None | ||
67 | 34 | account_account_id=None | ||
68 | 35 | account_account_types=None | ||
69 | 36 | partner_id=None | ||
70 | 37 | account_tax_id=None | ||
71 | 38 | account_payment_term_line_id=None | ||
72 | 39 | account_payment_term_id=None | ||
73 | 40 | |||
74 | 41 | class account(unittest.TestCase): | ||
75 | 42 | third_party_cases={prod.product_test_case: ['test_1_Create']} | ||
76 | 43 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
77 | 44 | self.cr = cursor | ||
78 | 45 | self.uid = user | ||
79 | 46 | unittest.TestCase.__init__(self, methodName) | ||
80 | 47 | |||
81 | 48 | def setUp(self): | ||
82 | 49 | try: | ||
83 | 50 | self.pool = pooler.get_pool(self.cr.dbname) | ||
84 | 51 | self.account_account = self.pool.get('account.account') | ||
85 | 52 | self.account_invoice = self.pool.get('account.invoice') | ||
86 | 53 | self.account_move = self.pool.get('account.move') | ||
87 | 54 | self.account_move_line = self.pool.get('account.move.line') | ||
88 | 55 | self.account_invoice_line = self.pool.get('account.invoice.line') | ||
89 | 56 | self.wf_service = netsvc.LocalService("workflow") | ||
90 | 57 | self.wizard_service = netsvc.ExportService.getService("wizard") | ||
91 | 58 | except osv.except_osv,e: | ||
92 | 59 | self.fail(e.name + e.value) | ||
93 | 60 | except Exception,e: | ||
94 | 61 | self.fail(e) | ||
95 | 62 | |||
96 | 63 | def tearDown(self): | ||
97 | 64 | try: | ||
98 | 65 | self.pool = None | ||
99 | 66 | self.account_move = None | ||
100 | 67 | self.account_move_line = None | ||
101 | 68 | self.account_invoice = None | ||
102 | 69 | self.account_invoice_line = None | ||
103 | 70 | self.wf_service = None | ||
104 | 71 | self.wizard_service = None | ||
105 | 72 | self.passwd = None | ||
106 | 73 | except osv.except_osv,e: | ||
107 | 74 | self.fail(e.name + e.value) | ||
108 | 75 | except Exception,e: | ||
109 | 76 | self.fail(e) | ||
110 | 77 | |||
111 | 78 | |||
112 | 79 | def test_1_creat_payment_term(self): | ||
113 | 80 | try: | ||
114 | 81 | global invoice_invoice_ids,invoice_line_ids,period_id,case_journal_id,sale_journal_id,purchase_journal_id,account_account_id,account_account_types,partner_id,account_tax_id,account_payment_term_line_id,account_payment_term_id | ||
115 | 82 | #Create Payment Term | ||
116 | 83 | account_payment_term_id = self.pool.get('account.payment.term').create(self.cr,self.uid,{'name':'Payment Term Unit test'}) | ||
117 | 84 | account_payment_term_line_id = self.pool.get('account.payment.term.line').create(self.cr,self.uid,{ | ||
118 | 85 | 'name':'Payment term unit test by', | ||
119 | 86 | 'sequence':1, | ||
120 | 87 | 'value':'procent', | ||
121 | 88 | 'value_amount':0.20, | ||
122 | 89 | 'days': 20, | ||
123 | 90 | 'days2':-1, | ||
124 | 91 | 'payment_id':account_payment_term_id, | ||
125 | 92 | }) | ||
126 | 93 | |||
127 | 94 | #Create Tax | ||
128 | 95 | account_tax_id = self.pool.get('account.tax').create(self.cr,self.uid,{'name':'VAT(Unit test)','amount':0.1200}) | ||
129 | 96 | |||
130 | 97 | #Create Account Type | ||
131 | 98 | account_account_types=[] | ||
132 | 99 | types= ['expense','income','cash'] | ||
133 | 100 | for type in types: | ||
134 | 101 | method = 'unreconciled' | ||
135 | 102 | if type == 'case': | ||
136 | 103 | method = 'balance' | ||
137 | 104 | account_type = self.pool.get('account.account.type').create(self.cr,self.uid,{ | ||
138 | 105 | 'name':'Test %s' % type.capitalize(), | ||
139 | 106 | 'code':type, | ||
140 | 107 | 'close_method':'unreconciled'}) | ||
141 | 108 | account_account_types.append(account_type) | ||
142 | 109 | |||
143 | 110 | account_account_types.extend(account_account_types) | ||
144 | 111 | accounts = ['payable','receivable','other','other','other','other'] | ||
145 | 112 | name = ['Test Main Payable','Test Main Receivable','Others','Test Product Purchase','Test Product Sale','Test Petty Cash'] | ||
146 | 113 | code = ['x-10','x-20','x-30','x-40','x-50','x-60'] | ||
147 | 114 | account_account_id = [] | ||
148 | 115 | for seq in range(0,len(accounts)): | ||
149 | 116 | account_account = self.pool.get('account.account').create(self.cr,self.uid,{ | ||
150 | 117 | 'name':name[seq], | ||
151 | 118 | 'code':code[seq], | ||
152 | 119 | 'reconcile':True, | ||
153 | 120 | 'type':accounts[seq], | ||
154 | 121 | 'user_type':account_account_types[seq], | ||
155 | 122 | }) | ||
156 | 123 | account_account_id.append(account_account) | ||
157 | 124 | model_obj = self.pool.get('ir.model.data') | ||
158 | 125 | sale_sequence = model_obj._get_id(self.cr,self.uid, 'account', 'sequence_sale_journal') | ||
159 | 126 | sale_sequence_id = model_obj.browse(self.cr, self.uid, sale_sequence).res_id | ||
160 | 127 | |||
161 | 128 | period = model_obj._get_id(self.cr,self.uid, 'account', 'period_11') | ||
162 | 129 | period_id = model_obj.browse(self.cr, self.uid, period).res_id | ||
163 | 130 | |||
164 | 131 | purchase_sequence = model_obj._get_id(self.cr,self.uid, 'account', 'sequence_purchase_journal') | ||
165 | 132 | purchase_sequence_id = model_obj.browse(self.cr, self.uid, purchase_sequence).res_id | ||
166 | 133 | |||
167 | 134 | |||
168 | 135 | case_sequence = model_obj._get_id(self.cr,self.uid,'account','sequence_journal') | ||
169 | 136 | case_sequence_id = model_obj.browse(self.cr,self.uid,case_sequence).res_id | ||
170 | 137 | |||
171 | 138 | |||
172 | 139 | view_id = self.pool.get('account.journal.view').search(self.cr,self.uid,[('name','=','Journal View')])[0] | ||
173 | 140 | |||
174 | 141 | #sale Journal | ||
175 | 142 | sale_journal_id = self.pool.get('account.journal').create(self.cr,self.uid,{ | ||
176 | 143 | 'name':'Sale Unit Test Journal', | ||
177 | 144 | 'code':'STJ', | ||
178 | 145 | 'view_id':view_id, | ||
179 | 146 | 'sequence_id':sale_sequence_id, | ||
180 | 147 | 'type':'sale', | ||
181 | 148 | 'update_posted':True, | ||
182 | 149 | 'default_credit_account_id':account_account_id[4], | ||
183 | 150 | 'default_debit_account_id':account_account_id[4]}) | ||
184 | 151 | #purchase journal | ||
185 | 152 | purchase_journal_id = self.pool.get('account.journal').create(self.cr,self.uid,{ | ||
186 | 153 | 'name':'Purchase Expense Unit Test Journal', | ||
187 | 154 | 'code':'PTJ', | ||
188 | 155 | 'view_id':view_id, | ||
189 | 156 | 'sequence_id':purchase_sequence_id, | ||
190 | 157 | 'type':'purchase', | ||
191 | 158 | 'update_posted':True, | ||
192 | 159 | 'default_credit_account_id':account_account_id[3], | ||
193 | 160 | 'default_debit_account_id':account_account_id[3]}) | ||
194 | 161 | view_case_id = self.pool.get('account.journal.view').search(self.cr,self.uid,[('name','=','Cash Journal View')])[0] | ||
195 | 162 | #case journal | ||
196 | 163 | case_journal_id = self.pool.get('account.journal').create(self.cr,self.uid,{ | ||
197 | 164 | 'name':'Case Unit Test Journal', | ||
198 | 165 | 'code':'CTJ', | ||
199 | 166 | 'view_id':view_case_id, | ||
200 | 167 | 'sequence_id':case_sequence_id, | ||
201 | 168 | 'type':'cash', | ||
202 | 169 | 'update_posted':True, | ||
203 | 170 | 'default_credit_account_id':account_account_id[5], | ||
204 | 171 | 'default_debit_account_id':account_account_id[5]}) | ||
205 | 172 | #Config Product | ||
206 | 173 | fields_sale_id = self.pool.get('ir.model.fields').search(self.cr,self.uid,[('model','=','product.template'),('name','=','property_account_income')]) | ||
207 | 174 | res_id = 'product.template,'+ str(prod.product_id) | ||
208 | 175 | sale_account_id = 'account.account,'+ str(account_account_id[4]) | ||
209 | 176 | company_id = self.pool.get('res.company').search(self.cr,self.uid,[('name','=','Tiny sprl')]) | ||
210 | 177 | |||
211 | 178 | property_sale_id = self.pool.get('ir.property').create(self.cr,self.uid,{ | ||
212 | 179 | 'fields_id':fields_sale_id[0], | ||
213 | 180 | 'res_id':res_id, | ||
214 | 181 | 'name':'property_account_income', | ||
215 | 182 | 'value':sale_account_id, | ||
216 | 183 | 'company_id':company_id[0] | ||
217 | 184 | }) | ||
218 | 185 | fields_purchase_id = self.pool.get('ir.model.fields').search(self.cr,self.uid,[('model','=','product.template'),('name','=','property_account_expense')]) | ||
219 | 186 | purchase_account_id = 'account.account,'+ str(account_account_id[3]) | ||
220 | 187 | property_purchase_id = self.pool.get('ir.property').create(self.cr,self.uid,{ | ||
221 | 188 | 'fields_id':fields_purchase_id[0], | ||
222 | 189 | 'res_id':res_id, | ||
223 | 190 | 'name':'property_account_expense', | ||
224 | 191 | 'value':purchase_account_id, | ||
225 | 192 | 'company_id':company_id[0] | ||
226 | 193 | }) | ||
227 | 194 | #Config partner | ||
228 | 195 | partner_id = self.pool.get('res.partner').create(self.cr,self.uid,{ | ||
229 | 196 | 'name':'Unit test partner', | ||
230 | 197 | 'supplier':True, | ||
231 | 198 | }) | ||
232 | 199 | partner_address = self.pool.get('res.partner.address').create(self.cr,self.uid,{ | ||
233 | 200 | 'name':'Unit test Address', | ||
234 | 201 | 'phone':'111-22222-33', | ||
235 | 202 | 'type':'default', | ||
236 | 203 | 'partner_id':partner_id | ||
237 | 204 | }) | ||
238 | 205 | res_id = 'res.partner,'+ str(partner_id) | ||
239 | 206 | fields_partner_rece_id = self.pool.get('ir.model.fields').search(self.cr,self.uid,[('model','=','res.partner'),('name','=','property_account_receivable')]) | ||
240 | 207 | partner_rece_account_id = 'account.account,'+ str(account_account_id[1]) | ||
241 | 208 | partner_rece_property_id = self.pool.get('ir.property').create(self.cr,self.uid,{ | ||
242 | 209 | 'fields_id':fields_partner_rece_id[0], | ||
243 | 210 | 'res_id':res_id, | ||
244 | 211 | 'name':'property_account_receivable', | ||
245 | 212 | 'value':partner_rece_account_id, | ||
246 | 213 | 'company_id':company_id[0] | ||
247 | 214 | }) | ||
248 | 215 | |||
249 | 216 | fields_partner_pay_id = self.pool.get('ir.model.fields').search(self.cr,self.uid,[('model','=','res.partner'),('name','=','property_account_payable')]) | ||
250 | 217 | partner_pay_account_id = 'account.account,'+ str(account_account_id[0]) | ||
251 | 218 | partner_pay_property_id = self.pool.get('ir.property').create(self.cr,self.uid,{ | ||
252 | 219 | 'fields_id':fields_partner_pay_id[0], | ||
253 | 220 | 'res_id':res_id, | ||
254 | 221 | 'name':'property_account_payable', | ||
255 | 222 | 'value':partner_pay_account_id, | ||
256 | 223 | 'company_id':company_id[0] | ||
257 | 224 | }) | ||
258 | 225 | #Create Customer Invoice | ||
259 | 226 | invoice_invoice_ids=[] | ||
260 | 227 | invoice_line_ids = [] | ||
261 | 228 | types = {'out_invoice':sale_journal_id,'in_invoice':purchase_journal_id} | ||
262 | 229 | for key,val in types.items(): | ||
263 | 230 | #Call Onchange Partner Id | ||
264 | 231 | res = self.pool.get('account.invoice').onchange_partner_id(self.cr, self.uid, [], key, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False) | ||
265 | 232 | invoice_id = self.pool.get('account.invoice').create(self.cr,self.uid,{ | ||
266 | 233 | 'journal_id':val, | ||
267 | 234 | 'address_invoice_id':res['value']['address_invoice_id'], | ||
268 | 235 | 'partner_id':partner_id, | ||
269 | 236 | 'type':key, | ||
270 | 237 | 'address_contact_id':res['value']['address_contact_id'], | ||
271 | 238 | 'account_id':res['value']['account_id'], | ||
272 | 239 | 'payment_term':res['value']['payment_term'] | ||
273 | 240 | }) | ||
274 | 241 | invoice_invoice_ids.append(invoice_id) | ||
275 | 242 | uom = False | ||
276 | 243 | #Call Onchange Product Id | ||
277 | 244 | res1 = self.pool.get('account.invoice.line').product_id_change(self.cr, self.uid, [], prod.product_id, uom, qty=0, name='', type=key, partner_id=partner_id, fposition_id=False, price_unit=False, address_invoice_id=False, context=None) | ||
278 | 245 | if res1['value']['price_unit'] == False: | ||
279 | 246 | res1['value']['price_unit']=5000 | ||
280 | 247 | invoice_line_id = self.pool.get('account.invoice.line').create(self.cr,self.uid,{ | ||
281 | 248 | 'name':res1['value']['name'], | ||
282 | 249 | 'uos_id':res1['value']['uos_id'], | ||
283 | 250 | 'invoice_id':invoice_id, | ||
284 | 251 | 'price_unit':res1['value']['price_unit'], | ||
285 | 252 | 'account_id':res1['value']['account_id'], | ||
286 | 253 | 'product_id':prod.product_id | ||
287 | 254 | }) | ||
288 | 255 | invoice_line_ids.append(invoice_line_id) | ||
289 | 256 | |||
290 | 257 | except osv.except_osv,e: | ||
291 | 258 | self.fail(e.name + e.value) | ||
292 | 259 | except Exception,e: | ||
293 | 260 | |||
294 | 261 | self.fail(e) | ||
295 | 262 | |||
296 | 263 | def test_2_validate_customer_invoice(self): | ||
297 | 264 | try: | ||
298 | 265 | self.failUnless(len(invoice_invoice_ids),"No Customer Invoices Created !") | ||
299 | 266 | self.wf_service.trg_validate(self.uid, 'account.invoice',invoice_invoice_ids[1],'invoice_open', self.cr) | ||
300 | 267 | |||
301 | 268 | except osv.except_osv,e: | ||
302 | 0 | self.fail(e.name + e.value) | 269 | self.fail(e.name + e.value) |
303 | 270 | except Exception,e: | ||
304 | 271 | self.fail(e) | ||
305 | 272 | |||
306 | 273 | def test_3_validate_supplier_invoice(self): | ||
307 | 274 | try: | ||
308 | 275 | self.failUnless(len(invoice_invoice_ids),"No Supplier Invoices Created !") | ||
309 | 276 | self.account_invoice.button_compute(self.cr, self.uid,[invoice_invoice_ids[0]], context=None, set_total=True) | ||
310 | 277 | self.wf_service.trg_validate(self.uid, 'account.invoice',invoice_invoice_ids[0],'invoice_open', self.cr) | ||
311 | 278 | except osv.except_osv,e: | ||
312 | 1 | self.fail(e.name + e.value) | 279 | self.fail(e.name + e.value) |
313 | 280 | except Exception,e: | ||
314 | 281 | self.fail(e) | ||
315 | 282 | |||
316 | 283 | def test_4_pay_customer_invoice(self): | ||
317 | 284 | try: | ||
318 | 285 | self.cr.commit() | ||
319 | 286 | self.failUnless(len(invoice_invoice_ids),"No Supplier Invoices Created !") | ||
320 | 287 | invoice_rec = self.pool.get('account.invoice').browse(self.cr,self.uid,invoice_invoice_ids[1]) | ||
321 | 288 | wizard_res = self.wizard_service.exp_create(self.cr.dbname, self.uid, 'account.invoice.pay') | ||
322 | 289 | datas = {'form':{'name':'Unit Test Supplier Invoice Paid', | ||
323 | 290 | 'amount': invoice_rec.residual, | ||
324 | 291 | 'date': time.strftime('%Y-%m-%d'), | ||
325 | 292 | 'period_id':period_id,'journal_id':case_journal_id}, | ||
326 | 293 | 'ids':[invoice_invoice_ids[1]],'id':invoice_invoice_ids[1]} | ||
327 | 2 | state = 'reconcile' | 294 | state = 'reconcile' |
328 | 295 | self.wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
329 | 296 | except osv.except_osv,e: | ||
330 | 297 | self.fail(e.name + e.value) | ||
331 | 298 | except Exception,e: | ||
332 | 299 | self.fail(e) | ||
333 | 300 | |||
334 | 301 | |||
335 | 302 | def test_5_pay_supplier_invoice(self): | ||
336 | 303 | try: | ||
337 | 304 | self.cr.commit() | ||
338 | 305 | self.failUnless(len(invoice_invoice_ids),"No Customer Invoices Created !") | ||
339 | 306 | invoice_rec = self.pool.get('account.invoice').browse(self.cr,self.uid,invoice_invoice_ids[0]) | ||
340 | 307 | wizard_res = self.wizard_service.exp_create(self.cr.dbname, self.uid, 'account.invoice.pay') | ||
341 | 3 | datas = {'form': | 308 | datas = {'form': |
342 | 309 | {'name':'Unit Test Customer Invoice Paid', | ||
343 | 310 | 'amount': invoice_rec.residual, | ||
344 | 311 | 'date': time.strftime('%Y-%m-%d'), | ||
345 | 312 | 'period_id':period_id, | ||
346 | 313 | 'journal_id':case_journal_id }, | ||
347 | 314 | 'ids':[invoice_invoice_ids[0]], | ||
348 | 315 | 'id':invoice_invoice_ids[0]} | ||
349 | 4 | state = 'reconcile' | 316 | state = 'reconcile' |
350 | 317 | self.wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
351 | 318 | except osv.except_osv,e: | ||
352 | 319 | self.fail(e.name + e.value) | ||
353 | 320 | except Exception,e: | ||
354 | 321 | self.fail(e) | ||
355 | 322 | |||
356 | 323 | def test_6_unreconcile_and_unlink_invoice(self): | ||
357 | 5 | try: | 324 | try: |
358 | 325 | self.failUnless(len(invoice_invoice_ids),"No invoice Created !") | ||
359 | 326 | for invoice_rec in self.pool.get('account.invoice').browse(self.cr,self.uid,invoice_invoice_ids): | ||
360 | 327 | move = self.pool.get('account.move.line').browse(self.cr,self.uid,invoice_rec.payment_ids[0].id) | ||
361 | 328 | entries = self.pool.get('account.move.line').search(self.cr,self.uid,[('move_id','=',invoice_rec.move_id.id)]) | ||
362 | 329 | entries.append(invoice_rec.payment_ids[0].id) | ||
363 | 330 | for entry in entries: | ||
364 | 331 | wizard_res = self.wizard_service.exp_create(self.cr.dbname, self.uid, 'account.move.line.unreconcile') | ||
365 | 332 | datas = {'form':{},'ids':[entry],'id':entry,'model':'account.move.line'} | ||
366 | 333 | state = 'unrec' | ||
367 | 334 | self.wizard_service.exp_execute(self.cr.dbname, self.uid,wizard_res , datas, state, {}) | ||
368 | 335 | self.pool.get('account.move').unlink(self.cr,self.uid,[move.move_id.id]) | ||
369 | 336 | self.wf_service.trg_validate(self.uid, 'account.invoice',invoice_rec.id,'open_test', self.cr) | ||
370 | 337 | self.wf_service.trg_validate(self.uid, 'account.invoice',invoice_rec.id,'invoice_cancel',self.cr) | ||
371 | 338 | self.account_invoice.unlink(self.cr,self.uid,invoice_invoice_ids) | ||
372 | 339 | #unlink payment term | ||
373 | 340 | self.failUnless(account_payment_term_line_id,"No payment term line Created !") | ||
374 | 341 | self.pool.get('account.payment.term.line').unlink(self.cr,self.uid,[account_payment_term_line_id]) | ||
375 | 342 | |||
376 | 343 | self.failUnless(account_payment_term_id,"No payment term Created !") | ||
377 | 344 | self.pool.get('account.payment.term').unlink(self.cr,self.uid,[account_payment_term_id]) | ||
378 | 345 | |||
379 | 346 | #unlink accounts | ||
380 | 347 | self.failUnless(len(account_account_id),"No Account Created !") | ||
381 | 348 | self.account_account.unlink(self.cr,self.uid,account_account_id) | ||
382 | 349 | |||
383 | 350 | #unlink account types | ||
384 | 351 | self.failUnless(len(account_account_types),"No Account types Created !") | ||
385 | 352 | self.pool.get('account.account.type').unlink(self.cr,self.uid,account_account_types) | ||
386 | 353 | |||
387 | 354 | #unlink tax | ||
388 | 355 | self.failUnless(account_tax_id,"No Tax Created !") | ||
389 | 356 | self.pool.get('account.tax').unlink(self.cr,self.uid,[account_tax_id]) | ||
390 | 357 | |||
391 | 358 | #unlink journal | ||
392 | 359 | self.pool.get('account.journal').unlink(self.cr,self.uid,[sale_journal_id,purchase_journal_id,case_journal_id]) | ||
393 | 360 | #unlink product | ||
394 | 361 | self.failUnless(prod.product_id,"No Product Created !") | ||
395 | 362 | self.pool.get('product.product').unlink(self.cr,self.uid,[prod.product_id]) | ||
396 | 363 | self.pool.get('product.pricelist.item').unlink(self.cr, self.uid,[prod.product_pricelist_items_id]) | ||
397 | 364 | self.pool.get('product.pricelist.version').unlink(self.cr,self.uid,[prod.product_pricelist_version_id]) | ||
398 | 365 | self.pool.get('product.pricelist').unlink(self.cr,self.uid,[prod.product_pricelist_id]) | ||
399 | 366 | self.pool.get('product.pricelist.type').unlink(self.cr,self.uid,[prod.pricelist_type_id]) | ||
400 | 367 | #unlink partner | ||
401 | 368 | self.pool.get('res.partner').unlink(self.cr,self.uid,[partner_id]) | ||
402 | 369 | except osv.except_osv,e: | ||
403 | 6 | self.fail(e.name + e.value) | 370 | self.fail(e.name + e.value) |
404 | 371 | except Exception,e: | ||
405 | 372 | self.fail(e) | ||
406 | 373 | |||
407 | 374 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
408 | 375 | |||
409 | 376 | |||
410 | 377 | |||
411 | 378 | |||
412 | 379 | |||
413 | 380 | |||
414 | 381 | |||
415 | 7 | 382 | ||
416 | === added directory 'account_analytic_analysis/unit_test' | |||
417 | === added file 'account_analytic_analysis/unit_test/__init__.py' | |||
418 | --- account_analytic_analysis/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
419 | +++ account_analytic_analysis/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
420 | @@ -0,0 +1,23 @@ | |||
421 | 1 | # -*- coding: utf-8 -*- | ||
422 | 2 | ############################################################################## | ||
423 | 3 | # | ||
424 | 4 | # OpenERP, Open Source Management Solution | ||
425 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
426 | 6 | # | ||
427 | 7 | # This program is free software: you can redistribute it and/or modify | ||
428 | 8 | # it under the terms of the GNU Affero General Public License as | ||
429 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
430 | 10 | # License, or (at your option) any later version. | ||
431 | 11 | # | ||
432 | 12 | # This program is distributed in the hope that it will be useful, | ||
433 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
434 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
435 | 15 | # GNU Affero General Public License for more details. | ||
436 | 16 | # | ||
437 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
438 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
439 | 19 | # | ||
440 | 20 | ############################################################################## | ||
441 | 21 | |||
442 | 22 | |||
443 | 23 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
444 | 0 | 24 | ||
445 | === added file 'account_analytic_analysis/unit_test/test.py' | |||
446 | --- account_analytic_analysis/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
447 | +++ account_analytic_analysis/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
448 | @@ -0,0 +1,123 @@ | |||
449 | 1 | # -*- coding: utf-8 -*- | ||
450 | 2 | ############################################################################## | ||
451 | 3 | # | ||
452 | 4 | # OpenERP, Open Source Management Solution | ||
453 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
454 | 6 | # | ||
455 | 7 | # This program is free software: you can redistribute it and/or modify | ||
456 | 8 | # it under the terms of the GNU Affero General Public License as | ||
457 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
458 | 10 | # License, or (at your option) any later version. | ||
459 | 11 | # | ||
460 | 12 | # This program is distributed in the hope that it will be useful, | ||
461 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
462 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
463 | 15 | # GNU Affero General Public License for more details. | ||
464 | 16 | # | ||
465 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
466 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
467 | 19 | # | ||
468 | 20 | ############################################################################## | ||
469 | 21 | |||
470 | 22 | import unittest | ||
471 | 23 | import pooler | ||
472 | 24 | from osv import osv | ||
473 | 25 | import netsvc | ||
474 | 26 | |||
475 | 27 | analytic_account_id =None | ||
476 | 28 | |||
477 | 29 | class account_analytic_analysis(unittest.TestCase): | ||
478 | 30 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
479 | 31 | self.cr = cursor | ||
480 | 32 | self.uid = user | ||
481 | 33 | unittest.TestCase.__init__(self, methodName) | ||
482 | 34 | |||
483 | 35 | def setUp(self): | ||
484 | 36 | try: | ||
485 | 37 | self.pool = pooler.get_pool(self.cr.dbname) | ||
486 | 38 | self.hr_anlalytic_timesheet = self.pool.get('hr.analytic.timesheet') | ||
487 | 39 | self.analytic_account = self.pool.get('account.analytic.account') | ||
488 | 40 | except osv.except_osv,e: | ||
489 | 41 | self.fail(e.name + e.value) | ||
490 | 42 | except Exception,e: | ||
491 | 43 | self.fail(e) | ||
492 | 44 | |||
493 | 45 | def tearDown(self): | ||
494 | 46 | try: | ||
495 | 47 | self.pool=None | ||
496 | 48 | self.hr_anlalytic_timesheet =None | ||
497 | 49 | self.analytic_account = None | ||
498 | 50 | except osv.except_osv,e: | ||
499 | 51 | self.fail(e.name + e.value) | ||
500 | 52 | except Exception,e: | ||
501 | 53 | self.fail(e) | ||
502 | 54 | |||
503 | 55 | |||
504 | 56 | def test_1_create_hr_analytic_timesheet(self): | ||
505 | 57 | try: | ||
506 | 58 | global analytic_account_id | ||
507 | 59 | model_obj = self.pool.get('ir.model.data') | ||
508 | 60 | analytic_account = model_obj._get_id(self.cr,self.uid, 'account', 'analytic_magasin_bml_1') | ||
509 | 61 | analytic_account_id = model_obj.browse(self.cr, self.uid, analytic_account).res_id | ||
510 | 62 | hr_timesheet_invoicing = model_obj._get_id(self.cr,self.uid,'hr_timesheet_invoice', 'timesheet_invoice_factor1') | ||
511 | 63 | product_pricelist = model_obj._get_id(self.cr,self.uid,'product','pricelist_type_sale') | ||
512 | 64 | product_pricelist_id = model_obj.browse(self.cr,self.uid,product_pricelist).res_id | ||
513 | 65 | |||
514 | 66 | hr_timesheet_invoicing_id =model_obj.browse(self.cr, self.uid, hr_timesheet_invoicing).res_id | ||
515 | 67 | |||
516 | 68 | hr_analytic_timesheet = self.hr_anlalytic_timesheet.create(self.cr,self.uid,{ | ||
517 | 69 | 'name':'Testing module', | ||
518 | 70 | 'amount':50.00, | ||
519 | 71 | 'account_id':analytic_account_id, | ||
520 | 72 | 'unit_amount':5.00, | ||
521 | 73 | 'to_invoice':hr_timesheet_invoicing_id | ||
522 | 74 | } ) | ||
523 | 75 | self.analytic_account.write(self.cr,self.uid,[analytic_account_id],{ | ||
524 | 76 | 'pricelist_id':product_pricelist_id, | ||
525 | 77 | 'quantity_max':500 | ||
526 | 78 | }) | ||
527 | 79 | self.cr.commit() | ||
528 | 80 | except osv.except_osv,e: | ||
529 | 81 | self.fail(e.name + e.value) | ||
530 | 82 | except Exception,e: | ||
531 | 83 | self.fail(e) | ||
532 | 84 | |||
533 | 85 | def test_2_timesheet_invoice(self): | ||
534 | 86 | try: | ||
535 | 87 | self.failUnless(analytic_account_id,"analytic account not found ") | ||
536 | 88 | wizard_service = netsvc.ExportService.getService("wizard") | ||
537 | 89 | wizard_res = wizard_service.exp_create(self.cr.dbname,self.uid,'hr.timesheet.final.invoice.create') | ||
538 | 90 | datas = {'form': {'date': 1, 'price': 1, 'balance_product': 1, 'name': 1, 'time': 1}, 'ids': [analytic_account_id], 'id': analytic_account_id} | ||
539 | 91 | state = 'create' | ||
540 | 92 | res = wizard_service.exp_execute(self.cr.dbname,self.uid,wizard_res,datas,state,{}) | ||
541 | 93 | except osv.except_osv,e: | ||
542 | 94 | self.fail(e.name + e.value) | ||
543 | 95 | except Exception,e: | ||
544 | 96 | self.fail(e) | ||
545 | 97 | |||
546 | 98 | def test_3_unlink_invoice(self): | ||
547 | 99 | try: | ||
548 | 100 | self.failUnless(analytic_account_id,"analytic account not found ") | ||
549 | 101 | analytic_line_id = self.pool.get("account.analytic.line").search(self.cr,self.uid,[('account_id','=',analytic_account_id)]) | ||
550 | 102 | self.failUnless(analytic_line_id,"analytic account line not found !") | ||
551 | 103 | invoice_id = self.pool.get('account.analytic.line').browse(self.cr,self.uid,analytic_line_id)[0].invoice_id.id | ||
552 | 104 | |||
553 | 105 | self.failUnless(invoice_id,"invoice not created!") | ||
554 | 106 | self.pool.get('account.invoice').unlink(self.cr,self.uid,[invoice_id]) | ||
555 | 107 | |||
556 | 108 | self.pool.get("account.analytic.line").unlink(self.cr,self.uid,analytic_line_id) | ||
557 | 109 | self.analytic_account.write(self.cr,self.uid,[analytic_account_id],{ | ||
558 | 110 | 'pricelist_id':False, | ||
559 | 111 | 'quantity_max':False | ||
560 | 112 | }) | ||
561 | 113 | except osv.except_osv,e: | ||
562 | 114 | self.fail(e.name + e.value) | ||
563 | 115 | except Exception,e: | ||
564 | 116 | self.fail(e) | ||
565 | 117 | |||
566 | 118 | |||
567 | 119 | |||
568 | 120 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
569 | 121 | |||
570 | 122 | |||
571 | 123 | |||
572 | 0 | 124 | ||
573 | === added directory 'account_analytic_default/unit_test' | |||
574 | === added file 'account_analytic_default/unit_test/__init__.py' | |||
575 | --- account_analytic_default/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
576 | +++ account_analytic_default/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
577 | @@ -0,0 +1,22 @@ | |||
578 | 1 | # -*- coding: utf-8 -*- | ||
579 | 2 | ############################################################################## | ||
580 | 3 | # | ||
581 | 4 | # OpenERP, Open Source Management Solution | ||
582 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
583 | 6 | # | ||
584 | 7 | # This program is free software: you can redistribute it and/or modify | ||
585 | 8 | # it under the terms of the GNU Affero General Public License as | ||
586 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
587 | 10 | # License, or (at your option) any later version. | ||
588 | 11 | # | ||
589 | 12 | # This program is distributed in the hope that it will be useful, | ||
590 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
591 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
592 | 15 | # GNU Affero General Public License for more details. | ||
593 | 16 | # | ||
594 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
595 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
596 | 19 | # | ||
597 | 20 | ############################################################################## | ||
598 | 21 | |||
599 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
600 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
601 | 1 | 24 | ||
602 | === added file 'account_analytic_default/unit_test/test.py' | |||
603 | --- account_analytic_default/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
604 | +++ account_analytic_default/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
605 | @@ -0,0 +1,162 @@ | |||
606 | 1 | # -*- coding: utf-8 -*- | ||
607 | 2 | ############################################################################## | ||
608 | 3 | # | ||
609 | 4 | # OpenERP, Open Source Management Solution | ||
610 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
611 | 6 | # | ||
612 | 7 | # This program is free software: you can redistribute it and/or modify | ||
613 | 8 | # it under the terms of the GNU Affero General Public License as | ||
614 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
615 | 10 | # License, or (at your option) any later version. | ||
616 | 11 | # | ||
617 | 12 | # This program is distributed in the hope that it will be useful, | ||
618 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
619 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
620 | 15 | # GNU Affero General Public License for more details. | ||
621 | 16 | # | ||
622 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
623 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
624 | 19 | # | ||
625 | 20 | ############################################################################## | ||
626 | 21 | |||
627 | 22 | import unittest | ||
628 | 23 | import pooler | ||
629 | 24 | import netsvc | ||
630 | 25 | from osv import osv | ||
631 | 26 | import time | ||
632 | 27 | |||
633 | 28 | account_analytic_default_id = None | ||
634 | 29 | invoice_id = None | ||
635 | 30 | sales_journal_id = None | ||
636 | 31 | |||
637 | 32 | class account_analytic_default_test_case(unittest.TestCase): | ||
638 | 33 | |||
639 | 34 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
640 | 35 | self.cr = cursor | ||
641 | 36 | self.uid = user | ||
642 | 37 | unittest.TestCase.__init__(self, methodName) | ||
643 | 38 | |||
644 | 39 | def setUp(self): | ||
645 | 40 | try: | ||
646 | 41 | self.pool = pooler.get_pool(self.cr.dbname) | ||
647 | 42 | self.account_analytic_default = self.pool.get('account.analytic.default') | ||
648 | 43 | self.account_invoice = self.pool.get('account.invoice') | ||
649 | 44 | except osv.except_osv,e: | ||
650 | 45 | self.fail(e.name + e.value) | ||
651 | 46 | except Exception,e: | ||
652 | 47 | self.fail(e) | ||
653 | 48 | |||
654 | 49 | def tearDown(self): | ||
655 | 50 | try: | ||
656 | 51 | self.account_analytic_default = None | ||
657 | 52 | self.account_invoice = None | ||
658 | 53 | except osv.except_osv,e: | ||
659 | 54 | self.fail(e.name + e.value) | ||
660 | 55 | except Exception,e: | ||
661 | 56 | self.fail(e) | ||
662 | 57 | |||
663 | 58 | def test_1_Create(self): | ||
664 | 59 | try: | ||
665 | 60 | global account_analytic_default_id,invoice_id,sales_journal_id | ||
666 | 61 | model_obj = self.pool.get('ir.model.data') | ||
667 | 62 | # Product | ||
668 | 63 | product = model_obj._get_id(self.cr,self.uid, 'product', 'product_product_pc1') | ||
669 | 64 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
670 | 65 | product_uom = model_obj._get_id(self.cr, self.uid, 'product', 'product_uom_unit') | ||
671 | 66 | product_uom_id = model_obj.browse(self.cr, self.uid, product_uom).res_id | ||
672 | 67 | |||
673 | 68 | # Analytic Account | ||
674 | 69 | account = model_obj._get_id(self.cr,self.uid, 'account', 'analytic_project_1') | ||
675 | 70 | account_id = model_obj.browse(self.cr, self.uid, account).res_id | ||
676 | 71 | |||
677 | 72 | # Partner | ||
678 | 73 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_desertic_hispafuentes') | ||
679 | 74 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
680 | 75 | |||
681 | 76 | # Company | ||
682 | 77 | company = model_obj._get_id(self.cr,self.uid, 'base', 'main_company') | ||
683 | 78 | company_id = model_obj.browse(self.cr, self.uid, company,).res_id | ||
684 | 79 | |||
685 | 80 | # Partners address | ||
686 | 81 | partner_address = model_obj._get_id(self.cr, self.uid, 'base', 'res_partner_address_1') | ||
687 | 82 | partner_address_id = model_obj.browse(self.cr, self.uid, partner_address).res_id | ||
688 | 83 | |||
689 | 84 | # Account | ||
690 | 85 | receive_account = model_obj._get_id(self.cr,self.uid, 'account', 'a_recv') | ||
691 | 86 | receive_account_id = model_obj.browse(self.cr, self.uid, receive_account).res_id | ||
692 | 87 | pay_account = model_obj._get_id(self.cr,self.uid, 'account', 'a_pay') | ||
693 | 88 | pay_account_id = model_obj.browse(self.cr, self.uid, pay_account).res_id | ||
694 | 89 | |||
695 | 90 | # Analytic Journal | ||
696 | 91 | sales_journal = model_obj._get_id(self.cr, self.uid, 'account', 'sales_journal') | ||
697 | 92 | sales_journal_id = model_obj.browse(self.cr, self.uid, sales_journal).res_id | ||
698 | 93 | analytic_journal = model_obj._get_id(self.cr, self.uid, 'account', 'cose_journal_sale') | ||
699 | 94 | analytic_journal_id = model_obj.browse(self.cr, self.uid, analytic_journal).res_id | ||
700 | 95 | |||
701 | 96 | account_analytic_default_id = self.account_analytic_default.create(self.cr,self.uid, | ||
702 | 97 | {'sequence':1, | ||
703 | 98 | 'analytic_id':account_id, | ||
704 | 99 | 'product_id':product_id, | ||
705 | 100 | 'partner_id':partner_id, | ||
706 | 101 | 'user_id':self.uid, | ||
707 | 102 | 'company_id':company_id, | ||
708 | 103 | 'date_start':time.strftime('%Y-%m-%d'), | ||
709 | 104 | 'date_stop':time.strftime('%Y-%m-%d')}) | ||
710 | 105 | # Invoice | ||
711 | 106 | invoice_id = self.account_invoice.create(self.cr,self.uid, | ||
712 | 107 | {'name': 'Unit Test case Invoice', | ||
713 | 108 | 'type': 'out_invoice', | ||
714 | 109 | 'partner_id': partner_id, | ||
715 | 110 | 'address_invoice_id': partner_address_id, | ||
716 | 111 | 'address_contact_id': partner_address_id, | ||
717 | 112 | 'account_id':receive_account_id, | ||
718 | 113 | }) | ||
719 | 114 | |||
720 | 115 | result=self.pool.get('account.invoice.line').product_id_change(self.cr,self.uid, [], product_id, | ||
721 | 116 | product_uom_id, qty=2, name='Unit test case', type='out_invoice', | ||
722 | 117 | partner_id=partner_id, fposition=False, price_unit=False, | ||
723 | 118 | address_invoice_id=False, context={}) | ||
724 | 119 | |||
725 | 120 | # Invoice line | ||
726 | 121 | invoice_line_id = self.pool.get('account.invoice.line').create(self.cr,self.uid, | ||
727 | 122 | {'name' :'Unit Test Invoice Line', | ||
728 | 123 | 'invoice_id':invoice_id, | ||
729 | 124 | 'account_id':pay_account_id, | ||
730 | 125 | 'product_id':product_id, | ||
731 | 126 | 'price_unit':result['value']['price_unit'] , | ||
732 | 127 | 'quantity':4, | ||
733 | 128 | 'account_analytic_id':result['value']['account_analytic_id'], | ||
734 | 129 | }) | ||
735 | 130 | self.pool.get('account.journal').write(self.cr,self.uid,[sales_journal_id],{'analytic_journal_id':analytic_journal_id}) | ||
736 | 131 | except osv.except_osv,e: | ||
737 | 132 | self.fail(e.name + e.value) | ||
738 | 133 | except Exception,e: | ||
739 | 134 | self.fail(e) | ||
740 | 135 | |||
741 | 136 | def test_2_CreateInvoice(self): | ||
742 | 137 | try: | ||
743 | 138 | self.failUnless(invoice_id,"No Invoice Created !") | ||
744 | 139 | wf_service = netsvc.LocalService("workflow") | ||
745 | 140 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id, 'invoice_open', self.cr) | ||
746 | 141 | except osv.except_osv,e: | ||
747 | 142 | self.fail(e.name + e.value) | ||
748 | 143 | except Exception,e: | ||
749 | 144 | self.fail(e) | ||
750 | 145 | |||
751 | 146 | def test_3_Unlink(self): | ||
752 | 147 | try: | ||
753 | 148 | self.failUnless(account_analytic_default_id,"No account_analytic Created !") | ||
754 | 149 | self.account_analytic_default.unlink(self.cr,self.uid,[account_analytic_default_id]) | ||
755 | 150 | sale_journal = self.pool.get('account.journal').browse(self.cr,self.uid,sales_journal_id) | ||
756 | 151 | wf_service = netsvc.LocalService("workflow") | ||
757 | 152 | if not sale_journal.update_posted: | ||
758 | 153 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal.id],{'update_posted':True}) | ||
759 | 154 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id,'invoice_cancel', self.cr) | ||
760 | 155 | self.account_invoice.unlink(self.cr,self.uid,[invoice_id]) | ||
761 | 156 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal.id],{'analytic_journal_id':False,'update_posted':False}) | ||
762 | 157 | except osv.except_osv,e: | ||
763 | 158 | self.fail(e.name + e.value) | ||
764 | 159 | except Exception,e: | ||
765 | 160 | self.fail(e) | ||
766 | 161 | |||
767 | 162 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
768 | 0 | 163 | ||
769 | === added directory 'account_analytic_plans/unit_test' | |||
770 | === added file 'account_analytic_plans/unit_test/__init__.py' | |||
771 | --- account_analytic_plans/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
772 | +++ account_analytic_plans/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
773 | @@ -0,0 +1,22 @@ | |||
774 | 1 | # -*- coding: utf-8 -*- | ||
775 | 2 | ############################################################################## | ||
776 | 3 | # | ||
777 | 4 | # OpenERP, Open Source Management Solution | ||
778 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
779 | 6 | # | ||
780 | 7 | # This program is free software: you can redistribute it and/or modify | ||
781 | 8 | # it under the terms of the GNU Affero General Public License as | ||
782 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
783 | 10 | # License, or (at your option) any later version. | ||
784 | 11 | # | ||
785 | 12 | # This program is distributed in the hope that it will be useful, | ||
786 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
787 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
788 | 15 | # GNU Affero General Public License for more details. | ||
789 | 16 | # | ||
790 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
791 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
792 | 19 | # | ||
793 | 20 | ############################################################################## | ||
794 | 21 | |||
795 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
796 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
797 | 1 | 24 | ||
798 | === added file 'account_analytic_plans/unit_test/test.py' | |||
799 | --- account_analytic_plans/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
800 | +++ account_analytic_plans/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
801 | @@ -0,0 +1,178 @@ | |||
802 | 1 | # -*- coding: utf-8 -*- | ||
803 | 2 | ############################################################################## | ||
804 | 3 | # | ||
805 | 4 | # OpenERP, Open Source Management Solution | ||
806 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
807 | 6 | # | ||
808 | 7 | # This program is free software: you can redistribute it and/or modify | ||
809 | 8 | # it under the terms of the GNU Affero General Public License as | ||
810 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
811 | 10 | # License, or (at your option) any later version. | ||
812 | 11 | # | ||
813 | 12 | # This program is distributed in the hope that it will be useful, | ||
814 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
815 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
816 | 15 | # GNU Affero General Public License for more details. | ||
817 | 16 | # | ||
818 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
819 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
820 | 19 | # | ||
821 | 20 | ############################################################################## | ||
822 | 21 | |||
823 | 22 | import unittest | ||
824 | 23 | import pooler | ||
825 | 24 | import netsvc | ||
826 | 25 | from osv import osv | ||
827 | 26 | |||
828 | 27 | analytic_plan_instance_id = None | ||
829 | 28 | analytic_plan_id = None | ||
830 | 29 | invoice_id = None | ||
831 | 30 | |||
832 | 31 | class account_analytic_plans_test_case(unittest.TestCase): | ||
833 | 32 | |||
834 | 33 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
835 | 34 | self.cr = cursor | ||
836 | 35 | self.uid = user | ||
837 | 36 | unittest.TestCase.__init__(self, methodName) | ||
838 | 37 | |||
839 | 38 | def setUp(self): | ||
840 | 39 | try: | ||
841 | 40 | self.pool = pooler.get_pool(self.cr.dbname) | ||
842 | 41 | self.account_analytic_plan_instance = self.pool.get('account.analytic.plan.instance') | ||
843 | 42 | self.account_analytic_plan_instance_line = self.pool.get('account.analytic.plan.instance.line') | ||
844 | 43 | self.account_analytic_plan = self.pool.get('account.analytic.plan') | ||
845 | 44 | self.account_analytic_plan_line = self.pool.get('account.analytic.plan.line') | ||
846 | 45 | self.account_invoice = self.pool.get('account.invoice') | ||
847 | 46 | self.account_invoice_line=self.pool.get('account.invoice.line') | ||
848 | 47 | except osv.except_osv,e: | ||
849 | 48 | self.fail(e.name + e.value) | ||
850 | 49 | except Exception,e: | ||
851 | 50 | self.fail(e) | ||
852 | 51 | |||
853 | 52 | def tearDown(self): | ||
854 | 53 | try: | ||
855 | 54 | self.account_analytic_plan_instance = None | ||
856 | 55 | self.account_analytic_plan_instance_line = None | ||
857 | 56 | self.account_analytic_plan = None | ||
858 | 57 | self.account_analytic_plan_line = None | ||
859 | 58 | self.account_invoice = None | ||
860 | 59 | self.account_invoice_line = None | ||
861 | 60 | except osv.except_osv,e: | ||
862 | 61 | self.fail(e.name + e.value) | ||
863 | 62 | except Exception,e: | ||
864 | 63 | self.fail(e) | ||
865 | 64 | |||
866 | 65 | def test_1_Create(self): | ||
867 | 66 | try: | ||
868 | 67 | global invoice_id,sales_journal_id,analytic_plan_instance_id,analytic_plan_id | ||
869 | 68 | model_obj = self.pool.get('ir.model.data') | ||
870 | 69 | # Product | ||
871 | 70 | product = model_obj._get_id(self.cr,self.uid, 'product', 'product_product_pc1') | ||
872 | 71 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
873 | 72 | product_uom = model_obj._get_id(self.cr, self.uid, 'product', 'product_uom_unit') | ||
874 | 73 | product_uom_id = model_obj.browse(self.cr, self.uid, product_uom).res_id | ||
875 | 74 | |||
876 | 75 | # Analytic Account | ||
877 | 76 | account = model_obj._get_id(self.cr,self.uid, 'account', 'analytic_project_1') | ||
878 | 77 | account_id = model_obj.browse(self.cr, self.uid, account).res_id | ||
879 | 78 | account_2 = model_obj._get_id(self.cr,self.uid, 'account', 'analytic_project_2') | ||
880 | 79 | account_id_2 = model_obj.browse(self.cr, self.uid, account_2).res_id | ||
881 | 80 | # Partner | ||
882 | 81 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_desertic_hispafuentes') | ||
883 | 82 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
884 | 83 | |||
885 | 84 | # Partners address | ||
886 | 85 | partner_address = model_obj._get_id(self.cr, self.uid, 'base', 'res_partner_address_1') | ||
887 | 86 | partner_address_id = model_obj.browse(self.cr, self.uid, partner_address).res_id | ||
888 | 87 | |||
889 | 88 | # Account | ||
890 | 89 | receive_account = model_obj._get_id(self.cr,self.uid, 'account', 'a_recv') | ||
891 | 90 | receive_account_id = model_obj.browse(self.cr, self.uid, receive_account).res_id | ||
892 | 91 | |||
893 | 92 | pay_account = model_obj._get_id(self.cr,self.uid, 'account', 'a_pay') | ||
894 | 93 | pay_account_id = model_obj.browse(self.cr, self.uid, pay_account).res_id | ||
895 | 94 | |||
896 | 95 | # Analytic Journal | ||
897 | 96 | analytic_journal = model_obj._get_id(self.cr, self.uid, 'account', 'cose_journal_sale') | ||
898 | 97 | analytic_journal_id = model_obj.browse(self.cr, self.uid, analytic_journal).res_id | ||
899 | 98 | |||
900 | 99 | # Account Analytic Plan | ||
901 | 100 | analytic_plan_id = self.account_analytic_plan.create(self.cr,self.uid, | ||
902 | 101 | {'name':'Unit test analytic plan'}) | ||
903 | 102 | # Analytic plan Instance | ||
904 | 103 | analytic_plan_instance_id = self.account_analytic_plan_instance.create(self.cr,self.uid, | ||
905 | 104 | {'name':'Unit test Analytic Distribution', | ||
906 | 105 | 'code':'Unit test AD', | ||
907 | 106 | 'journal_id':analytic_journal_id, | ||
908 | 107 | 'plan_id':analytic_plan_id}) | ||
909 | 108 | |||
910 | 109 | # Account Analytic Plan Lines | ||
911 | 110 | for acc,rate in [(account_id,10.00),(account_id_2,50.00)]: | ||
912 | 111 | self.account_analytic_plan_line.create(self.cr,self.uid, | ||
913 | 112 | {'plan_id':analytic_plan_id, | ||
914 | 113 | 'name':'First', | ||
915 | 114 | 'sequence':0, | ||
916 | 115 | 'root_analytic_id':acc, | ||
917 | 116 | 'min_required':rate, | ||
918 | 117 | 'max_required':100.00}) | ||
919 | 118 | # Analytic plan Instance Line | ||
920 | 119 | self.account_analytic_plan_instance_line.create(self.cr,self.uid, | ||
921 | 120 | {'plan_id':analytic_plan_instance_id, | ||
922 | 121 | 'analytic_account_id':acc, | ||
923 | 122 | 'rate':rate}) | ||
924 | 123 | # Invoice | ||
925 | 124 | invoice_id = self.account_invoice.create(self.cr,self.uid, | ||
926 | 125 | {'name': 'Unit Test case Invoice', | ||
927 | 126 | 'type': 'out_invoice', | ||
928 | 127 | 'partner_id': partner_id, | ||
929 | 128 | 'address_invoice_id': partner_address_id, | ||
930 | 129 | 'address_contact_id': partner_address_id, | ||
931 | 130 | 'account_id':receive_account_id, | ||
932 | 131 | }) | ||
933 | 132 | |||
934 | 133 | # Invoice line | ||
935 | 134 | self.account_invoice_line.create(self.cr,self.uid, | ||
936 | 135 | {'name':'Unit Test Invoice Line', | ||
937 | 136 | 'invoice_id':invoice_id, | ||
938 | 137 | 'uos_id':product_uom_id, | ||
939 | 138 | 'product_id':product_id, | ||
940 | 139 | 'account_id':pay_account_id, | ||
941 | 140 | 'price_unit':400, | ||
942 | 141 | 'quantity':10, | ||
943 | 142 | 'analytics_id':analytic_plan_instance_id}) | ||
944 | 143 | |||
945 | 144 | except osv.except_osv,e: | ||
946 | 145 | self.fail(e.name + e.value) | ||
947 | 146 | except Exception,e: | ||
948 | 147 | self.fail(e) | ||
949 | 148 | |||
950 | 149 | def test_2_CreateInvoice(self): | ||
951 | 150 | try: | ||
952 | 151 | self.failUnless(invoice_id,"No Invoice Created !") | ||
953 | 152 | wf_service = netsvc.LocalService("workflow") | ||
954 | 153 | res = wf_service.trg_validate(self.uid, 'account.invoice',invoice_id, 'invoice_open', self.cr) | ||
955 | 154 | except osv.except_osv,e: | ||
956 | 155 | self.fail(e.name + e.value) | ||
957 | 156 | except Exception,e: | ||
958 | 157 | self.fail(e) | ||
959 | 158 | |||
960 | 159 | def test_3_Unlink(self): | ||
961 | 160 | try: | ||
962 | 161 | self.failUnless(invoice_id,"No Invoice Created !") | ||
963 | 162 | sale_journal = self.pool.get('account.journal').search(self.cr,self.uid,[('name','=','x Sales Journal')]) | ||
964 | 163 | self.failUnless(sale_journal,"No sale_journal Found !") | ||
965 | 164 | sale_journal_id = self.pool.get('account.journal').browse(self.cr,self.uid,sale_journal)[0] | ||
966 | 165 | wf_service = netsvc.LocalService("workflow") | ||
967 | 166 | if not sale_journal_id.update_posted: | ||
968 | 167 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal_id.id],{'update_posted':True}) | ||
969 | 168 | res = wf_service.trg_validate(self.uid, 'account.invoice',invoice_id,'invoice_cancel', self.cr) | ||
970 | 169 | self.account_invoice.unlink(self.cr,self.uid,[invoice_id]) | ||
971 | 170 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal_id.id],{'update_posted':False}) | ||
972 | 171 | self.account_analytic_plan_instance.unlink(self.cr,self.uid,[analytic_plan_instance_id]) | ||
973 | 172 | self.account_analytic_plan.unlink(self.cr,self.uid,[analytic_plan_id]) | ||
974 | 173 | except osv.except_osv,e: | ||
975 | 174 | self.fail(e.name + e.value) | ||
976 | 175 | except Exception,e: | ||
977 | 176 | self.fail(e) | ||
978 | 177 | |||
979 | 178 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
980 | 0 | 179 | ||
981 | === added directory 'account_balance' | |||
982 | === added directory 'account_balance/unit_test' | |||
983 | === added file 'account_balance/unit_test/__init__.py' | |||
984 | --- account_balance/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
985 | +++ account_balance/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
986 | @@ -0,0 +1,22 @@ | |||
987 | 1 | # -*- coding: utf-8 -*- | ||
988 | 2 | ############################################################################## | ||
989 | 3 | # | ||
990 | 4 | # OpenERP, Open Source Management Solution | ||
991 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
992 | 6 | # | ||
993 | 7 | # This program is free software: you can redistribute it and/or modify | ||
994 | 8 | # it under the terms of the GNU Affero General Public License as | ||
995 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
996 | 10 | # License, or (at your option) any later version. | ||
997 | 11 | # | ||
998 | 12 | # This program is distributed in the hope that it will be useful, | ||
999 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1000 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1001 | 15 | # GNU Affero General Public License for more details. | ||
1002 | 16 | # | ||
1003 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1004 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1005 | 19 | # | ||
1006 | 20 | ############################################################################## | ||
1007 | 21 | |||
1008 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1009 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
1010 | 1 | 24 | ||
1011 | === added file 'account_balance/unit_test/test.py' | |||
1012 | --- account_balance/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
1013 | +++ account_balance/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
1014 | @@ -0,0 +1,70 @@ | |||
1015 | 1 | # -*- coding: utf-8 -*- | ||
1016 | 2 | ############################################################################## | ||
1017 | 3 | # | ||
1018 | 4 | # OpenERP, Open Source Management Solution | ||
1019 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1020 | 6 | # | ||
1021 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1022 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1023 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1024 | 10 | # License, or (at your option) any later version. | ||
1025 | 11 | # | ||
1026 | 12 | # This program is distributed in the hope that it will be useful, | ||
1027 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1028 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1029 | 15 | # GNU Affero General Public License for more details. | ||
1030 | 16 | # | ||
1031 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1032 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1033 | 19 | # | ||
1034 | 20 | ############################################################################## | ||
1035 | 21 | |||
1036 | 22 | import unittest | ||
1037 | 23 | import pooler | ||
1038 | 24 | import netsvc | ||
1039 | 25 | from osv import osv | ||
1040 | 26 | |||
1041 | 27 | class account_balance_test_case(unittest.TestCase): | ||
1042 | 28 | |||
1043 | 29 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
1044 | 30 | self.cr = cursor | ||
1045 | 31 | self.uid = user | ||
1046 | 32 | unittest.TestCase.__init__(self, methodName) | ||
1047 | 33 | |||
1048 | 34 | def setUp(self): | ||
1049 | 35 | try: | ||
1050 | 36 | self.pool = pooler.get_pool(self.cr.dbname) | ||
1051 | 37 | except osv.except_osv,e: | ||
1052 | 38 | self.fail(e.name + e.value) | ||
1053 | 39 | except Exception,e: | ||
1054 | 40 | self.fail(e) | ||
1055 | 41 | |||
1056 | 42 | |||
1057 | 43 | def tearDown(self): | ||
1058 | 44 | try: | ||
1059 | 45 | self.pool = None | ||
1060 | 46 | except osv.except_osv,e: | ||
1061 | 47 | self.fail(e.name + e.value) | ||
1062 | 48 | except Exception,e: | ||
1063 | 49 | self.fail(e) | ||
1064 | 50 | |||
1065 | 51 | def test_1_wizard_test(self): | ||
1066 | 52 | try: | ||
1067 | 53 | model_obj = self.pool.get('ir.model.data') | ||
1068 | 54 | account = model_obj._get_id(self.cr, self.uid, 'account', 'a_recv') | ||
1069 | 55 | account_id = model_obj.browse(self.cr, self.uid, account).res_id | ||
1070 | 56 | sel_account=model_obj._get_id(self.cr, self.uid, 'account', 'a_pay') | ||
1071 | 57 | sel_account_id=model_obj.browse(self.cr, self.uid, sel_account).res_id | ||
1072 | 58 | fiscal_year_ids=self.pool.get('account.fiscalyear').search(self.cr,self.uid,[]) | ||
1073 | 59 | period_ids=self.pool.get('account.period').search(self.cr,self.uid,[]) | ||
1074 | 60 | wizard_service = netsvc.ExportService.getService("wizard") | ||
1075 | 61 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'account.balance.account.balance.report') | ||
1076 | 62 | datas = {'form': {'fiscalyear':[(6,0,fiscal_year_ids)],'select_account':sel_account_id,'account_choice':'all','show_columns':1,'landscape':1,'format_perc':1,'compare_pattern':'bal_cash','period_manner':'actual','periods':[(6,0,[x for x in period_ids ])]}, 'ids': [account_id], 'id':account_id} | ||
1077 | 63 | state = 'checkyear' | ||
1078 | 64 | res = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
1079 | 65 | except osv.except_osv,e: | ||
1080 | 66 | self.fail(e.name + e.value) | ||
1081 | 67 | except Exception,e: | ||
1082 | 68 | self.fail(e) | ||
1083 | 69 | |||
1084 | 70 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1085 | 0 | 71 | ||
1086 | === added directory 'account_budget/unit_test' | |||
1087 | === added file 'account_budget/unit_test/__init__.py' | |||
1088 | --- account_budget/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
1089 | +++ account_budget/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
1090 | @@ -0,0 +1,22 @@ | |||
1091 | 1 | # -*- coding: utf-8 -*- | ||
1092 | 2 | ############################################################################## | ||
1093 | 3 | # | ||
1094 | 4 | # OpenERP, Open Source Management Solution | ||
1095 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1096 | 6 | # | ||
1097 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1098 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1099 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1100 | 10 | # License, or (at your option) any later version. | ||
1101 | 11 | # | ||
1102 | 12 | # This program is distributed in the hope that it will be useful, | ||
1103 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1104 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1105 | 15 | # GNU Affero General Public License for more details. | ||
1106 | 16 | # | ||
1107 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1108 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1109 | 19 | # | ||
1110 | 20 | ############################################################################## | ||
1111 | 21 | |||
1112 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1113 | 0 | 23 | ||
1114 | === added file 'account_budget/unit_test/test.py' | |||
1115 | --- account_budget/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
1116 | +++ account_budget/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
1117 | @@ -0,0 +1,199 @@ | |||
1118 | 1 | # -*- coding: utf-8 -*- | ||
1119 | 2 | ############################################################################## | ||
1120 | 3 | # | ||
1121 | 4 | # OpenERP, Open Source Management Solution | ||
1122 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1123 | 6 | # | ||
1124 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1125 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1126 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1127 | 10 | # License, or (at your option) any later version. | ||
1128 | 11 | # | ||
1129 | 12 | # This program is distributed in the hope that it will be useful, | ||
1130 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1131 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1132 | 15 | # GNU Affero General Public License for more details. | ||
1133 | 16 | # | ||
1134 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1135 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1136 | 19 | # | ||
1137 | 20 | ############################################################################## | ||
1138 | 21 | |||
1139 | 22 | import unittest | ||
1140 | 23 | import pooler | ||
1141 | 24 | import netsvc | ||
1142 | 25 | import time | ||
1143 | 26 | from osv import osv | ||
1144 | 27 | |||
1145 | 28 | crossovered_budget_id = None | ||
1146 | 29 | budget_post_id = None | ||
1147 | 30 | analytic_account_id = None | ||
1148 | 31 | |||
1149 | 32 | class account_budget_test_case(unittest.TestCase): | ||
1150 | 33 | |||
1151 | 34 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
1152 | 35 | self.cr = cursor | ||
1153 | 36 | self.uid = user | ||
1154 | 37 | unittest.TestCase.__init__(self, methodName) | ||
1155 | 38 | |||
1156 | 39 | def setUp(self): | ||
1157 | 40 | try: | ||
1158 | 41 | self.pool = pooler.get_pool(self.cr.dbname) | ||
1159 | 42 | self.account_budget_post=self.pool.get('account.budget.post') | ||
1160 | 43 | self.crossovered_budget=self.pool.get('crossovered.budget') | ||
1161 | 44 | self.crossovered_budget_lines=self.pool.get('crossovered.budget.lines') | ||
1162 | 45 | except osv.except_osv,e: | ||
1163 | 46 | self.fail(e.name + e.value) | ||
1164 | 47 | except Exception,e: | ||
1165 | 48 | self.fail(e) | ||
1166 | 49 | |||
1167 | 50 | def tearDown(self): | ||
1168 | 51 | try: | ||
1169 | 52 | self.pool = None | ||
1170 | 53 | self.account_budget_post=None | ||
1171 | 54 | self.crossovered_budget=None | ||
1172 | 55 | self.crossovered_budget_lines=None | ||
1173 | 56 | except osv.except_osv,e: | ||
1174 | 57 | self.fail(e.name + e.value) | ||
1175 | 58 | except Exception,e: | ||
1176 | 59 | self.fail(e) | ||
1177 | 60 | |||
1178 | 61 | def test_1_Create(self): | ||
1179 | 62 | |||
1180 | 63 | try: | ||
1181 | 64 | global crossovered_budget_id,budget_post_id, analytic_account_id | ||
1182 | 65 | model_obj = self.pool.get('ir.model.data') | ||
1183 | 66 | analytic_account = model_obj._get_id(self.cr, self.uid, 'account', 'analytic_project_1') | ||
1184 | 67 | analytic_account_id = model_obj.browse(self.cr, self.uid,analytic_account).res_id | ||
1185 | 68 | account_ids=self.pool.get('account.account').search(self.cr,self.uid,[]) | ||
1186 | 69 | |||
1187 | 70 | budget_post_id = self.account_budget_post.create(self.cr,self.uid, | ||
1188 | 71 | {'name':'Receive', | ||
1189 | 72 | 'code':'REC', | ||
1190 | 73 | 'account_ids':[(6,0,account_ids)], | ||
1191 | 74 | }) | ||
1192 | 75 | crossovered_budget_id=self.crossovered_budget.create(self.cr,self.uid, | ||
1193 | 76 | {'name':'BUDGET:2009', | ||
1194 | 77 | 'code':'+2009', | ||
1195 | 78 | 'creating_user_id':self.uid, | ||
1196 | 79 | 'validating_user_id':self.uid, | ||
1197 | 80 | 'date_from':time.strftime('2009-04-01'), | ||
1198 | 81 | 'date_to':time.strftime('2010-04-01'), | ||
1199 | 82 | 'state':'draft'}) | ||
1200 | 83 | crossovered_budget_lines_id=self.crossovered_budget_lines.create(self.cr,self.uid, | ||
1201 | 84 | {'crossovered_budget_id':crossovered_budget_id, | ||
1202 | 85 | 'analytic_account_id':analytic_account_id, | ||
1203 | 86 | 'general_budget_id':budget_post_id, | ||
1204 | 87 | 'date_from':time.strftime('2009-04-01'), | ||
1205 | 88 | 'date_to':time.strftime('2010-04-01'), | ||
1206 | 89 | 'planned_amount':9000.00, | ||
1207 | 90 | }) | ||
1208 | 91 | except osv.except_osv,e: | ||
1209 | 92 | self.fail(e.name + e.value) | ||
1210 | 93 | except Exception,e: | ||
1211 | 94 | self.fail(e) | ||
1212 | 95 | |||
1213 | 96 | def test_2_ConfirmBudget(self): | ||
1214 | 97 | try: | ||
1215 | 98 | self.failUnless(crossovered_budget_id,"No Budget Created !") | ||
1216 | 99 | wf_service = netsvc.LocalService("workflow") | ||
1217 | 100 | res = wf_service.trg_validate(self.uid, 'crossovered.budget',crossovered_budget_id, 'confirm', self.cr) | ||
1218 | 101 | except osv.except_osv,e: | ||
1219 | 102 | self.fail(e.name + e.value) | ||
1220 | 103 | except Exception,e: | ||
1221 | 104 | self.fail(e) | ||
1222 | 105 | |||
1223 | 106 | def test_3_ValidateBudget(self): | ||
1224 | 107 | try: | ||
1225 | 108 | self.failUnless(crossovered_budget_id,"No Budget Created !") | ||
1226 | 109 | wf_service = netsvc.LocalService("workflow") | ||
1227 | 110 | res = wf_service.trg_validate(self.uid, 'crossovered.budget',crossovered_budget_id, 'validate', self.cr) | ||
1228 | 111 | except osv.except_osv,e: | ||
1229 | 112 | self.fail(e.name + e.value) | ||
1230 | 113 | except Exception,e: | ||
1231 | 114 | self.fail(e) | ||
1232 | 115 | |||
1233 | 116 | def test_4_DoneBudget(self): | ||
1234 | 117 | try: | ||
1235 | 118 | self.failUnless(crossovered_budget_id,"No Budget Created !") | ||
1236 | 119 | wf_service = netsvc.LocalService("workflow") | ||
1237 | 120 | res = wf_service.trg_validate(self.uid, 'crossovered.budget',crossovered_budget_id, 'done', self.cr) | ||
1238 | 121 | except osv.except_osv,e: | ||
1239 | 122 | self.fail(e.name + e.value) | ||
1240 | 123 | except Exception,e: | ||
1241 | 124 | self.fail(e) | ||
1242 | 125 | |||
1243 | 126 | def test_5_wizard_spread_test(self): | ||
1244 | 127 | try: | ||
1245 | 128 | self.cr.commit() | ||
1246 | 129 | model_obj = self.pool.get('ir.model.data') | ||
1247 | 130 | fiscal_year=self.pool.get('account.fiscalyear').search(self.cr,self.uid,[]) | ||
1248 | 131 | fiscal_id = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,fiscal_year)[0] | ||
1249 | 132 | wizard_service = netsvc.ExportService.getService("wizard") | ||
1250 | 133 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'account.budget.spread') | ||
1251 | 134 | datas = {'form': {'fiscalyear':fiscal_id.id,'amount':3600}, 'ids': [budget_post_id],'id':budget_post_id} | ||
1252 | 135 | state = 'spread' | ||
1253 | 136 | res = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
1254 | 137 | except osv.except_osv,e: | ||
1255 | 138 | self.fail(e.name + e.value) | ||
1256 | 139 | except Exception,e: | ||
1257 | 140 | self.fail(e) | ||
1258 | 141 | |||
1259 | 142 | def test_6_wizard_budget_report(self): | ||
1260 | 143 | try: | ||
1261 | 144 | self.cr.commit() | ||
1262 | 145 | model_obj = self.pool.get('ir.model.data') | ||
1263 | 146 | fiscal_year=self.pool.get('account.fiscalyear').search(self.cr,self.uid,[]) | ||
1264 | 147 | fiscal_id = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,fiscal_year)[0] | ||
1265 | 148 | wizard_service = netsvc.ExportService.getService("wizard") | ||
1266 | 149 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'account.budget.report') | ||
1267 | 150 | datas = {'form': {'date1':time.strftime('2009-04-01'),'date2':time.strftime('2009-31-01')}, | ||
1268 | 151 | 'ids': [budget_post_id],'id':budget_post_id} | ||
1269 | 152 | state = 'report' | ||
1270 | 153 | res = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
1271 | 154 | except osv.except_osv,e: | ||
1272 | 155 | self.fail(e.name + e.value) | ||
1273 | 156 | except Exception,e: | ||
1274 | 157 | self.fail(e) | ||
1275 | 158 | |||
1276 | 159 | def test_7_wizard_analytic_budget_report(self): | ||
1277 | 160 | try: | ||
1278 | 161 | self.cr.commit() | ||
1279 | 162 | model_obj = self.pool.get('ir.model.data') | ||
1280 | 163 | wizard_service = netsvc.ExportService.getService("wizard") | ||
1281 | 164 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'wizard.analytic.account.budget.report') | ||
1282 | 165 | datas = {'form': {'date_from':time.strftime('2009-04-01'),'date_to':time.strftime('2009-31-01'),},'ids': [analytic_account_id],'id':analytic_account_id} | ||
1283 | 166 | state = 'report' | ||
1284 | 167 | res = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
1285 | 168 | except osv.except_osv,e: | ||
1286 | 169 | self.fail(e.name + e.value) | ||
1287 | 170 | except Exception,e: | ||
1288 | 171 | self.fail(e) | ||
1289 | 172 | |||
1290 | 173 | def test_8_wizard_crossovered_budget_summary(self): | ||
1291 | 174 | try: | ||
1292 | 175 | self.cr.commit() | ||
1293 | 176 | model_obj = self.pool.get('ir.model.data') | ||
1294 | 177 | wizard_service = netsvc.ExportService.getService("wizard") | ||
1295 | 178 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'wizard.crossovered.budget.summary') | ||
1296 | 179 | datas = {'form': {'date_from':time.strftime('2009-04-01'),'date_to':time.strftime('2009-31-01'),}, 'ids': [crossovered_budget_id],'id':crossovered_budget_id} | ||
1297 | 180 | state = 'report' | ||
1298 | 181 | res = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
1299 | 182 | except osv.except_osv,e: | ||
1300 | 183 | self.fail(e.name + e.value) | ||
1301 | 184 | except Exception,e: | ||
1302 | 185 | self.fail(e) | ||
1303 | 186 | |||
1304 | 187 | def test_9_Unlink(self): | ||
1305 | 188 | try: | ||
1306 | 189 | self.failUnless(crossovered_budget_id,"No Budget Created !") | ||
1307 | 190 | self.failUnless(budget_post_id,"No Account Budget post Created !") | ||
1308 | 191 | self.crossovered_budget.unlink(self.cr, self.uid, [crossovered_budget_id]) | ||
1309 | 192 | self.account_budget_post.unlink(self.cr, self.uid, [budget_post_id ]) | ||
1310 | 193 | except osv.except_osv,e: | ||
1311 | 194 | self.fail(e.name + e.value) | ||
1312 | 195 | except Exception,e: | ||
1313 | 196 | self.fail(e) | ||
1314 | 197 | |||
1315 | 198 | |||
1316 | 199 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1317 | 0 | 200 | ||
1318 | === added directory 'account_date_check/unit_test' | |||
1319 | === added file 'account_date_check/unit_test/__init__.py' | |||
1320 | --- account_date_check/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
1321 | +++ account_date_check/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
1322 | @@ -0,0 +1,22 @@ | |||
1323 | 1 | # -*- coding: utf-8 -*- | ||
1324 | 2 | ############################################################################## | ||
1325 | 3 | # | ||
1326 | 4 | # OpenERP, Open Source Management Solution | ||
1327 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1328 | 6 | # | ||
1329 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1330 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1331 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1332 | 10 | # License, or (at your option) any later version. | ||
1333 | 11 | # | ||
1334 | 12 | # This program is distributed in the hope that it will be useful, | ||
1335 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1336 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1337 | 15 | # GNU Affero General Public License for more details. | ||
1338 | 16 | # | ||
1339 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1340 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1341 | 19 | # | ||
1342 | 20 | ############################################################################## | ||
1343 | 21 | |||
1344 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1345 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
1346 | 1 | 24 | ||
1347 | === added file 'account_date_check/unit_test/test.py' | |||
1348 | --- account_date_check/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
1349 | +++ account_date_check/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
1350 | @@ -0,0 +1,123 @@ | |||
1351 | 1 | # -*- coding: utf-8 -*- | ||
1352 | 2 | ############################################################################## | ||
1353 | 3 | # | ||
1354 | 4 | # OpenERP, Open Source Management Solution | ||
1355 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1356 | 6 | # | ||
1357 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1358 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1359 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1360 | 10 | # License, or (at your option) any later version. | ||
1361 | 11 | # | ||
1362 | 12 | # This program is distributed in the hope that it will be useful, | ||
1363 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1364 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1365 | 15 | # GNU Affero General Public License for more details. | ||
1366 | 16 | # | ||
1367 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1368 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1369 | 19 | # | ||
1370 | 20 | ############################################################################## | ||
1371 | 21 | |||
1372 | 22 | import unittest | ||
1373 | 23 | import pooler | ||
1374 | 24 | import netsvc | ||
1375 | 25 | from osv import osv | ||
1376 | 26 | import time | ||
1377 | 27 | |||
1378 | 28 | invoice_id = None | ||
1379 | 29 | sale_journal_id = None | ||
1380 | 30 | |||
1381 | 31 | class account_date_check_test_case(unittest.TestCase): | ||
1382 | 32 | |||
1383 | 33 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
1384 | 34 | self.cr = cursor | ||
1385 | 35 | self.uid = user | ||
1386 | 36 | unittest.TestCase.__init__(self, methodName) | ||
1387 | 37 | |||
1388 | 38 | def setUp(self): | ||
1389 | 39 | try: | ||
1390 | 40 | self.pool = pooler.get_pool(self.cr.dbname) | ||
1391 | 41 | self.account_invoice=self.pool.get('account.invoice') | ||
1392 | 42 | self.account_invoice_line=self.pool.get('account.invoice.line') | ||
1393 | 43 | self.account_journal=self.pool.get('account.journal') | ||
1394 | 44 | except osv.except_osv,e: | ||
1395 | 45 | self.fail(e.name + e.value) | ||
1396 | 46 | except Exception,e: | ||
1397 | 47 | self.fail(e) | ||
1398 | 48 | |||
1399 | 49 | def tearDown(self): | ||
1400 | 50 | try: | ||
1401 | 51 | self.pool = None | ||
1402 | 52 | self.account_invoice=None | ||
1403 | 53 | self.account_invoice_line=None | ||
1404 | 54 | self.account_journal=None | ||
1405 | 55 | except osv.except_osv,e: | ||
1406 | 56 | self.fail(e.name + e.value) | ||
1407 | 57 | except Exception,e: | ||
1408 | 58 | self.fail(e) | ||
1409 | 59 | |||
1410 | 60 | def test_1_Create(self): | ||
1411 | 61 | try: | ||
1412 | 62 | global invoice_id,sale_journal_id | ||
1413 | 63 | |||
1414 | 64 | model_obj = self.pool.get('ir.model.data') | ||
1415 | 65 | product = model_obj._get_id(self.cr,self.uid, 'product', 'product_product_pc2') | ||
1416 | 66 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
1417 | 67 | product_uom = model_obj._get_id(self.cr, self.uid, 'product', 'product_uom_unit') | ||
1418 | 68 | product_uom_id = model_obj.browse(self.cr, self.uid, product_uom).res_id | ||
1419 | 69 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
1420 | 70 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
1421 | 71 | partner_invoice = model_obj._get_id(self.cr, self.uid, 'base', 'res_partner_address_9') | ||
1422 | 72 | partner_invoice_id = model_obj.browse(self.cr, self.uid, partner_invoice).res_id | ||
1423 | 73 | sale_journal = self.pool.get('account.journal').search(self.cr,self.uid,[('name','=','x Sales Journal')]) | ||
1424 | 74 | sale_journal_id = self.pool.get('account.journal').browse(self.cr,self.uid,sale_journal)[0] | ||
1425 | 75 | account = model_obj._get_id(self.cr, self.uid, 'account', 'a_recv') | ||
1426 | 76 | account_id = model_obj.browse(self.cr, self.uid, account).res_id | ||
1427 | 77 | |||
1428 | 78 | invoice_id=self.account_invoice.create(self.cr,self.uid,{'name':'Unit Test case Invoice', | ||
1429 | 79 | 'type':'out_invoice', | ||
1430 | 80 | 'state':'draft', | ||
1431 | 81 | 'date_invoice':time.strftime('2008-11-01') , | ||
1432 | 82 | 'partner_id': partner_id, | ||
1433 | 83 | 'journal_id': sale_journal_id.id, | ||
1434 | 84 | 'address_invoice_id':partner_invoice_id, | ||
1435 | 85 | 'account_id':account_id, | ||
1436 | 86 | 'address_contact_id':partner_invoice_id }) | ||
1437 | 87 | invoice_line_id=self.account_invoice_line.create(self.cr,self.uid,{'name':'Unit Test Invoice Line', | ||
1438 | 88 | 'invoice_id':invoice_id, | ||
1439 | 89 | 'uos_id':product_uom_id, | ||
1440 | 90 | 'product_id':product_id, | ||
1441 | 91 | 'account_id':account_id, | ||
1442 | 92 | 'price_unit':400, | ||
1443 | 93 | 'quantity':10,}) | ||
1444 | 94 | except osv.except_osv,e: | ||
1445 | 95 | self.fail(e.name + e.value) | ||
1446 | 96 | except Exception,e: | ||
1447 | 97 | self.fail(e) | ||
1448 | 98 | |||
1449 | 99 | def test_2_CreateInvoice(self): | ||
1450 | 100 | try: | ||
1451 | 101 | self.failUnless(invoice_id,"No Invoice Created !") | ||
1452 | 102 | wf_service = netsvc.LocalService("workflow") | ||
1453 | 103 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id, 'invoice_open', self.cr) | ||
1454 | 104 | except osv.except_osv,e: | ||
1455 | 105 | self.fail(e.name + e.value) | ||
1456 | 106 | except Exception,e: | ||
1457 | 107 | self.fail(e) | ||
1458 | 108 | |||
1459 | 109 | def test_3_UnlinkInvoice(self): | ||
1460 | 110 | try: | ||
1461 | 111 | self.failUnless(invoice_id,"No Invoice Created !") | ||
1462 | 112 | wf_service = netsvc.LocalService("workflow") | ||
1463 | 113 | if not sale_journal_id.update_posted: | ||
1464 | 114 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal_id.id],{'update_posted':True}) | ||
1465 | 115 | res = wf_service.trg_validate(self.uid, 'account.invoice',invoice_id,'invoice_cancel', self.cr) | ||
1466 | 116 | self.account_invoice.unlink(self.cr,self.uid,[invoice_id]) | ||
1467 | 117 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal_id.id],{'update_posted':False}) | ||
1468 | 118 | except osv.except_osv,e: | ||
1469 | 119 | self.fail(e.name + e.value) | ||
1470 | 120 | except Exception,e: | ||
1471 | 121 | self.fail(e) | ||
1472 | 122 | |||
1473 | 123 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1474 | 0 | 124 | ||
1475 | === added directory 'account_followup/unit_test' | |||
1476 | === added file 'account_followup/unit_test/__init__.py' | |||
1477 | --- account_followup/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
1478 | +++ account_followup/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
1479 | @@ -0,0 +1,22 @@ | |||
1480 | 1 | # -*- coding: utf-8 -*- | ||
1481 | 2 | ############################################################################## | ||
1482 | 3 | # | ||
1483 | 4 | # OpenERP, Open Source Management Solution | ||
1484 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1485 | 6 | # | ||
1486 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1487 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1488 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1489 | 10 | # License, or (at your option) any later version. | ||
1490 | 11 | # | ||
1491 | 12 | # This program is distributed in the hope that it will be useful, | ||
1492 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1493 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1494 | 15 | # GNU Affero General Public License for more details. | ||
1495 | 16 | # | ||
1496 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1497 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1498 | 19 | # | ||
1499 | 20 | ############################################################################## | ||
1500 | 21 | |||
1501 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1502 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
1503 | 1 | 24 | ||
1504 | === added file 'account_followup/unit_test/test.py' | |||
1505 | --- account_followup/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
1506 | +++ account_followup/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
1507 | @@ -0,0 +1,171 @@ | |||
1508 | 1 | # -*- coding: utf-8 -*- | ||
1509 | 2 | ############################################################################## | ||
1510 | 3 | # | ||
1511 | 4 | # OpenERP, Open Source Management Solution | ||
1512 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1513 | 6 | # | ||
1514 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1515 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1516 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1517 | 10 | # License, or (at your option) any later version. | ||
1518 | 11 | # | ||
1519 | 12 | # This program is distributed in the hope that it will be useful, | ||
1520 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1521 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1522 | 15 | # GNU Affero General Public License for more details. | ||
1523 | 16 | # | ||
1524 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1525 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1526 | 19 | # | ||
1527 | 20 | ############################################################################## | ||
1528 | 21 | |||
1529 | 22 | import unittest | ||
1530 | 23 | import pooler | ||
1531 | 24 | import netsvc | ||
1532 | 25 | from osv import osv | ||
1533 | 26 | import time | ||
1534 | 27 | |||
1535 | 28 | followup_id = None | ||
1536 | 29 | invoice_id = None | ||
1537 | 30 | partner_id = None | ||
1538 | 31 | sale_journal_id = None | ||
1539 | 32 | |||
1540 | 33 | class account_followup_test_case(unittest.TestCase): | ||
1541 | 34 | |||
1542 | 35 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
1543 | 36 | self.cr = cursor | ||
1544 | 37 | self.uid = user | ||
1545 | 38 | unittest.TestCase.__init__(self, methodName) | ||
1546 | 39 | |||
1547 | 40 | def setUp(self): | ||
1548 | 41 | try: | ||
1549 | 42 | self.pool = pooler.get_pool(self.cr.dbname) | ||
1550 | 43 | self.account_invoice=self.pool.get('account.invoice') | ||
1551 | 44 | self.account_invoice_line=self.pool.get('account.invoice.line') | ||
1552 | 45 | self.account_followup_followup=self.pool.get('account_followup.followup') | ||
1553 | 46 | self.account_followup_followup_line=self.pool.get('account_followup.followup.line') | ||
1554 | 47 | except osv.except_osv,e: | ||
1555 | 48 | self.fail(e.name + e.value) | ||
1556 | 49 | except Exception,e: | ||
1557 | 50 | self.fail(e) | ||
1558 | 51 | |||
1559 | 52 | |||
1560 | 53 | def tearDown(self): | ||
1561 | 54 | try: | ||
1562 | 55 | self.pool = None | ||
1563 | 56 | self.account_invoice=None | ||
1564 | 57 | self.account_invoice_line=None | ||
1565 | 58 | self.account_followup_followup=None | ||
1566 | 59 | self.account_followup_followup_line=None | ||
1567 | 60 | except osv.except_osv,e: | ||
1568 | 61 | self.fail(e.name + e.value) | ||
1569 | 62 | except Exception,e: | ||
1570 | 63 | self.fail(e) | ||
1571 | 64 | |||
1572 | 65 | |||
1573 | 66 | |||
1574 | 67 | def test_1_Create(self): | ||
1575 | 68 | try: | ||
1576 | 69 | global invoice_id,followup_id,partner_id,sale_journal_id | ||
1577 | 70 | |||
1578 | 71 | model_obj = self.pool.get('ir.model.data') | ||
1579 | 72 | product = model_obj._get_id(self.cr,self.uid, 'product', 'product_product_pc2') | ||
1580 | 73 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
1581 | 74 | product_uom = model_obj._get_id(self.cr, self.uid, 'product', 'product_uom_unit') | ||
1582 | 75 | product_uom_id = model_obj.browse(self.cr, self.uid, product_uom).res_id | ||
1583 | 76 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
1584 | 77 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
1585 | 78 | partner_invoice = model_obj._get_id(self.cr, self.uid, 'base', 'res_partner_address_9') | ||
1586 | 79 | partner_invoice_id = model_obj.browse(self.cr, self.uid, partner_invoice).res_id | ||
1587 | 80 | company = self.pool.get('res.company').search(self.cr,self.uid,[]) | ||
1588 | 81 | company_id = self.pool.get('res.company').browse(self.cr,self.uid,company)[0] | ||
1589 | 82 | sale_journal = self.pool.get('account.journal').search(self.cr,self.uid,[('name','=','x Sales Journal')]) | ||
1590 | 83 | sale_journal_id = self.pool.get('account.journal').browse(self.cr,self.uid,sale_journal)[0] | ||
1591 | 84 | account = model_obj._get_id(self.cr, self.uid, 'account', 'a_recv') | ||
1592 | 85 | account_id = model_obj.browse(self.cr, self.uid, account).res_id | ||
1593 | 86 | |||
1594 | 87 | invoice_id = self.account_invoice.create(self.cr,self.uid, | ||
1595 | 88 | {'name':'Unit Test case Invoice', | ||
1596 | 89 | 'type':'out_invoice', | ||
1597 | 90 | 'state':'draft', | ||
1598 | 91 | 'partner_id': partner_id, | ||
1599 | 92 | 'journal_id': sale_journal_id.id, | ||
1600 | 93 | 'address_invoice_id':partner_invoice_id, | ||
1601 | 94 | 'account_id':account_id, | ||
1602 | 95 | 'address_contact_id':partner_invoice_id }) | ||
1603 | 96 | |||
1604 | 97 | self.account_invoice_line.create(self.cr,self.uid, | ||
1605 | 98 | {'name':'Unit Test Invoice Line', | ||
1606 | 99 | 'invoice_id':invoice_id, | ||
1607 | 100 | 'uos_id':product_uom_id, | ||
1608 | 101 | 'product_id':product_id, | ||
1609 | 102 | 'account_id':account_id, | ||
1610 | 103 | 'price_unit':400, | ||
1611 | 104 | 'quantity':10,}) | ||
1612 | 105 | |||
1613 | 106 | followup_id = self.account_followup_followup.create(self.cr,self.uid, | ||
1614 | 107 | {'name':'Follow-up 1', | ||
1615 | 108 | 'description':'This is Unit test followup', | ||
1616 | 109 | 'company_id':company_id.id,}) | ||
1617 | 110 | for i in range(0,2): | ||
1618 | 111 | self.account_followup_followup_line.create(self.cr,self.uid, | ||
1619 | 112 | {'name':'Level : follow-up-line %s'%(i+1), | ||
1620 | 113 | 'delay':15 * i+1, | ||
1621 | 114 | 'start':'days', | ||
1622 | 115 | 'followup_id':followup_id, | ||
1623 | 116 | 'description':'description %s'%(i+1), | ||
1624 | 117 | 'sequence':i}) | ||
1625 | 118 | except osv.except_osv,e: | ||
1626 | 119 | self.fail(e.name + e.value) | ||
1627 | 120 | except Exception,e: | ||
1628 | 121 | self.fail(e) | ||
1629 | 122 | |||
1630 | 123 | def test_2_CreateInvoice(self): | ||
1631 | 124 | try: | ||
1632 | 125 | self.failUnless(invoice_id,"No Invoice Created !") | ||
1633 | 126 | wf_service = netsvc.LocalService("workflow") | ||
1634 | 127 | res = wf_service.trg_validate(self.uid, 'account.invoice',invoice_id, 'invoice_open', self.cr) | ||
1635 | 128 | except osv.except_osv,e: | ||
1636 | 129 | self.fail(e.name + e.value) | ||
1637 | 130 | except Exception,e: | ||
1638 | 131 | self.fail(e) | ||
1639 | 132 | |||
1640 | 133 | def test_3_SendFollowups(self): | ||
1641 | 134 | try: | ||
1642 | 135 | self.cr.commit() | ||
1643 | 136 | self.failUnless(invoice_id,"No Invoice Created !") | ||
1644 | 137 | wizard_service = netsvc.ExportService.getService("wizard") | ||
1645 | 138 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'account_followup.followup.print.all') | ||
1646 | 139 | datas = {'form': {}, 'ids': [followup_id],'id': followup_id} | ||
1647 | 140 | state = 'init' | ||
1648 | 141 | while state != 'end': | ||
1649 | 142 | res = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
1650 | 143 | if 'datas' in res: | ||
1651 | 144 | datas['form'].update(res['datas']) | ||
1652 | 145 | if res['type']=='form': | ||
1653 | 146 | for field in res['fields'].keys(): | ||
1654 | 147 | datas['form'][field] = datas['form'].get(field,False) | ||
1655 | 148 | state = res['state'][-1][0] | ||
1656 | 149 | elif res['type'] in ('state','print'): | ||
1657 | 150 | state = res['state'] | ||
1658 | 151 | except osv.except_osv,e: | ||
1659 | 152 | self.fail(e.name + e.value) | ||
1660 | 153 | except Exception,e: | ||
1661 | 154 | self.fail(e) | ||
1662 | 155 | |||
1663 | 156 | def test_4_Unlink(self): | ||
1664 | 157 | try: | ||
1665 | 158 | self.failUnless(followup_id,"No followup Created !") | ||
1666 | 159 | self.account_followup_followup.unlink(self.cr,self.uid,[followup_id]) | ||
1667 | 160 | wf_service = netsvc.LocalService("workflow") | ||
1668 | 161 | if not sale_journal_id.update_posted: | ||
1669 | 162 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal_id.id],{'update_posted':True}) | ||
1670 | 163 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id,'invoice_cancel', self.cr) | ||
1671 | 164 | self.account_invoice.unlink(self.cr,self.uid,[invoice_id]) | ||
1672 | 165 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal_id.id],{'update_posted':False}) | ||
1673 | 166 | except osv.except_osv,e: | ||
1674 | 167 | self.fail(e.name + e.value) | ||
1675 | 168 | except Exception,e: | ||
1676 | 169 | self.fail(e) | ||
1677 | 170 | |||
1678 | 171 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1679 | 0 | 172 | ||
1680 | === added directory 'account_invoice_layout/unit_test' | |||
1681 | === added file 'account_invoice_layout/unit_test/__init__.py' | |||
1682 | --- account_invoice_layout/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
1683 | +++ account_invoice_layout/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
1684 | @@ -0,0 +1,22 @@ | |||
1685 | 1 | # -*- coding: utf-8 -*- | ||
1686 | 2 | ############################################################################## | ||
1687 | 3 | # | ||
1688 | 4 | # OpenERP, Open Source Management Solution | ||
1689 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1690 | 6 | # | ||
1691 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1692 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1693 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1694 | 10 | # License, or (at your option) any later version. | ||
1695 | 11 | # | ||
1696 | 12 | # This program is distributed in the hope that it will be useful, | ||
1697 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1698 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1699 | 15 | # GNU Affero General Public License for more details. | ||
1700 | 16 | # | ||
1701 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1702 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1703 | 19 | # | ||
1704 | 20 | ############################################################################## | ||
1705 | 21 | |||
1706 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1707 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
1708 | 1 | 24 | ||
1709 | === added file 'account_invoice_layout/unit_test/test.py' | |||
1710 | --- account_invoice_layout/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
1711 | +++ account_invoice_layout/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
1712 | @@ -0,0 +1,153 @@ | |||
1713 | 1 | # -*- coding: utf-8 -*- | ||
1714 | 2 | ############################################################################## | ||
1715 | 3 | # | ||
1716 | 4 | # OpenERP, Open Source Management Solution | ||
1717 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1718 | 6 | # | ||
1719 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1720 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1721 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1722 | 10 | # License, or (at your option) any later version. | ||
1723 | 11 | # | ||
1724 | 12 | # This program is distributed in the hope that it will be useful, | ||
1725 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1726 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1727 | 15 | # GNU Affero General Public License for more details. | ||
1728 | 16 | # | ||
1729 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1730 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1731 | 19 | # | ||
1732 | 20 | ############################################################################## | ||
1733 | 21 | |||
1734 | 22 | import unittest | ||
1735 | 23 | import pooler | ||
1736 | 24 | import netsvc | ||
1737 | 25 | from osv import osv | ||
1738 | 26 | |||
1739 | 27 | message_id = None | ||
1740 | 28 | invoice_id = None | ||
1741 | 29 | journal_id = None | ||
1742 | 30 | |||
1743 | 31 | class account_invoice_layout_test_case(unittest.TestCase): | ||
1744 | 32 | |||
1745 | 33 | |||
1746 | 34 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
1747 | 35 | self.cr = cursor | ||
1748 | 36 | self.uid = user | ||
1749 | 37 | unittest.TestCase.__init__(self, methodName) | ||
1750 | 38 | |||
1751 | 39 | def setUp(self): | ||
1752 | 40 | try: | ||
1753 | 41 | self.pool = pooler.get_pool(self.cr.dbname) | ||
1754 | 42 | self.notify_message=self.pool.get('notify.message') | ||
1755 | 43 | self.account_invoice=self.pool.get('account.invoice') | ||
1756 | 44 | self.account_invoice_line=self.pool.get('account.invoice.line') | ||
1757 | 45 | self.account_journal=self.pool.get('account.journal') | ||
1758 | 46 | except osv.except_osv,e: | ||
1759 | 47 | self.fail(e.name + e.value) | ||
1760 | 48 | except Exception,e: | ||
1761 | 49 | self.fail(e) | ||
1762 | 50 | |||
1763 | 51 | |||
1764 | 52 | def tearDown(self): | ||
1765 | 53 | try: | ||
1766 | 54 | self.pool = None | ||
1767 | 55 | self.notify_message=None | ||
1768 | 56 | self.account_invoice=None | ||
1769 | 57 | self.account_invoice_line=None | ||
1770 | 58 | self.account_journal=None | ||
1771 | 59 | except osv.except_osv,e: | ||
1772 | 60 | self.fail(e.name + e.value) | ||
1773 | 61 | except Exception,e: | ||
1774 | 62 | self.fail(e) | ||
1775 | 63 | |||
1776 | 64 | def test_1_Create(self): | ||
1777 | 65 | try: | ||
1778 | 66 | global message_id,invoice_id,journal_id | ||
1779 | 67 | model_obj = self.pool.get('ir.model.data') | ||
1780 | 68 | product = model_obj._get_id(self.cr,self.uid, 'product', 'product_product_pc2') | ||
1781 | 69 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
1782 | 70 | product_uom = model_obj._get_id(self.cr, self.uid, 'product', 'product_uom_unit') | ||
1783 | 71 | product_uom_id = model_obj.browse(self.cr, self.uid, product_uom).res_id | ||
1784 | 72 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
1785 | 73 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
1786 | 74 | partner_invoice = model_obj._get_id(self.cr, self.uid, 'base', 'res_partner_address_9') | ||
1787 | 75 | partner_invoice_id = model_obj.browse(self.cr, self.uid, partner_invoice).res_id | ||
1788 | 76 | journal = model_obj._get_id(self.cr,self.uid, 'account', 'sales_journal') | ||
1789 | 77 | journal_id = model_obj.browse(self.cr, self.uid, journal).res_id | ||
1790 | 78 | account = model_obj._get_id(self.cr, self.uid, 'account', 'a_recv') | ||
1791 | 79 | account_id = model_obj.browse(self.cr, self.uid, account).res_id | ||
1792 | 80 | |||
1793 | 81 | invoice_id=self.account_invoice.create(self.cr,self.uid,{'name':'Unit Test case Invoice', | ||
1794 | 82 | 'type':'out_invoice', | ||
1795 | 83 | 'state':'draft', | ||
1796 | 84 | 'partner_id': partner_id, | ||
1797 | 85 | 'journal_id': journal_id, | ||
1798 | 86 | 'address_invoice_id':partner_invoice_id, | ||
1799 | 87 | 'account_id':account_id, | ||
1800 | 88 | 'address_contact_id':partner_invoice_id }) | ||
1801 | 89 | |||
1802 | 90 | |||
1803 | 91 | invoice_line_id=self.account_invoice_line.create(self.cr,self.uid,{'name':'Unit Test Invoice Line', | ||
1804 | 92 | 'invoice_id':invoice_id, | ||
1805 | 93 | 'uos_id':product_uom_id, | ||
1806 | 94 | 'product_id':product_id, | ||
1807 | 95 | 'account_id':account_id, | ||
1808 | 96 | 'price_unit':400, | ||
1809 | 97 | 'quantity':10,}) | ||
1810 | 98 | message_id= self.notify_message.create(self.cr,self.uid,{'name':'NEW MESSAGE','msg':'THIS IS A NEW MESSAGE'}) | ||
1811 | 99 | except osv.except_osv,e: | ||
1812 | 100 | self.fail(e.name + e.value) | ||
1813 | 101 | except Exception,e: | ||
1814 | 102 | self.fail(e) | ||
1815 | 103 | |||
1816 | 104 | def test_2_CreateInvoice(self): | ||
1817 | 105 | try: | ||
1818 | 106 | self.failUnless(invoice_id,"No Invoice Created !") | ||
1819 | 107 | wf_service = netsvc.LocalService("workflow") | ||
1820 | 108 | res = wf_service.trg_validate(self.uid, 'account.invoice',invoice_id, 'invoice_open', self.cr) | ||
1821 | 109 | except osv.except_osv,e: | ||
1822 | 110 | self.fail(e.name + e.value) | ||
1823 | 111 | except Exception,e: | ||
1824 | 112 | self.fail(e) | ||
1825 | 113 | |||
1826 | 114 | def test_3_wizard_test(self): | ||
1827 | 115 | try: | ||
1828 | 116 | self.failUnless(message_id,"No Message Created !") | ||
1829 | 117 | wizard_service = netsvc.ExportService.getService("wizard") | ||
1830 | 118 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'wizard.notify_message') | ||
1831 | 119 | datas = {'form': {'message':message_id}, 'ids': [invoice_id], 'id':invoice_id} | ||
1832 | 120 | state = 'print' | ||
1833 | 121 | res = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
1834 | 122 | except osv.except_osv,e: | ||
1835 | 123 | self.fail(e.name + e.value) | ||
1836 | 124 | except Exception,e: | ||
1837 | 125 | self.fail(e) | ||
1838 | 126 | |||
1839 | 127 | def test_4_layout_report(self): | ||
1840 | 128 | try: | ||
1841 | 129 | self.failUnless(message_id,"No Message Created !") | ||
1842 | 130 | report_service = netsvc.ExportService.getService('report') | ||
1843 | 131 | report_service.exp_report(self.cr.dbname, self.uid, 'account.invoice', [invoice_id]) | ||
1844 | 132 | except osv.except_osv,e: | ||
1845 | 133 | self.fail(e.name + e.value) | ||
1846 | 134 | except Exception,e: | ||
1847 | 135 | self.fail(e) | ||
1848 | 136 | |||
1849 | 137 | def test_5_Unlink_layout(self): | ||
1850 | 138 | try: | ||
1851 | 139 | self.failUnless(message_id,"No Message Created !") | ||
1852 | 140 | self.failUnless(journal_id,"No Journal Created !") | ||
1853 | 141 | self.notify_message.unlink(self.cr, self.uid, [message_id]) | ||
1854 | 142 | sale_journal = self.pool.get('account.journal').browse(self.cr,self.uid,journal_id) | ||
1855 | 143 | wf_service = netsvc.LocalService("workflow") | ||
1856 | 144 | if not sale_journal.update_posted: | ||
1857 | 145 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal.id],{'update_posted':True}) | ||
1858 | 146 | res = wf_service.trg_validate(self.uid, 'account.invoice',invoice_id,'invoice_cancel', self.cr) | ||
1859 | 147 | self.account_invoice.unlink(self.cr,self.uid,[invoice_id]) | ||
1860 | 148 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal.id],{'update_posted':False}) | ||
1861 | 149 | except osv.except_osv,e: | ||
1862 | 150 | self.fail(e.name + e.value) | ||
1863 | 151 | except Exception,e: | ||
1864 | 152 | self.fail(e) | ||
1865 | 153 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1866 | 0 | 154 | ||
1867 | === added directory 'account_payment/unit_test' | |||
1868 | === added file 'account_payment/unit_test/__init__.py' | |||
1869 | --- account_payment/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
1870 | +++ account_payment/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
1871 | @@ -0,0 +1,22 @@ | |||
1872 | 1 | # -*- coding: utf-8 -*- | ||
1873 | 2 | ############################################################################## | ||
1874 | 3 | # | ||
1875 | 4 | # OpenERP, Open Source Management Solution | ||
1876 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1877 | 6 | # | ||
1878 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1879 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1880 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1881 | 10 | # License, or (at your option) any later version. | ||
1882 | 11 | # | ||
1883 | 12 | # This program is distributed in the hope that it will be useful, | ||
1884 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1885 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1886 | 15 | # GNU Affero General Public License for more details. | ||
1887 | 16 | # | ||
1888 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1889 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1890 | 19 | # | ||
1891 | 20 | ############################################################################## | ||
1892 | 21 | |||
1893 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1894 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
1895 | 1 | 24 | ||
1896 | === added file 'account_payment/unit_test/test.py' | |||
1897 | --- account_payment/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
1898 | +++ account_payment/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
1899 | @@ -0,0 +1,227 @@ | |||
1900 | 1 | # -*- coding: utf-8 -*- | ||
1901 | 2 | ############################################################################## | ||
1902 | 3 | # | ||
1903 | 4 | # OpenERP, Open Source Management Solution | ||
1904 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
1905 | 6 | # | ||
1906 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1907 | 8 | # it under the terms of the GNU Affero General Public License as | ||
1908 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
1909 | 10 | # License, or (at your option) any later version. | ||
1910 | 11 | # | ||
1911 | 12 | # This program is distributed in the hope that it will be useful, | ||
1912 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1913 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1914 | 15 | # GNU Affero General Public License for more details. | ||
1915 | 16 | # | ||
1916 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
1917 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1918 | 19 | # | ||
1919 | 20 | ############################################################################## | ||
1920 | 21 | import unittest | ||
1921 | 22 | import pooler | ||
1922 | 23 | import netsvc | ||
1923 | 24 | from osv import osv | ||
1924 | 25 | import time | ||
1925 | 26 | |||
1926 | 27 | bank_id = None | ||
1927 | 28 | bank_type_id = None | ||
1928 | 29 | payment_type_id = None | ||
1929 | 30 | payment_mode_id = None | ||
1930 | 31 | partner_bank_id = None | ||
1931 | 32 | invoice_id = None | ||
1932 | 33 | invoice_line_id = None | ||
1933 | 34 | payment_order_id = None | ||
1934 | 35 | |||
1935 | 36 | class account_payment_test_case(unittest.TestCase): | ||
1936 | 37 | |||
1937 | 38 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
1938 | 39 | self.cr = cursor | ||
1939 | 40 | self.uid = user | ||
1940 | 41 | unittest.TestCase.__init__(self, methodName) | ||
1941 | 42 | |||
1942 | 43 | def setUp(self): | ||
1943 | 44 | try: | ||
1944 | 45 | self.pool = pooler.get_pool(self.cr.dbname) | ||
1945 | 46 | self.payment_type = self.pool.get('payment.type') | ||
1946 | 47 | self.payment_order = self.pool.get('payment.order') | ||
1947 | 48 | self.res_partner_bank_type_fields = self.pool.get('res.partner.bank.type.field') | ||
1948 | 49 | self.res_partner_bank_type = self.pool.get('res.partner.bank.type') | ||
1949 | 50 | self.payment_mode = self.pool.get('payment.mode') | ||
1950 | 51 | self.res_partner_bank = self.pool.get('res.partner.bank') | ||
1951 | 52 | self.res_bank = self.pool.get('res.bank') | ||
1952 | 53 | self.account_invoice = self.pool.get('account.invoice') | ||
1953 | 54 | self.account_invoice_line = self.pool.get('account.invoice.line') | ||
1954 | 55 | except osv.except_osv,e: | ||
1955 | 56 | self.fail(e.name + e.value) | ||
1956 | 57 | except Exception,e: | ||
1957 | 58 | self.fail(e) | ||
1958 | 59 | |||
1959 | 60 | def tearDown(self): | ||
1960 | 61 | try: | ||
1961 | 62 | self.payment_type = None | ||
1962 | 63 | self.res_partner_bank_type_fields = None | ||
1963 | 64 | self.res_partner_bank_type = None | ||
1964 | 65 | self.payment_mode = None | ||
1965 | 66 | self.res_partner_bank = None | ||
1966 | 67 | self.res_bank = None | ||
1967 | 68 | self.account_invoice = None | ||
1968 | 69 | self.account_invoice_line = None | ||
1969 | 70 | except osv.except_osv,e: | ||
1970 | 71 | self.fail(e.name + e.value) | ||
1971 | 72 | except Exception,e: | ||
1972 | 73 | self.fail(e) | ||
1973 | 74 | |||
1974 | 75 | def test_1_create(self): | ||
1975 | 76 | try: | ||
1976 | 77 | global bank_type_id,payment_type_id,payment_mode_id,bank_id,invoice_id,invoice_line_id,payment_order_id,res | ||
1977 | 78 | |||
1978 | 79 | model_obj = self.pool.get('ir.model.data') | ||
1979 | 80 | journal = model_obj._get_id(self.cr, self.uid, 'account', 'bank_journal') | ||
1980 | 81 | journal_id = model_obj.browse(self.cr, self.uid,journal).res_id | ||
1981 | 82 | |||
1982 | 83 | # Partner | ||
1983 | 84 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
1984 | 85 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
1985 | 86 | |||
1986 | 87 | # Partners address | ||
1987 | 88 | partner_address = model_obj._get_id(self.cr, self.uid, 'base', 'res_partner_address_1') | ||
1988 | 89 | partner_address_id = model_obj.browse(self.cr, self.uid, partner_address).res_id | ||
1989 | 90 | |||
1990 | 91 | # Account | ||
1991 | 92 | receive_account = model_obj._get_id(self.cr,self.uid, 'account', 'a_recv') | ||
1992 | 93 | receive_account_id = model_obj.browse(self.cr, self.uid, receive_account).res_id | ||
1993 | 94 | account = model_obj._get_id(self.cr,self.uid, 'account', 'a_pay') | ||
1994 | 95 | account_id = model_obj.browse(self.cr, self.uid, account).res_id | ||
1995 | 96 | # Product | ||
1996 | 97 | product = model_obj._get_id(self.cr,self.uid, 'product', 'product_product_pc1') | ||
1997 | 98 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
1998 | 99 | |||
1999 | 100 | # Bank | ||
2000 | 101 | bank_id = self.res_bank.create(self.cr,self.uid,{'name':'IDBI Bank'}) | ||
2001 | 102 | bank_type_id = self.res_partner_bank_type.create(self.cr,self.uid,{'name':'Industrial Bank','code':'industry'}) | ||
2002 | 103 | |||
2003 | 104 | partner_bank_id = self.res_partner_bank.create(self.cr,self.uid,{'name':'HSBC Bank','acc_number':'78453621254', | ||
2004 | 105 | 'state':'industry','partner_id':partner_id, | ||
2005 | 106 | 'bank':bank_id}) | ||
2006 | 107 | # Payment Type | ||
2007 | 108 | payment_type_id = self.payment_type.create(self.cr,self.uid,{'name':'My payment mode', | ||
2008 | 109 | 'code':'mypayment', | ||
2009 | 110 | 'suitable_bank_types':[(6,0,[bank_type_id])]}) | ||
2010 | 111 | # Payment Mode | ||
2011 | 112 | payment_mode_id = self.payment_mode.create(self.cr,self.uid,{'name':'My Payment Mode','bank_id':partner_bank_id, | ||
2012 | 113 | 'journal':journal_id,'type':payment_type_id}) | ||
2013 | 114 | # Invoice | ||
2014 | 115 | invoice_id = self.account_invoice.create(self.cr,self.uid, | ||
2015 | 116 | {'name': 'Unit Test case Invoice', | ||
2016 | 117 | 'type': 'out_invoice', | ||
2017 | 118 | 'partner_id': partner_id, | ||
2018 | 119 | 'address_invoice_id': partner_address_id, | ||
2019 | 120 | 'address_contact_id': partner_address_id, | ||
2020 | 121 | 'account_id':receive_account_id, | ||
2021 | 122 | }) | ||
2022 | 123 | # Invoice line | ||
2023 | 124 | invoice_line_id = self.account_invoice_line.create(self.cr,self.uid, | ||
2024 | 125 | {'name' :'Unit Test Invoice Line', | ||
2025 | 126 | 'invoice_id':invoice_id, | ||
2026 | 127 | 'account_id':account_id, | ||
2027 | 128 | 'product_id':product_id, | ||
2028 | 129 | 'price_unit':500 , | ||
2029 | 130 | 'quantity':5 | ||
2030 | 131 | }) | ||
2031 | 132 | except osv.except_osv,e: | ||
2032 | 133 | self.fail(e.name + e.value) | ||
2033 | 134 | except Exception,e: | ||
2034 | 135 | self.fail(e) | ||
2035 | 136 | |||
2036 | 137 | def test_2_InvoiceCreate(self): | ||
2037 | 138 | try: | ||
2038 | 139 | self.failUnless(invoice_id,"No Invoice Created !") | ||
2039 | 140 | wf_service = netsvc.LocalService("workflow") | ||
2040 | 141 | res = wf_service.trg_validate(self.uid, 'account.invoice',invoice_id,'invoice_open', self.cr) | ||
2041 | 142 | except osv.except_osv,e: | ||
2042 | 143 | self.fail(e.name + e.value) | ||
2043 | 144 | except Exception,e: | ||
2044 | 145 | self.fail(e) | ||
2045 | 146 | |||
2046 | 147 | def test_3_CreatePaymentOrder(self): | ||
2047 | 148 | try: | ||
2048 | 149 | global payment_order_id | ||
2049 | 150 | payment_order_id = self.payment_order.create(self.cr,self.uid,{'mode':payment_type_id}) | ||
2050 | 151 | line = self.pool.get('account.move.line').search(self.cr,self.uid,[('name','=','Unit Test Invoice Line')]) | ||
2051 | 152 | self.cr.commit() | ||
2052 | 153 | self.failUnless(payment_order_id,"No Case Stage Created !") | ||
2053 | 154 | wizard_service = netsvc.ExportService.getService("wizard") | ||
2054 | 155 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'populate_payment') | ||
2055 | 156 | datas = {'form': {'duedate': time.strftime('%Y-%m-%d'), 'entries': [[6, 0, line]]}, 'ids': [payment_order_id], 'id': payment_order_id} | ||
2056 | 157 | state = 'create' | ||
2057 | 158 | res3 = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
2058 | 159 | except osv.except_osv,e: | ||
2059 | 160 | self.fail(e.name + e.value) | ||
2060 | 161 | except Exception,e: | ||
2061 | 162 | self.fail(e) | ||
2062 | 163 | |||
2063 | 164 | def test_4_ConfirmPayment(self): | ||
2064 | 165 | try: | ||
2065 | 166 | self.failUnless(payment_order_id,"No Payment Order Created !") | ||
2066 | 167 | wf_service = netsvc.LocalService("workflow") | ||
2067 | 168 | res = wf_service.trg_validate(self.uid, 'payment.order',payment_order_id, 'open', self.cr) | ||
2068 | 169 | except osv.except_osv,e: | ||
2069 | 170 | self.fail(e.name + e.value) | ||
2070 | 171 | except Exception,e: | ||
2071 | 172 | self.fail(e) | ||
2072 | 173 | |||
2073 | 174 | def test_5_MakePayment(self): | ||
2074 | 175 | try: | ||
2075 | 176 | self.cr.commit() | ||
2076 | 177 | self.failUnless(payment_order_id,"No Payment Order Created !") | ||
2077 | 178 | wizard_service = netsvc.ExportService.getService("wizard") | ||
2078 | 179 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'pay_payment') | ||
2079 | 180 | datas = {'model': 'payment.order', 'form': {}, 'id': payment_order_id, 'ids': [payment_order_id]} | ||
2080 | 181 | state = 'init' | ||
2081 | 182 | res3 = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
2082 | 183 | except osv.except_osv,e: | ||
2083 | 184 | self.fail(e.name + e.value) | ||
2084 | 185 | except Exception,e: | ||
2085 | 186 | self.fail(e) | ||
2086 | 187 | |||
2087 | 188 | def test_6_PrintOrder(self): | ||
2088 | 189 | try: | ||
2089 | 190 | self.failUnless(payment_order_id,"No Payment Order Created !") | ||
2090 | 191 | report_service = netsvc.ExportService.getService('report') | ||
2091 | 192 | report_service.exp_report(self.cr.dbname, self.uid, 'payment.order', [payment_order_id]) | ||
2092 | 193 | except osv.except_osv,e: | ||
2093 | 194 | self.fail(e.name + e.value) | ||
2094 | 195 | except Exception,e: | ||
2095 | 196 | self.fail(e) | ||
2096 | 197 | |||
2097 | 198 | def test_7_UnlinkPaymentOrder(self): | ||
2098 | 199 | try: | ||
2099 | 200 | self.failUnless(payment_order_id,"No Payment Order Created !") | ||
2100 | 201 | self.payment_order.unlink(self.cr,self.uid,[payment_order_id]) | ||
2101 | 202 | self.payment_mode.unlink(self.cr,self.uid,[payment_mode_id]) | ||
2102 | 203 | self.payment_type.unlink(self.cr,self.uid,[payment_type_id]) | ||
2103 | 204 | self.res_partner_bank.unlink(self.cr,self.uid,[partner_bank_id]) | ||
2104 | 205 | self.res_partner_bank_type.unlink(self.cr,self.uid,[bank_type_id]) | ||
2105 | 206 | self.res_bank.unlink(self.cr,self.uid,[bank_id]) | ||
2106 | 207 | except osv.except_osv,e: | ||
2107 | 208 | self.fail(e.name + e.value) | ||
2108 | 209 | except Exception,e: | ||
2109 | 210 | self.fail(e) | ||
2110 | 211 | |||
2111 | 212 | def test_8_UnlinkInvoice(self): | ||
2112 | 213 | try: | ||
2113 | 214 | sale_journal = self.pool.get('account.journal').search(self.cr,self.uid,[('name','=','x Sales Journal')]) | ||
2114 | 215 | sale_journal_id = self.pool.get('account.journal').browse(self.cr,self.uid,sale_journal)[0] | ||
2115 | 216 | wf_service = netsvc.LocalService("workflow") | ||
2116 | 217 | if not sale_journal_id.update_posted: | ||
2117 | 218 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal_id.id],{'update_posted':True}) | ||
2118 | 219 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id,'invoice_cancel', self.cr) | ||
2119 | 220 | self.account_invoice.unlink(self.cr,self.uid,[invoice_id]) | ||
2120 | 221 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal_id.id],{'update_posted':False}) | ||
2121 | 222 | except osv.except_osv,e: | ||
2122 | 223 | self.fail(e.name + e.value) | ||
2123 | 224 | except Exception,e: | ||
2124 | 225 | self.fail(e) | ||
2125 | 226 | |||
2126 | 227 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2127 | 0 | 228 | ||
2128 | === added directory 'account_report/unit_test' | |||
2129 | === added file 'account_report/unit_test/__init__.py' | |||
2130 | --- account_report/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
2131 | +++ account_report/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
2132 | @@ -0,0 +1,22 @@ | |||
2133 | 1 | # -*- coding: utf-8 -*- | ||
2134 | 2 | ############################################################################## | ||
2135 | 3 | # | ||
2136 | 4 | # OpenERP, Open Source Management Solution | ||
2137 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2138 | 6 | # | ||
2139 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2140 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2141 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2142 | 10 | # License, or (at your option) any later version. | ||
2143 | 11 | # | ||
2144 | 12 | # This program is distributed in the hope that it will be useful, | ||
2145 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2146 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2147 | 15 | # GNU Affero General Public License for more details. | ||
2148 | 16 | # | ||
2149 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2150 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2151 | 19 | # | ||
2152 | 20 | ############################################################################## | ||
2153 | 21 | |||
2154 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2155 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
2156 | 1 | 24 | ||
2157 | === added file 'account_report/unit_test/test.py' | |||
2158 | --- account_report/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
2159 | +++ account_report/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
2160 | @@ -0,0 +1,89 @@ | |||
2161 | 1 | # -*- coding: utf-8 -*- | ||
2162 | 2 | ############################################################################## | ||
2163 | 3 | # | ||
2164 | 4 | # OpenERP, Open Source Management Solution | ||
2165 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2166 | 6 | # | ||
2167 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2168 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2169 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2170 | 10 | # License, or (at your option) any later version. | ||
2171 | 11 | # | ||
2172 | 12 | # This program is distributed in the hope that it will be useful, | ||
2173 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2174 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2175 | 15 | # GNU Affero General Public License for more details. | ||
2176 | 16 | # | ||
2177 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2178 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2179 | 19 | # | ||
2180 | 20 | ############################################################################## | ||
2181 | 21 | import unittest | ||
2182 | 22 | import pooler | ||
2183 | 23 | from osv import osv | ||
2184 | 24 | import netsvc | ||
2185 | 25 | |||
2186 | 26 | account_report_report_id = None | ||
2187 | 27 | |||
2188 | 28 | class account(unittest.TestCase): | ||
2189 | 29 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
2190 | 30 | self.cr = cursor | ||
2191 | 31 | self.uid = user | ||
2192 | 32 | unittest.TestCase.__init__(self, methodName) | ||
2193 | 33 | |||
2194 | 34 | def setUp(self): | ||
2195 | 35 | try: | ||
2196 | 36 | self.pool = pooler.get_pool(self.cr.dbname) | ||
2197 | 37 | self.account_account_report = self.pool.get('account.report.report') | ||
2198 | 38 | except osv.except_osv,e: | ||
2199 | 39 | self.fail(e.name + e.value) | ||
2200 | 40 | except Exception,e: | ||
2201 | 41 | self.fail(e) | ||
2202 | 42 | |||
2203 | 43 | def tearDown(self): | ||
2204 | 44 | try: | ||
2205 | 45 | self.pool = None | ||
2206 | 46 | self.account_account_report = None | ||
2207 | 47 | except osv.except_osv,e: | ||
2208 | 48 | self.fail(e.name + e.value) | ||
2209 | 49 | except Exception,e: | ||
2210 | 50 | self.fail(e) | ||
2211 | 51 | |||
2212 | 52 | def test_1_creat_custom_report(self): | ||
2213 | 53 | try: | ||
2214 | 54 | global account_report_report_id | ||
2215 | 55 | account_report_report_id = self.account_account_report.create(self.cr,self.uid,{ | ||
2216 | 56 | 'name':'Unit test of account report', | ||
2217 | 57 | 'code':'TEST', | ||
2218 | 58 | 'goodness_limit':-100, | ||
2219 | 59 | 'badness_limit':-100, | ||
2220 | 60 | 'expression':'credit([\'x 40000\'],Fiscal Year 2009)', | ||
2221 | 61 | 'disp_tree':True, | ||
2222 | 62 | 'disp_graph':True | ||
2223 | 63 | }) | ||
2224 | 64 | except osv.except_osv,e: | ||
2225 | 65 | self.fail(e.name + e.value) | ||
2226 | 66 | except Exception,e: | ||
2227 | 67 | self.fail(e) | ||
2228 | 68 | |||
2229 | 69 | def test_2_print_report(self): | ||
2230 | 70 | try: | ||
2231 | 71 | self.cr.commit() | ||
2232 | 72 | self.failUnless(account_report_report_id,"No custom report created !") | ||
2233 | 73 | report_service = netsvc.ExportService.getService('report') | ||
2234 | 74 | report_service.exp_report(self.cr.dbname, self.uid, "accounting.report", [account_report_report_id]) | ||
2235 | 75 | except osv.except_osv,e: | ||
2236 | 76 | self.fail(e.name + e.value) | ||
2237 | 77 | except Exception,e: | ||
2238 | 78 | self.fail(e) | ||
2239 | 79 | |||
2240 | 80 | def test_2_unlink_custom_report(self): | ||
2241 | 81 | try: | ||
2242 | 82 | self.failUnless(account_report_report_id,"No custome report created !") | ||
2243 | 83 | self.account_account_report.unlink(self.cr,self.uid,[account_report_report_id]) | ||
2244 | 84 | except osv.except_osv,e: | ||
2245 | 85 | self.fail(e.name + e.value) | ||
2246 | 86 | except Exception,e: | ||
2247 | 87 | self.fail(e) | ||
2248 | 88 | |||
2249 | 89 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2250 | 0 | 90 | ||
2251 | === added directory 'account_reporting/unit_test' | |||
2252 | === added file 'account_reporting/unit_test/__init__.py' | |||
2253 | --- account_reporting/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
2254 | +++ account_reporting/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
2255 | @@ -0,0 +1,22 @@ | |||
2256 | 1 | # -*- coding: utf-8 -*- | ||
2257 | 2 | ############################################################################## | ||
2258 | 3 | # | ||
2259 | 4 | # OpenERP, Open Source Management Solution | ||
2260 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2261 | 6 | # | ||
2262 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2263 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2264 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2265 | 10 | # License, or (at your option) any later version. | ||
2266 | 11 | # | ||
2267 | 12 | # This program is distributed in the hope that it will be useful, | ||
2268 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2269 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2270 | 15 | # GNU Affero General Public License for more details. | ||
2271 | 16 | # | ||
2272 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2273 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2274 | 19 | # | ||
2275 | 20 | ############################################################################## | ||
2276 | 21 | |||
2277 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2278 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
2279 | 1 | 24 | ||
2280 | === added file 'account_reporting/unit_test/test.py' | |||
2281 | --- account_reporting/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
2282 | +++ account_reporting/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
2283 | @@ -0,0 +1,99 @@ | |||
2284 | 1 | # -*- coding: utf-8 -*- | ||
2285 | 2 | ############################################################################## | ||
2286 | 3 | # | ||
2287 | 4 | # OpenERP, Open Source Management Solution | ||
2288 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2289 | 6 | # | ||
2290 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2291 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2292 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2293 | 10 | # License, or (at your option) any later version. | ||
2294 | 11 | # | ||
2295 | 12 | # This program is distributed in the hope that it will be useful, | ||
2296 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2297 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2298 | 15 | # GNU Affero General Public License for more details. | ||
2299 | 16 | # | ||
2300 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2301 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2302 | 19 | # | ||
2303 | 20 | ############################################################################## | ||
2304 | 21 | |||
2305 | 22 | import unittest | ||
2306 | 23 | import pooler | ||
2307 | 24 | import netsvc | ||
2308 | 25 | from osv import osv | ||
2309 | 26 | |||
2310 | 27 | report_bs_id = None | ||
2311 | 28 | period_id = None | ||
2312 | 29 | |||
2313 | 30 | class account_reporting_test_case(unittest.TestCase): | ||
2314 | 31 | |||
2315 | 32 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
2316 | 33 | self.cr = cursor | ||
2317 | 34 | self.uid = user | ||
2318 | 35 | unittest.TestCase.__init__(self, methodName) | ||
2319 | 36 | |||
2320 | 37 | def setUp(self): | ||
2321 | 38 | try: | ||
2322 | 39 | self.pool = pooler.get_pool(self.cr.dbname) | ||
2323 | 40 | self.account_report_bs = self.pool.get('account.report.bs') | ||
2324 | 41 | except osv.except_osv,e: | ||
2325 | 42 | self.fail(e.name + e.value) | ||
2326 | 43 | except Exception,e: | ||
2327 | 44 | self.fail(e) | ||
2328 | 45 | |||
2329 | 46 | def tearDown(self): | ||
2330 | 47 | try: | ||
2331 | 48 | self.pool = None | ||
2332 | 49 | self.account_report_bs = None | ||
2333 | 50 | except osv.except_osv,e: | ||
2334 | 51 | self.fail(e.name + e.value) | ||
2335 | 52 | except Exception,e: | ||
2336 | 53 | self.fail(e) | ||
2337 | 54 | |||
2338 | 55 | def test_1_Create(self): | ||
2339 | 56 | try: | ||
2340 | 57 | global report_bs_id,period_id | ||
2341 | 58 | |||
2342 | 59 | model_obj = self.pool.get('ir.model.data') | ||
2343 | 60 | self.cr.execute("select id from account_account limit 5") | ||
2344 | 61 | acc_id = map(lambda x: x[0], self.cr.fetchall()) | ||
2345 | 62 | |||
2346 | 63 | self.cr.execute("select id from account_period") | ||
2347 | 64 | period_id = map(lambda x: x[0], self.cr.fetchall()) | ||
2348 | 65 | |||
2349 | 66 | report_bs_id = self.account_report_bs.create(self.cr,self.uid,{'name':'Unit test balance sheet report', | ||
2350 | 67 | 'code':'Unit BS', | ||
2351 | 68 | 'account_id':[(6,0,acc_id)], | ||
2352 | 69 | 'font_style':'Courier', | ||
2353 | 70 | 'report_type':'acc_with_child'}) | ||
2354 | 71 | except osv.except_osv,e: | ||
2355 | 72 | self.fail(e.name + e.value) | ||
2356 | 73 | except Exception,e: | ||
2357 | 74 | self.fail(e) | ||
2358 | 75 | |||
2359 | 76 | def test_2_Report(self): | ||
2360 | 77 | try: | ||
2361 | 78 | self.failUnless(report_bs_id,"No Report Balance Sheet record Created !") | ||
2362 | 79 | self.cr.commit() | ||
2363 | 80 | wizard_service = netsvc.ExportService.getService("wizard") | ||
2364 | 81 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'account.account.balancesheet.report') | ||
2365 | 82 | datas = {'id': report_bs_id, 'model': 'account.report.bs', 'form': {'periods': [[6, 0, period_id]], 'report_type': 'only_obj', 'fiscalyear': 1},} | ||
2366 | 83 | state = 'report' | ||
2367 | 84 | wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
2368 | 85 | except osv.except_osv,e: | ||
2369 | 86 | self.fail(e.name + e.value) | ||
2370 | 87 | except Exception,e: | ||
2371 | 88 | self.fail(e) | ||
2372 | 89 | |||
2373 | 90 | def test_3_UnlinkInvoice(self): | ||
2374 | 91 | try: | ||
2375 | 92 | self.failUnless(report_bs_id,"No Report Balance Sheet record Created !") | ||
2376 | 93 | self.account_report_bs.unlink(self.cr,self.uid,[report_bs_id]) | ||
2377 | 94 | except osv.except_osv,e: | ||
2378 | 95 | self.fail(e.name + e.value) | ||
2379 | 96 | except Exception,e: | ||
2380 | 97 | self.fail(e) | ||
2381 | 98 | |||
2382 | 99 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2383 | 0 | 100 | ||
2384 | === added directory 'account_tax_include/unit_test' | |||
2385 | === added file 'account_tax_include/unit_test/__init__.py' | |||
2386 | --- account_tax_include/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
2387 | +++ account_tax_include/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
2388 | @@ -0,0 +1,22 @@ | |||
2389 | 1 | # -*- coding: utf-8 -*- | ||
2390 | 2 | ############################################################################## | ||
2391 | 3 | # | ||
2392 | 4 | # OpenERP, Open Source Management Solution | ||
2393 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2394 | 6 | # | ||
2395 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2396 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2397 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2398 | 10 | # License, or (at your option) any later version. | ||
2399 | 11 | # | ||
2400 | 12 | # This program is distributed in the hope that it will be useful, | ||
2401 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2402 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2403 | 15 | # GNU Affero General Public License for more details. | ||
2404 | 16 | # | ||
2405 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2406 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2407 | 19 | # | ||
2408 | 20 | ############################################################################## | ||
2409 | 21 | |||
2410 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2411 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
2412 | 1 | 24 | ||
2413 | === added file 'account_tax_include/unit_test/test.py' | |||
2414 | --- account_tax_include/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
2415 | +++ account_tax_include/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
2416 | @@ -0,0 +1,135 @@ | |||
2417 | 1 | # -*- coding: utf-8 -*- | ||
2418 | 2 | ############################################################################## | ||
2419 | 3 | # | ||
2420 | 4 | # OpenERP, Open Source Management Solution | ||
2421 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2422 | 6 | # | ||
2423 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2424 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2425 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2426 | 10 | # License, or (at your option) any later version. | ||
2427 | 11 | # | ||
2428 | 12 | # This program is distributed in the hope that it will be useful, | ||
2429 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2430 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2431 | 15 | # GNU Affero General Public License for more details. | ||
2432 | 16 | # | ||
2433 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2434 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2435 | 19 | # | ||
2436 | 20 | ############################################################################## | ||
2437 | 21 | |||
2438 | 22 | import unittest | ||
2439 | 23 | import pooler | ||
2440 | 24 | import netsvc | ||
2441 | 25 | from osv import osv | ||
2442 | 26 | |||
2443 | 27 | invoice_id = None | ||
2444 | 28 | invoice_line_id = None | ||
2445 | 29 | tax_id = None | ||
2446 | 30 | |||
2447 | 31 | class account_tax_include_test_case(unittest.TestCase): | ||
2448 | 32 | |||
2449 | 33 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
2450 | 34 | self.cr = cursor | ||
2451 | 35 | self.uid = user | ||
2452 | 36 | unittest.TestCase.__init__(self, methodName) | ||
2453 | 37 | |||
2454 | 38 | def setUp(self): | ||
2455 | 39 | try: | ||
2456 | 40 | self.pool = pooler.get_pool(self.cr.dbname) | ||
2457 | 41 | self.account_invoice = self.pool.get('account.invoice') | ||
2458 | 42 | self.account_invoice_line = self.pool.get('account.invoice.line') | ||
2459 | 43 | self.account_tax = self.pool.get('account.tax') | ||
2460 | 44 | except osv.except_osv,e: | ||
2461 | 45 | self.fail(e.name + e.value) | ||
2462 | 46 | except Exception,e: | ||
2463 | 47 | self.fail(e) | ||
2464 | 48 | |||
2465 | 49 | def tearDown(self): | ||
2466 | 50 | try: | ||
2467 | 51 | self.account_invoice = None | ||
2468 | 52 | self.account_invoice_line = None | ||
2469 | 53 | self.account_tax = None | ||
2470 | 54 | except osv.except_osv,e: | ||
2471 | 55 | self.fail(e.name + e.value) | ||
2472 | 56 | except Exception,e: | ||
2473 | 57 | self.fail(e) | ||
2474 | 58 | |||
2475 | 59 | def test_1_Create(self): | ||
2476 | 60 | try: | ||
2477 | 61 | global invoice_id,invoice_line_id,tax_id,sales_journal_id | ||
2478 | 62 | model_obj = self.pool.get('ir.model.data') | ||
2479 | 63 | # Product | ||
2480 | 64 | product = model_obj._get_id(self.cr,self.uid, 'product', 'product_product_pc1') | ||
2481 | 65 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
2482 | 66 | # Partner | ||
2483 | 67 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_desertic_hispafuentes') | ||
2484 | 68 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
2485 | 69 | |||
2486 | 70 | # Partners address | ||
2487 | 71 | partner_address = model_obj._get_id(self.cr, self.uid, 'base', 'res_partner_address_1') | ||
2488 | 72 | partner_address_id = model_obj.browse(self.cr, self.uid, partner_address).res_id | ||
2489 | 73 | |||
2490 | 74 | # Account | ||
2491 | 75 | receive_account = model_obj._get_id(self.cr,self.uid, 'account', 'a_recv') | ||
2492 | 76 | receive_account_id = model_obj.browse(self.cr, self.uid, receive_account).res_id | ||
2493 | 77 | pay_account = model_obj._get_id(self.cr,self.uid, 'account', 'a_pay') | ||
2494 | 78 | pay_account_id = model_obj.browse(self.cr, self.uid, pay_account).res_id | ||
2495 | 79 | |||
2496 | 80 | # Journal | ||
2497 | 81 | sales_journal = model_obj._get_id(self.cr, self.uid, 'account', 'sales_journal') | ||
2498 | 82 | sales_journal_id = model_obj.browse(self.cr, self.uid, sales_journal).res_id | ||
2499 | 83 | |||
2500 | 84 | tax_id = self.account_tax.create(self.cr,self.uid,{'name':'Unit test case tax', | ||
2501 | 85 | 'amount':0.10}) | ||
2502 | 86 | invoice_id = self.account_invoice.create(self.cr,self.uid, | ||
2503 | 87 | {'name': 'Unit Test Account tax include case Invoice', | ||
2504 | 88 | 'type': 'out_invoice', | ||
2505 | 89 | 'partner_id': partner_id, | ||
2506 | 90 | 'address_invoice_id': partner_address_id, | ||
2507 | 91 | 'address_contact_id': partner_address_id, | ||
2508 | 92 | 'account_id':receive_account_id, | ||
2509 | 93 | }) | ||
2510 | 94 | |||
2511 | 95 | invoice_line_id = self.pool.get('account.invoice.line').create(self.cr,self.uid, | ||
2512 | 96 | {'name' :'Unit Test Invoice Line', | ||
2513 | 97 | 'invoice_id':invoice_id, | ||
2514 | 98 | 'account_id':pay_account_id, | ||
2515 | 99 | 'product_id':product_id, | ||
2516 | 100 | 'price_unit':450 , | ||
2517 | 101 | 'quantity':4, | ||
2518 | 102 | 'invoice_line_tax_id':[(6,0,[tax_id])], | ||
2519 | 103 | }) | ||
2520 | 104 | except osv.except_osv,e: | ||
2521 | 105 | self.fail(e.name + e.value) | ||
2522 | 106 | except Exception,e: | ||
2523 | 107 | self.fail(e) | ||
2524 | 108 | |||
2525 | 109 | def test_2_CreateInvoice(self): | ||
2526 | 110 | try: | ||
2527 | 111 | self.failUnless(invoice_id,"No Invoice Created !") | ||
2528 | 112 | wf_service = netsvc.LocalService("workflow") | ||
2529 | 113 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id, 'invoice_open', self.cr) | ||
2530 | 114 | except osv.except_osv,e: | ||
2531 | 115 | self.fail(e.name + e.value) | ||
2532 | 116 | except Exception,e: | ||
2533 | 117 | self.fail(e) | ||
2534 | 118 | |||
2535 | 119 | def test_3_Unlink(self): | ||
2536 | 120 | try: | ||
2537 | 121 | self.failUnless(invoice_id,"No Invoice Created !") | ||
2538 | 122 | sale_journal = self.pool.get('account.journal').browse(self.cr,self.uid,sales_journal_id) | ||
2539 | 123 | wf_service = netsvc.LocalService("workflow") | ||
2540 | 124 | if not sale_journal.update_posted: | ||
2541 | 125 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal.id],{'update_posted':True}) | ||
2542 | 126 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id,'invoice_cancel', self.cr) | ||
2543 | 127 | self.account_invoice.unlink(self.cr,self.uid,[invoice_id]) | ||
2544 | 128 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal.id],{'update_posted':False}) | ||
2545 | 129 | self.account_tax.unlink(self.cr,self.uid,[tax_id]) | ||
2546 | 130 | except osv.except_osv,e: | ||
2547 | 131 | self.fail(e.name + e.value) | ||
2548 | 132 | except Exception,e: | ||
2549 | 133 | self.fail(e) | ||
2550 | 134 | |||
2551 | 135 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2552 | 0 | 136 | ||
2553 | === added directory 'account_voucher/unit_test' | |||
2554 | === added file 'account_voucher/unit_test/__init__.py' | |||
2555 | --- account_voucher/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
2556 | +++ account_voucher/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
2557 | @@ -0,0 +1,22 @@ | |||
2558 | 1 | # -*- coding: utf-8 -*- | ||
2559 | 2 | ############################################################################## | ||
2560 | 3 | # | ||
2561 | 4 | # OpenERP, Open Source Management Solution | ||
2562 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2563 | 6 | # | ||
2564 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2565 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2566 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2567 | 10 | # License, or (at your option) any later version. | ||
2568 | 11 | # | ||
2569 | 12 | # This program is distributed in the hope that it will be useful, | ||
2570 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2571 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2572 | 15 | # GNU Affero General Public License for more details. | ||
2573 | 16 | # | ||
2574 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2575 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2576 | 19 | # | ||
2577 | 20 | ############################################################################## | ||
2578 | 21 | |||
2579 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2580 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
2581 | 1 | 24 | ||
2582 | === added file 'account_voucher/unit_test/test.py' | |||
2583 | --- account_voucher/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
2584 | +++ account_voucher/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
2585 | @@ -0,0 +1,144 @@ | |||
2586 | 1 | # -*- coding: utf-8 -*- | ||
2587 | 2 | ############################################################################## | ||
2588 | 3 | # | ||
2589 | 4 | # OpenERP, Open Source Management Solution | ||
2590 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2591 | 6 | # | ||
2592 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2593 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2594 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2595 | 10 | # License, or (at your option) any later version. | ||
2596 | 11 | # | ||
2597 | 12 | # This program is distributed in the hope that it will be useful, | ||
2598 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2599 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2600 | 15 | # GNU Affero General Public License for more details. | ||
2601 | 16 | # | ||
2602 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2603 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2604 | 19 | # | ||
2605 | 20 | ############################################################################## | ||
2606 | 21 | import unittest | ||
2607 | 22 | import pooler | ||
2608 | 23 | import netsvc | ||
2609 | 24 | from osv import osv | ||
2610 | 25 | |||
2611 | 26 | voucher_id = None | ||
2612 | 27 | voucher_line_id = None | ||
2613 | 28 | account_id = None | ||
2614 | 29 | |||
2615 | 30 | class account_voucher_test_case(unittest.TestCase): | ||
2616 | 31 | |||
2617 | 32 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
2618 | 33 | self.cr = cursor | ||
2619 | 34 | self.uid = user | ||
2620 | 35 | unittest.TestCase.__init__(self, methodName) | ||
2621 | 36 | |||
2622 | 37 | def setUp(self): | ||
2623 | 38 | try: | ||
2624 | 39 | self.pool = pooler.get_pool(self.cr.dbname) | ||
2625 | 40 | self.account_invoice = self.pool.get('account.invoice') | ||
2626 | 41 | self.account_invoice_line = self.pool.get('account.invoice.line') | ||
2627 | 42 | self.account_voucher = self.pool.get('account.voucher') | ||
2628 | 43 | self.account_voucher_line = self.pool.get('account.voucher.line') | ||
2629 | 44 | except osv.except_osv,e: | ||
2630 | 45 | self.fail(e.name + e.value) | ||
2631 | 46 | except Exception,e: | ||
2632 | 47 | self.fail(e) | ||
2633 | 48 | |||
2634 | 49 | def tearDown(self): | ||
2635 | 50 | try: | ||
2636 | 51 | self.account_invoice = None | ||
2637 | 52 | self.account_invoice_line = None | ||
2638 | 53 | self.account_voucher = None | ||
2639 | 54 | self.account_voucher_line = None | ||
2640 | 55 | except osv.except_osv,e: | ||
2641 | 56 | self.fail(e.name + e.value) | ||
2642 | 57 | except Exception,e: | ||
2643 | 58 | self.fail(e) | ||
2644 | 59 | |||
2645 | 60 | def test_1_CreateVoucher(self): | ||
2646 | 61 | try: | ||
2647 | 62 | global voucher_id,voucher_line_id,receive_account_id,account_id,analytic_journal_id,journal | ||
2648 | 63 | |||
2649 | 64 | model_obj = self.pool.get('ir.model.data') | ||
2650 | 65 | |||
2651 | 66 | account = model_obj._get_id(self.cr,self.uid, 'account', 'cash') | ||
2652 | 67 | account_id = model_obj.browse(self.cr, self.uid, account).res_id | ||
2653 | 68 | receive_account = model_obj._get_id(self.cr,self.uid, 'account', 'a_recv') | ||
2654 | 69 | receive_account_id = model_obj.browse(self.cr, self.uid, receive_account).res_id | ||
2655 | 70 | # Analytic Account | ||
2656 | 71 | analytic_account = model_obj._get_id(self.cr,self.uid, 'account', 'analytic_project_1') | ||
2657 | 72 | analytic_account_id = model_obj.browse(self.cr, self.uid, analytic_account).res_id | ||
2658 | 73 | # Partner | ||
2659 | 74 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_asus') | ||
2660 | 75 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
2661 | 76 | |||
2662 | 77 | sales_journal = model_obj._get_id(self.cr, self.uid, 'account', 'sales_journal') | ||
2663 | 78 | sales_journal_id = model_obj.browse(self.cr, self.uid, sales_journal).res_id | ||
2664 | 79 | analytic_journal = model_obj._get_id(self.cr, self.uid, 'account', 'cose_journal_sale') | ||
2665 | 80 | analytic_journal_id = model_obj.browse(self.cr, self.uid, analytic_journal).res_id | ||
2666 | 81 | |||
2667 | 82 | voucher_id = self.account_voucher.create(self.cr,self.uid,{'name':'Unit test case voucher', | ||
2668 | 83 | 'narration':'Ref: Unit test case', | ||
2669 | 84 | 'account_id':account_id}) | ||
2670 | 85 | |||
2671 | 86 | voucher_line_id = self.account_voucher_line.create(self.cr,self.uid,{'voucher_id':voucher_id, | ||
2672 | 87 | 'name':'Unit test voucher line', | ||
2673 | 88 | 'account_analytic_id':analytic_account_id, | ||
2674 | 89 | 'account_id':receive_account_id, | ||
2675 | 90 | 'partner_id':partner_id, | ||
2676 | 91 | 'type':'cr', | ||
2677 | 92 | 'amount':1000.00}) | ||
2678 | 93 | |||
2679 | 94 | except osv.except_osv,e: | ||
2680 | 95 | self.fail(e.name + e.value) | ||
2681 | 96 | except Exception,e: | ||
2682 | 97 | self.fail(e) | ||
2683 | 98 | |||
2684 | 99 | def test_2_open_voucher(self): | ||
2685 | 100 | try: | ||
2686 | 101 | self.failUnless(voucher_id,"No Voucher Created !") | ||
2687 | 102 | self.account_voucher.open_voucher(self.cr,self.uid,[voucher_id]) | ||
2688 | 103 | except osv.except_osv,e: | ||
2689 | 104 | self.fail(e.name + e.value) | ||
2690 | 105 | except Exception,e: | ||
2691 | 106 | self.fail(e) | ||
2692 | 107 | |||
2693 | 108 | def test_3_proforma_voucher(self): | ||
2694 | 109 | try: | ||
2695 | 110 | self.failUnless(voucher_id,"No Voucher Created !") | ||
2696 | 111 | global journal | ||
2697 | 112 | journal = self.account_voucher.browse(self.cr,self.uid,voucher_id) | ||
2698 | 113 | if not journal.journal_id.analytic_journal_id.id: | ||
2699 | 114 | self.pool.get('account.journal').write(self.cr,self.uid,[journal.journal_id.id],{'analytic_journal_id':analytic_journal_id}) | ||
2700 | 115 | self.account_voucher.proforma_voucher(self.cr,self.uid,[voucher_id]) | ||
2701 | 116 | self.pool.get('account.journal').write(self.cr,self.uid,[journal.journal_id.id],{'analytic_journal_id':False}) | ||
2702 | 117 | except osv.except_osv,e: | ||
2703 | 118 | self.fail(e.name + e.value) | ||
2704 | 119 | except Exception,e: | ||
2705 | 120 | self.fail(e) | ||
2706 | 121 | |||
2707 | 122 | def test_4_CancelVoucher(self): | ||
2708 | 123 | try: | ||
2709 | 124 | bank_journal = self.pool.get('account.journal').browse(self.cr,self.uid,journal.journal_id.id) | ||
2710 | 125 | if not bank_journal.update_posted: | ||
2711 | 126 | self.pool.get('account.journal').write(self.cr,self.uid,[journal.journal_id.id],{'update_posted':True}) | ||
2712 | 127 | self.account_voucher.cancel_voucher(self.cr,self.uid,[voucher_id]) | ||
2713 | 128 | self.account_voucher.action_cancel_draft(self.cr,self.uid,[voucher_id]) | ||
2714 | 129 | self.pool.get('account.journal').write(self.cr,self.uid,[journal.journal_id.id],{'analytic_journal_id':False,'update_posted':False}) | ||
2715 | 130 | except osv.except_osv,e: | ||
2716 | 131 | self.fail(e.name + e.value) | ||
2717 | 132 | except Exception,e: | ||
2718 | 133 | self.fail(e) | ||
2719 | 134 | |||
2720 | 135 | def test_5_Unlink(self): | ||
2721 | 136 | try: | ||
2722 | 137 | self.failUnless(voucher_id,"No Voucher Created !") | ||
2723 | 138 | self.account_voucher.unlink(self.cr,self.uid,[voucher_id]) | ||
2724 | 139 | except osv.except_osv,e: | ||
2725 | 140 | self.fail(e.name + e.value) | ||
2726 | 141 | except Exception,e: | ||
2727 | 142 | self.fail(e) | ||
2728 | 143 | |||
2729 | 144 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2730 | 0 | 145 | ||
2731 | === added directory 'analytic_journal_billing_rate/unit_test' | |||
2732 | === added file 'analytic_journal_billing_rate/unit_test/__init__.py' | |||
2733 | --- analytic_journal_billing_rate/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
2734 | +++ analytic_journal_billing_rate/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
2735 | @@ -0,0 +1,23 @@ | |||
2736 | 1 | # -*- coding: utf-8 -*- | ||
2737 | 2 | ############################################################################## | ||
2738 | 3 | # | ||
2739 | 4 | # OpenERP, Open Source Management Solution | ||
2740 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2741 | 6 | # | ||
2742 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2743 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2744 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2745 | 10 | # License, or (at your option) any later version. | ||
2746 | 11 | # | ||
2747 | 12 | # This program is distributed in the hope that it will be useful, | ||
2748 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2749 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2750 | 15 | # GNU Affero General Public License for more details. | ||
2751 | 16 | # | ||
2752 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2753 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2754 | 19 | # | ||
2755 | 20 | ############################################################################## | ||
2756 | 21 | |||
2757 | 22 | |||
2758 | 23 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2759 | 0 | 24 | ||
2760 | === added file 'analytic_journal_billing_rate/unit_test/test.py' | |||
2761 | --- analytic_journal_billing_rate/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
2762 | +++ analytic_journal_billing_rate/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
2763 | @@ -0,0 +1,161 @@ | |||
2764 | 1 | # -*- coding: utf-8 -*- | ||
2765 | 2 | ############################################################################## | ||
2766 | 3 | # | ||
2767 | 4 | # OpenERP, Open Source Management Solution | ||
2768 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2769 | 6 | # | ||
2770 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2771 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2772 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2773 | 10 | # License, or (at your option) any later version. | ||
2774 | 11 | # | ||
2775 | 12 | # This program is distributed in the hope that it will be useful, | ||
2776 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2777 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2778 | 15 | # GNU Affero General Public License for more details. | ||
2779 | 16 | # | ||
2780 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2781 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2782 | 19 | # | ||
2783 | 20 | ############################################################################## | ||
2784 | 21 | import unittest | ||
2785 | 22 | import pooler | ||
2786 | 23 | import netsvc | ||
2787 | 24 | from osv import osv | ||
2788 | 25 | import hr_timesheet.unit_test.test as ht | ||
2789 | 26 | |||
2790 | 27 | journal_rate_id = None | ||
2791 | 28 | |||
2792 | 29 | class analytic_journal_billing_rate_test_case(unittest.TestCase): | ||
2793 | 30 | |||
2794 | 31 | third_party_cases={ht.hr_timesheet_test_case: ['test_1_Create']} | ||
2795 | 32 | |||
2796 | 33 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
2797 | 34 | self.cr = cursor | ||
2798 | 35 | self.uid = user | ||
2799 | 36 | unittest.TestCase.__init__(self, methodName) | ||
2800 | 37 | |||
2801 | 38 | def setUp(self): | ||
2802 | 39 | try: | ||
2803 | 40 | self.pool = pooler.get_pool(self.cr.dbname) | ||
2804 | 41 | self.account_invoice = self.pool.get('account.invoice') | ||
2805 | 42 | self.account_invoice_line = self.pool.get('account.invoice.line') | ||
2806 | 43 | self.analytic_journal_rate_grid = self.pool.get('analytic_journal_rate_grid') | ||
2807 | 44 | self.hr_analytic_timesheet = self.pool.get('hr.analytic.timesheet') | ||
2808 | 45 | except osv.except_osv,e: | ||
2809 | 46 | self.fail(e.name + e.value) | ||
2810 | 47 | except Exception,e: | ||
2811 | 48 | self.fail(e) | ||
2812 | 49 | |||
2813 | 50 | def tearDown(self): | ||
2814 | 51 | try: | ||
2815 | 52 | self.account_invoice = None | ||
2816 | 53 | self.account_invoice_line = None | ||
2817 | 54 | self.analytic_journal_rate_grid = None | ||
2818 | 55 | self.hr_analytic_timesheet = None | ||
2819 | 56 | except osv.except_osv,e: | ||
2820 | 57 | self.fail(e.name + e.value) | ||
2821 | 58 | except Exception,e: | ||
2822 | 59 | self.fail(e) | ||
2823 | 60 | |||
2824 | 61 | def test_1_Create(self): | ||
2825 | 62 | try: | ||
2826 | 63 | global journal_rate_id,analytic_account_id,product_id,journal_id,invoice_id,sales_journal_id,flag | ||
2827 | 64 | model_obj = self.pool.get('ir.model.data') | ||
2828 | 65 | |||
2829 | 66 | product = model_obj._get_id(self.cr,self.uid, 'hr_timesheet', 'product_consultant') | ||
2830 | 67 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
2831 | 68 | analytic_account = model_obj._get_id(self.cr, self.uid, 'account', 'analytic_project_1') | ||
2832 | 69 | analytic_account_id = model_obj.browse(self.cr, self.uid, analytic_account).res_id | ||
2833 | 70 | journal = model_obj._get_id(self.cr, self.uid, 'account', 'cose_journal_sale') | ||
2834 | 71 | journal_id = model_obj.browse(self.cr, self.uid, journal).res_id | ||
2835 | 72 | rate = model_obj._get_id(self.cr, self.uid, 'hr_timesheet_invoice', 'timesheet_invoice_factor2') | ||
2836 | 73 | rate_id = model_obj.browse(self.cr, self.uid, rate).res_id | ||
2837 | 74 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
2838 | 75 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
2839 | 76 | pricelist = model_obj._get_id(self.cr, self.uid, 'product', 'list0') | ||
2840 | 77 | pricelist_id = model_obj.browse(self.cr, self.uid, pricelist).res_id | ||
2841 | 78 | invoice_discount = model_obj._get_id(self.cr, self.uid, 'hr_timesheet_invoice', 'timesheet_invoice_factor2') | ||
2842 | 79 | invoice_discount_id = model_obj.browse(self.cr, self.uid, invoice_discount).res_id | ||
2843 | 80 | sales_journal = model_obj._get_id(self.cr, self.uid, 'account', 'sales_journal') | ||
2844 | 81 | sales_journal_id = model_obj.browse(self.cr, self.uid, sales_journal).res_id | ||
2845 | 82 | |||
2846 | 83 | journal_rate_id = self.analytic_journal_rate_grid.create(self.cr,self.uid,{'account_id':analytic_account_id, | ||
2847 | 84 | 'journal_id':journal_id, | ||
2848 | 85 | 'rate_id':rate_id}) | ||
2849 | 86 | |||
2850 | 87 | analytic_id = self.pool.get('account.analytic.account').browse(self.cr,self.uid,[analytic_account_id])[0] | ||
2851 | 88 | if not (analytic_id.pricelist_id and analytic_id.partner_id): | ||
2852 | 89 | self.pool.get('account.analytic.account').write(self.cr,self.uid,[analytic_account_id],{ | ||
2853 | 90 | 'pricelist_id':pricelist_id, | ||
2854 | 91 | 'partner_id':partner_id | ||
2855 | 92 | }) | ||
2856 | 93 | self.hr_analytic_timesheet.write(self.cr,self.uid,[ht.timesheet_id],{'to_invoice':invoice_discount_id}) | ||
2857 | 94 | except osv.except_osv,e: | ||
2858 | 95 | self.fail(e.name + e.value) | ||
2859 | 96 | except Exception,e: | ||
2860 | 97 | self.fail(e) | ||
2861 | 98 | |||
2862 | 99 | def test_2_wizard_case(self): | ||
2863 | 100 | try: | ||
2864 | 101 | self.failUnless(analytic_account_id,"No analytic_account Created !") | ||
2865 | 102 | self.cr.commit() | ||
2866 | 103 | wizard_service = netsvc.ExportService.getService("wizard") | ||
2867 | 104 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'hr.timesheet.invoice.create') | ||
2868 | 105 | datas = {'form':{'date':True,'time':True,'name':True,'price':True,'accounts':[(6,0,[analytic_account_id ])],'product':product_id} ,'ids':[ht.timesheet_id],'id':ht.timesheet_id} | ||
2869 | 106 | state = 'create' | ||
2870 | 107 | global res | ||
2871 | 108 | res = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
2872 | 109 | except osv.except_osv,e: | ||
2873 | 110 | self.fail(e.name + e.value) | ||
2874 | 111 | except Exception,e: | ||
2875 | 112 | self.fail(e) | ||
2876 | 113 | |||
2877 | 114 | def test_3_CreateInvoice(self): | ||
2878 | 115 | try: | ||
2879 | 116 | global invoice_id | ||
2880 | 117 | invoice_id = res['action']['domain'][0][2] | ||
2881 | 118 | self.failUnless(invoice_id,"No invoices Created !") | ||
2882 | 119 | journal = self.account_invoice.browse(self.cr,self.uid,invoice_id)[0] | ||
2883 | 120 | wf_service = netsvc.LocalService("workflow") | ||
2884 | 121 | if not journal.journal_id.analytic_journal_id: | ||
2885 | 122 | self.pool.get('account.journal').write(self.cr,self.uid,[journal.journal_id.id],{'analytic_journal_id':journal_id}) | ||
2886 | 123 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id[0], 'invoice_open', self.cr) | ||
2887 | 124 | self.pool.get('account.journal').write(self.cr,self.uid,[journal.journal_id.id],{'analytic_journal_id':False}) | ||
2888 | 125 | except osv.except_osv,e: | ||
2889 | 126 | self.fail(e.name + e.value) | ||
2890 | 127 | except Exception,e: | ||
2891 | 128 | self.fail(e) | ||
2892 | 129 | |||
2893 | 130 | def test_4_CancelInvoice(self): | ||
2894 | 131 | try: | ||
2895 | 132 | self.failUnless(invoice_id,"No invoices Created !") | ||
2896 | 133 | sale_journal = self.pool.get('account.journal').browse(self.cr,self.uid,sales_journal_id) | ||
2897 | 134 | wf_service = netsvc.LocalService("workflow") | ||
2898 | 135 | if not sale_journal.update_posted: | ||
2899 | 136 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal.id],{'update_posted':True}) | ||
2900 | 137 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id[0],'invoice_cancel', self.cr) | ||
2901 | 138 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal.id],{'analytic_journal_id':False,'update_posted':False}) | ||
2902 | 139 | self.account_invoice.unlink(self.cr,self.uid,invoice_id) | ||
2903 | 140 | except osv.except_osv,e: | ||
2904 | 141 | self.fail(e.name + e.value) | ||
2905 | 142 | except Exception,e: | ||
2906 | 143 | self.fail(e) | ||
2907 | 144 | |||
2908 | 145 | def test_5_Unlink(self): | ||
2909 | 146 | try: | ||
2910 | 147 | self.failUnless(ht.timesheet_id,"No timesheet Created !") | ||
2911 | 148 | self.failUnless(journal_rate_id,"No journal_rate Created !") | ||
2912 | 149 | self.failUnless(analytic_account_id,"No analytic_account Created !") | ||
2913 | 150 | self.hr_analytic_timesheet.unlink(self.cr,self.uid,[ht.timesheet_id]) | ||
2914 | 151 | self.analytic_journal_rate_grid.unlink(self.cr,self.uid,[journal_rate_id]) | ||
2915 | 152 | self.pool.get('account.analytic.account').write(self.cr,self.uid,[analytic_account_id],{ | ||
2916 | 153 | 'pricelist_id':False, | ||
2917 | 154 | 'partner_id':False | ||
2918 | 155 | }) | ||
2919 | 156 | except osv.except_osv,e: | ||
2920 | 157 | self.fail(e.name + e.value) | ||
2921 | 158 | except Exception,e: | ||
2922 | 159 | self.fail(e) | ||
2923 | 160 | |||
2924 | 161 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2925 | 0 | 162 | ||
2926 | === added directory 'analytic_user_function/unit_test' | |||
2927 | === added file 'analytic_user_function/unit_test/__init__.py' | |||
2928 | --- analytic_user_function/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
2929 | +++ analytic_user_function/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
2930 | @@ -0,0 +1,23 @@ | |||
2931 | 1 | # -*- coding: utf-8 -*- | ||
2932 | 2 | ############################################################################## | ||
2933 | 3 | # | ||
2934 | 4 | # OpenERP, Open Source Management Solution | ||
2935 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2936 | 6 | # | ||
2937 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2938 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2939 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2940 | 10 | # License, or (at your option) any later version. | ||
2941 | 11 | # | ||
2942 | 12 | # This program is distributed in the hope that it will be useful, | ||
2943 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2944 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2945 | 15 | # GNU Affero General Public License for more details. | ||
2946 | 16 | # | ||
2947 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2948 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2949 | 19 | # | ||
2950 | 20 | ############################################################################## | ||
2951 | 21 | |||
2952 | 22 | |||
2953 | 23 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2954 | 0 | 24 | ||
2955 | === added file 'analytic_user_function/unit_test/test.py' | |||
2956 | --- analytic_user_function/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
2957 | +++ analytic_user_function/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
2958 | @@ -0,0 +1,161 @@ | |||
2959 | 1 | # -*- coding: utf-8 -*- | ||
2960 | 2 | ############################################################################## | ||
2961 | 3 | # | ||
2962 | 4 | # OpenERP, Open Source Management Solution | ||
2963 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
2964 | 6 | # | ||
2965 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2966 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2967 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2968 | 10 | # License, or (at your option) any later version. | ||
2969 | 11 | # | ||
2970 | 12 | # This program is distributed in the hope that it will be useful, | ||
2971 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2972 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2973 | 15 | # GNU Affero General Public License for more details. | ||
2974 | 16 | # | ||
2975 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2976 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2977 | 19 | # | ||
2978 | 20 | ############################################################################## | ||
2979 | 21 | import unittest | ||
2980 | 22 | import pooler | ||
2981 | 23 | import netsvc | ||
2982 | 24 | from osv import osv | ||
2983 | 25 | import hr_timesheet.unit_test.test as ht | ||
2984 | 26 | |||
2985 | 27 | user_function_id = None | ||
2986 | 28 | |||
2987 | 29 | class analytic_user_function_test_case(unittest.TestCase): | ||
2988 | 30 | |||
2989 | 31 | third_party_cases={ht.hr_timesheet_test_case: ['test_1_Create']} | ||
2990 | 32 | |||
2991 | 33 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
2992 | 34 | self.cr = cursor | ||
2993 | 35 | self.uid = user | ||
2994 | 36 | unittest.TestCase.__init__(self, methodName) | ||
2995 | 37 | |||
2996 | 38 | def setUp(self): | ||
2997 | 39 | try: | ||
2998 | 40 | self.pool = pooler.get_pool(self.cr.dbname) | ||
2999 | 41 | self.account_invoice = self.pool.get('account.invoice') | ||
3000 | 42 | self.account_invoice_line = self.pool.get('account.invoice.line') | ||
3001 | 43 | self.analytic_user_funct_grid = self.pool.get('analytic_user_funct_grid') | ||
3002 | 44 | self.hr_analytic_timesheet = self.pool.get('hr.analytic.timesheet') | ||
3003 | 45 | except osv.except_osv,e: | ||
3004 | 46 | self.fail(e.name + e.value) | ||
3005 | 47 | except Exception,e: | ||
3006 | 48 | self.fail(e) | ||
3007 | 49 | |||
3008 | 50 | def tearDown(self): | ||
3009 | 51 | try: | ||
3010 | 52 | self.account_invoice = None | ||
3011 | 53 | self.account_invoice_line = None | ||
3012 | 54 | self.analytic_user_funct_grid = None | ||
3013 | 55 | self.hr_analytic_timesheet = None | ||
3014 | 56 | except osv.except_osv,e: | ||
3015 | 57 | self.fail(e.name + e.value) | ||
3016 | 58 | except Exception,e: | ||
3017 | 59 | self.fail(e) | ||
3018 | 60 | |||
3019 | 61 | def test_1_Create(self): | ||
3020 | 62 | try: | ||
3021 | 63 | global journal_rate_id,analytic_account_id,product_id,journal_id,invoice_id,sales_journal_id,flag | ||
3022 | 64 | model_obj = self.pool.get('ir.model.data') | ||
3023 | 65 | |||
3024 | 66 | product = model_obj._get_id(self.cr,self.uid, 'product', 'product_product_pc1') | ||
3025 | 67 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
3026 | 68 | analytic_account = model_obj._get_id(self.cr, self.uid, 'account', 'analytic_project_1') | ||
3027 | 69 | analytic_account_id = model_obj.browse(self.cr, self.uid, analytic_account).res_id | ||
3028 | 70 | journal = model_obj._get_id(self.cr, self.uid, 'account', 'cose_journal_sale') | ||
3029 | 71 | journal_id = model_obj.browse(self.cr, self.uid, journal).res_id | ||
3030 | 72 | rate = model_obj._get_id(self.cr, self.uid, 'hr_timesheet_invoice', 'timesheet_invoice_factor2') | ||
3031 | 73 | rate_id = model_obj.browse(self.cr, self.uid, rate).res_id | ||
3032 | 74 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
3033 | 75 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
3034 | 76 | pricelist = model_obj._get_id(self.cr, self.uid, 'product', 'list0') | ||
3035 | 77 | pricelist_id = model_obj.browse(self.cr, self.uid, pricelist).res_id | ||
3036 | 78 | invoice_discount = model_obj._get_id(self.cr, self.uid, 'hr_timesheet_invoice', 'timesheet_invoice_factor2') | ||
3037 | 79 | invoice_discount_id = model_obj.browse(self.cr, self.uid, invoice_discount).res_id | ||
3038 | 80 | sales_journal = model_obj._get_id(self.cr, self.uid, 'account', 'sales_journal') | ||
3039 | 81 | sales_journal_id = model_obj.browse(self.cr, self.uid, sales_journal).res_id | ||
3040 | 82 | |||
3041 | 83 | user_function_id = self.analytic_user_funct_grid.create(self.cr,self.uid,{'account_id':analytic_account_id, | ||
3042 | 84 | 'user_id':self.uid, | ||
3043 | 85 | 'product_id':product_id}) | ||
3044 | 86 | |||
3045 | 87 | analytic_id = self.pool.get('account.analytic.account').browse(self.cr,self.uid,[analytic_account_id])[0] | ||
3046 | 88 | if not (analytic_id.pricelist_id and analytic_id.partner_id): | ||
3047 | 89 | self.pool.get('account.analytic.account').write(self.cr,self.uid,[analytic_account_id],{ | ||
3048 | 90 | 'pricelist_id':pricelist_id, | ||
3049 | 91 | 'partner_id':partner_id | ||
3050 | 92 | }) | ||
3051 | 93 | self.hr_analytic_timesheet.write(self.cr,self.uid,[ht.timesheet_id],{'to_invoice':invoice_discount_id}) | ||
3052 | 94 | except osv.except_osv,e: | ||
3053 | 95 | self.fail(e.name + e.value) | ||
3054 | 96 | except Exception,e: | ||
3055 | 97 | self.fail(e) | ||
3056 | 98 | |||
3057 | 99 | def test_2_wizard_case(self): | ||
3058 | 100 | try: | ||
3059 | 101 | self.cr.commit() | ||
3060 | 102 | self.failUnless(analytic_account_id,"No analytic_account Created !") | ||
3061 | 103 | wizard_service = netsvc.ExportService.getService("wizard") | ||
3062 | 104 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'hr.timesheet.invoice.create') | ||
3063 | 105 | datas = {'form':{'date':True,'time':True,'name':True,'price':True,'accounts':[(6,0,[analytic_account_id ])],'product':product_id} ,'ids':[ht.timesheet_id],'id':ht.timesheet_id} | ||
3064 | 106 | state = 'create' | ||
3065 | 107 | global res | ||
3066 | 108 | res = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
3067 | 109 | except osv.except_osv,e: | ||
3068 | 110 | self.fail(e.name + e.value) | ||
3069 | 111 | except Exception,e: | ||
3070 | 112 | self.fail(e) | ||
3071 | 113 | |||
3072 | 114 | def test_3_CreateInvoice(self): | ||
3073 | 115 | try: | ||
3074 | 116 | global invoice_id | ||
3075 | 117 | invoice_id = res['action']['domain'][0][2] | ||
3076 | 118 | self.failUnless(invoice_id,"No invoices Created !") | ||
3077 | 119 | journal = self.account_invoice.browse(self.cr,self.uid,invoice_id)[0] | ||
3078 | 120 | wf_service = netsvc.LocalService("workflow") | ||
3079 | 121 | if not journal.journal_id.analytic_journal_id: | ||
3080 | 122 | self.pool.get('account.journal').write(self.cr,self.uid,[journal.journal_id.id],{'analytic_journal_id':journal_id}) | ||
3081 | 123 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id[0], 'invoice_open', self.cr) | ||
3082 | 124 | self.pool.get('account.journal').write(self.cr,self.uid,[journal.journal_id.id],{'analytic_journal_id':False}) | ||
3083 | 125 | except osv.except_osv,e: | ||
3084 | 126 | self.fail(e.name + e.value) | ||
3085 | 127 | except Exception,e: | ||
3086 | 128 | self.fail(e) | ||
3087 | 129 | |||
3088 | 130 | def test_4_CancelInvoice(self): | ||
3089 | 131 | try: | ||
3090 | 132 | self.failUnless(invoice_id,"No invoices Created !") | ||
3091 | 133 | sale_journal = self.pool.get('account.journal').browse(self.cr,self.uid,sales_journal_id) | ||
3092 | 134 | wf_service = netsvc.LocalService("workflow") | ||
3093 | 135 | if not sale_journal.update_posted: | ||
3094 | 136 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal.id],{'update_posted':True}) | ||
3095 | 137 | wf_service.trg_validate(self.uid, 'account.invoice',invoice_id[0],'invoice_cancel', self.cr) | ||
3096 | 138 | self.pool.get('account.journal').write(self.cr,self.uid,[sale_journal.id],{'analytic_journal_id':False,'update_posted':False}) | ||
3097 | 139 | self.account_invoice.unlink(self.cr,self.uid,invoice_id) | ||
3098 | 140 | except osv.except_osv,e: | ||
3099 | 141 | self.fail(e.name + e.value) | ||
3100 | 142 | except Exception,e: | ||
3101 | 143 | self.fail(e) | ||
3102 | 144 | |||
3103 | 145 | def test_5_Unlink(self): | ||
3104 | 146 | try: | ||
3105 | 147 | self.failUnless(ht.timesheet_id,"No timesheet Created !") | ||
3106 | 148 | self.failUnless(user_function_id,"No user_function Created !") | ||
3107 | 149 | self.failUnless(analytic_account_id,"No analytic_account Created !") | ||
3108 | 150 | self.hr_analytic_timesheet.unlink(self.cr,self.uid,[ht.timesheet_id]) | ||
3109 | 151 | self.analytic_user_funct_grid.unlink(self.cr,self.uid,[user_function_id]) | ||
3110 | 152 | self.pool.get('account.analytic.account').write(self.cr,self.uid,[analytic_account_id],{ | ||
3111 | 153 | 'pricelist_id':False, | ||
3112 | 154 | 'partner_id':False | ||
3113 | 155 | }) | ||
3114 | 156 | except osv.except_osv,e: | ||
3115 | 157 | self.fail(e.name + e.value) | ||
3116 | 158 | except Exception,e: | ||
3117 | 159 | self.fail(e) | ||
3118 | 160 | |||
3119 | 161 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3120 | 0 | 162 | ||
3121 | === added directory 'auction/unit_test' | |||
3122 | === added file 'auction/unit_test/__init__.py' | |||
3123 | --- auction/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
3124 | +++ auction/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
3125 | @@ -0,0 +1,23 @@ | |||
3126 | 1 | # -*- coding: utf-8 -*- | ||
3127 | 2 | ############################################################################## | ||
3128 | 3 | # | ||
3129 | 4 | # OpenERP, Open Source Management Solution | ||
3130 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
3131 | 6 | # | ||
3132 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3133 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3134 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3135 | 10 | # License, or (at your option) any later version. | ||
3136 | 11 | # | ||
3137 | 12 | # This program is distributed in the hope that it will be useful, | ||
3138 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3139 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3140 | 15 | # GNU Affero General Public License for more details. | ||
3141 | 16 | # | ||
3142 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3143 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3144 | 19 | # | ||
3145 | 20 | ############################################################################## | ||
3146 | 21 | |||
3147 | 22 | |||
3148 | 23 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3149 | 0 | \ No newline at end of file | 24 | \ No newline at end of file |
3150 | 1 | 25 | ||
3151 | === added file 'auction/unit_test/test.py' | |||
3152 | --- auction/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
3153 | +++ auction/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
3154 | @@ -0,0 +1,184 @@ | |||
3155 | 1 | # -*- coding: utf-8 -*- | ||
3156 | 2 | ############################################################################## | ||
3157 | 3 | # | ||
3158 | 4 | # OpenERP, Open Source Management Solution | ||
3159 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
3160 | 6 | # | ||
3161 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3162 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3163 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3164 | 10 | # License, or (at your option) any later version. | ||
3165 | 11 | # | ||
3166 | 12 | # This program is distributed in the hope that it will be useful, | ||
3167 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3168 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3169 | 15 | # GNU Affero General Public License for more details. | ||
3170 | 16 | # | ||
3171 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3172 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3173 | 19 | # | ||
3174 | 20 | ############################################################################## | ||
3175 | 21 | import unittest | ||
3176 | 22 | import pooler | ||
3177 | 23 | import netsvc | ||
3178 | 24 | from osv import osv | ||
3179 | 25 | import time | ||
3180 | 26 | |||
3181 | 27 | auction_lots_id = None | ||
3182 | 28 | auction_date_id = None | ||
3183 | 29 | auction_deposit_id = None | ||
3184 | 30 | |||
3185 | 31 | class auction_test_case(unittest.TestCase): | ||
3186 | 32 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
3187 | 33 | self.cr = cursor | ||
3188 | 34 | self.uid = user | ||
3189 | 35 | unittest.TestCase.__init__(self, methodName) | ||
3190 | 36 | |||
3191 | 37 | def setUp(self): | ||
3192 | 38 | try: | ||
3193 | 39 | self.pool = pooler.get_pool(self.cr.dbname) | ||
3194 | 40 | self.auction_lots = self.pool.get('auction.lots') | ||
3195 | 41 | self.auction_dates = self.pool.get('auction.dates') | ||
3196 | 42 | self.auction_deposit = self.pool.get('auction.deposit') | ||
3197 | 43 | except osv.except_osv,e: | ||
3198 | 44 | self.fail(e.name + e.value) | ||
3199 | 45 | except Exception,e: | ||
3200 | 46 | self.fail(e) | ||
3201 | 47 | |||
3202 | 48 | |||
3203 | 49 | def tearDown(self): | ||
3204 | 50 | try: | ||
3205 | 51 | self.pool = None | ||
3206 | 52 | self.auction_lots = None | ||
3207 | 53 | self.auction_dates = None | ||
3208 | 54 | self.auction_deposit = None | ||
3209 | 55 | except osv.except_osv,e: | ||
3210 | 56 | self.fail(e.name + e.value) | ||
3211 | 57 | except Exception,e: | ||
3212 | 58 | self.fail(e) | ||
3213 | 59 | |||
3214 | 60 | |||
3215 | 61 | def test_1_Create(self): | ||
3216 | 62 | |||
3217 | 63 | try: | ||
3218 | 64 | global auction_lots_id,auction_date_id,auction_deposit_id | ||
3219 | 65 | vals = {} | ||
3220 | 66 | model_obj = self.pool.get('ir.model.data') | ||
3221 | 67 | |||
3222 | 68 | buyer_costs = self.pool.get('account.tax').search(self.cr,self.uid,[('name','=','Buyer Costs')]) | ||
3223 | 69 | buyer_costs_id = self.pool.get('account.tax').browse(self.cr,self.uid,buyer_costs)[0] | ||
3224 | 70 | seller_costs = self.pool.get('account.tax').search(self.cr,self.uid,[('name','=','Seller Costs')]) | ||
3225 | 71 | seller_costs_id = self.pool.get('account.tax').browse(self.cr,self.uid,buyer_costs)[0] | ||
3226 | 72 | |||
3227 | 73 | acc_income = model_obj._get_id(self.cr, self.uid, 'account', 'a_sale') | ||
3228 | 74 | acc_income_id = model_obj.browse(self.cr, self.uid,acc_income).res_id | ||
3229 | 75 | acc_expense = model_obj._get_id(self.cr, self.uid, 'account', 'a_expense') | ||
3230 | 76 | acc_expense_id = model_obj.browse(self.cr, self.uid,acc_expense).res_id | ||
3231 | 77 | journal = model_obj._get_id(self.cr, self.uid, 'account', 'sales_journal') | ||
3232 | 78 | journal_id = model_obj.browse(self.cr, self.uid,journal).res_id | ||
3233 | 79 | journal_seller = model_obj._get_id(self.cr, self.uid, 'account', 'expenses_journal') | ||
3234 | 80 | journal_seller_id = model_obj.browse(self.cr, self.uid,journal_seller).res_id | ||
3235 | 81 | account_analytic = model_obj._get_id(self.cr, self.uid, 'account', 'analytic_absences') | ||
3236 | 82 | account_analytic_id = model_obj.browse(self.cr, self.uid,account_analytic).res_id | ||
3237 | 83 | product = model_obj._get_id(self.cr, self.uid, 'auction', 'monproduit') | ||
3238 | 84 | product_id = model_obj.browse(self.cr, self.uid,product).res_id | ||
3239 | 85 | auction_tax = model_obj._get_id(self.cr, self.uid, 'auction', 'auction_tax') | ||
3240 | 86 | auction_tax_id = model_obj.browse(self.cr, self.uid,auction_tax).res_id | ||
3241 | 87 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
3242 | 88 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
3243 | 89 | analytic_journal = model_obj._get_id(self.cr,self.uid, 'account', 'cose_journal_sale') | ||
3244 | 90 | analytic_journal_id = model_obj.browse(self.cr, self.uid, analytic_journal,).res_id | ||
3245 | 91 | |||
3246 | 92 | |||
3247 | 93 | auction_date_id = self.auction_dates.create(self.cr,self.uid,{'name':'Furniture Exhibition', | ||
3248 | 94 | 'expo1':time.strftime('%Y-%m-01'),'expo2':time.strftime('%Y-%m-20'), | ||
3249 | 95 | 'auction1':time.strftime('%Y-%m-21'),'auction2':time.strftime('%Y-%m-29'), | ||
3250 | 96 | 'buyer_costs':[(6,0,[buyer_costs_id.id])], | ||
3251 | 97 | 'seller_costs':[(6,0,[seller_costs_id.id])], | ||
3252 | 98 | 'acc_income':acc_income_id, | ||
3253 | 99 | 'acc_expense':acc_expense_id, | ||
3254 | 100 | 'journal_id':journal_id, | ||
3255 | 101 | 'journal_seller_id':journal_seller_id, | ||
3256 | 102 | 'account_analytic_id':account_analytic_id}) | ||
3257 | 103 | |||
3258 | 104 | auction_deposit_id = self.auction_deposit.create(self.cr,self.uid,{'date_dep':time.strftime('%Y-4-20'), | ||
3259 | 105 | 'partner_id':partner_id, | ||
3260 | 106 | 'method':'keep',}) | ||
3261 | 107 | |||
3262 | 108 | auction_lots_id = self.auction_lots.create(self.cr,self.uid,{'name':'Golden sofa', | ||
3263 | 109 | 'auction_id':auction_date_id, | ||
3264 | 110 | 'lot_num':1,'lot_est1':10000,'lot_est2':20000, | ||
3265 | 111 | 'obj_desc':'Coverd by gold sheet','obj_ret':9000, | ||
3266 | 112 | 'obj_num':21,'obj_price':9500,'bord_vnd_id':auction_deposit_id, | ||
3267 | 113 | 'product_id':product_id,'author_right':auction_tax_id, | ||
3268 | 114 | 'ach_login':'admin', | ||
3269 | 115 | 'ach_uid':partner_id}) | ||
3270 | 116 | |||
3271 | 117 | self.pool.get('account.journal').write(self.cr,self.uid,[analytic_journal_id], | ||
3272 | 118 | {'analytic_journal_id' :analytic_journal_id}) | ||
3273 | 119 | except osv.except_osv,e: | ||
3274 | 120 | self.fail(e.name + e.value) | ||
3275 | 121 | except Exception,e: | ||
3276 | 122 | self.fail(e) | ||
3277 | 123 | |||
3278 | 124 | def test_2_SoldObject(self): | ||
3279 | 125 | try: | ||
3280 | 126 | self.failUnless(auction_lots_id,"No auction lots Created !") | ||
3281 | 127 | self.auction_lots.button_bought(self.cr,self.uid,auction_lots_id) | ||
3282 | 128 | except osv.except_osv,e: | ||
3283 | 129 | self.fail(e.name + e.value) | ||
3284 | 130 | except Exception,e: | ||
3285 | 131 | self.fail(e) | ||
3286 | 132 | |||
3287 | 133 | def test_3_NotSoldObject(self): | ||
3288 | 134 | try: | ||
3289 | 135 | self.failUnless(auction_lots_id,"No auction lots Created !") | ||
3290 | 136 | self.auction_lots.button_not_bought(self.cr,self.uid,auction_lots_id) | ||
3291 | 137 | except osv.except_osv,e: | ||
3292 | 138 | self.fail(e.name + e.value) | ||
3293 | 139 | except Exception,e: | ||
3294 | 140 | self.fail(e) | ||
3295 | 141 | |||
3296 | 142 | def test_4_SetToDraftObject(self): | ||
3297 | 143 | try: | ||
3298 | 144 | self.failUnless(auction_lots_id,"No auction lots Created !") | ||
3299 | 145 | self.auction_lots.button_draft(self.cr,self.uid,auction_lots_id) | ||
3300 | 146 | except osv.except_osv,e: | ||
3301 | 147 | self.fail(e.name + e.value) | ||
3302 | 148 | except Exception,e: | ||
3303 | 149 | self.fail(e) | ||
3304 | 150 | |||
3305 | 151 | def test_5_TakenAwayObject(self): | ||
3306 | 152 | try: | ||
3307 | 153 | self.failUnless(auction_lots_id,"No auction lots Created !") | ||
3308 | 154 | self.auction_lots.button_taken_away(self.cr,self.uid,auction_lots_id) | ||
3309 | 155 | except osv.except_osv,e: | ||
3310 | 156 | self.fail(e.name + e.value) | ||
3311 | 157 | except Exception,e: | ||
3312 | 158 | self.fail(e) | ||
3313 | 159 | |||
3314 | 160 | def test_6_PrintOrder(self): | ||
3315 | 161 | try: | ||
3316 | 162 | self.failUnless(auction_lots_id,"No auction lots Created !") | ||
3317 | 163 | self.cr.commit() | ||
3318 | 164 | report_service = netsvc.ExportService.getService('report') | ||
3319 | 165 | report_service.exp_report(self.cr.dbname, self.uid, 'report.auction.ach_bordereau', [auction_lots_id]) | ||
3320 | 166 | except osv.except_osv,e: | ||
3321 | 167 | self.fail(e.name + e.value) | ||
3322 | 168 | except Exception,e: | ||
3323 | 169 | self.fail(e) | ||
3324 | 170 | |||
3325 | 171 | def test_7_Unlink(self): | ||
3326 | 172 | try: | ||
3327 | 173 | self.failUnless(auction_lots_id,"No auction lots Created !") | ||
3328 | 174 | self.failUnless(auction_deposit_id,"No auction deposit Created !") | ||
3329 | 175 | self.failUnless(auction_date_id,"No auction date Created !") | ||
3330 | 176 | self.auction_lots.unlink(self.cr,self.uid,[auction_lots_id]) | ||
3331 | 177 | self.auction_deposit.unlink(self.cr,self.uid,[auction_deposit_id]) | ||
3332 | 178 | self.auction_dates.unlink(self.cr,self.uid,[auction_date_id]) | ||
3333 | 179 | except osv.except_osv,e: | ||
3334 | 180 | self.fail(e.name + e.value) | ||
3335 | 181 | except Exception,e: | ||
3336 | 182 | self.fail(e) | ||
3337 | 183 | |||
3338 | 184 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3339 | 0 | 185 | ||
3340 | === added directory 'audittrail/unit_test' | |||
3341 | === added file 'audittrail/unit_test/__init__.py' | |||
3342 | --- audittrail/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
3343 | +++ audittrail/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
3344 | @@ -0,0 +1,22 @@ | |||
3345 | 1 | # -*- coding: utf-8 -*- | ||
3346 | 2 | ############################################################################## | ||
3347 | 3 | # | ||
3348 | 4 | # OpenERP, Open Source Management Solution | ||
3349 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
3350 | 6 | # | ||
3351 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3352 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3353 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3354 | 10 | # License, or (at your option) any later version. | ||
3355 | 11 | # | ||
3356 | 12 | # This program is distributed in the hope that it will be useful, | ||
3357 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3358 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3359 | 15 | # GNU Affero General Public License for more details. | ||
3360 | 16 | # | ||
3361 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3362 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3363 | 19 | # | ||
3364 | 20 | ############################################################################## | ||
3365 | 21 | |||
3366 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3367 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
3368 | 1 | 24 | ||
3369 | === added file 'audittrail/unit_test/test.py' | |||
3370 | --- audittrail/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
3371 | +++ audittrail/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
3372 | @@ -0,0 +1,103 @@ | |||
3373 | 1 | # -*- coding: utf-8 -*- | ||
3374 | 2 | ############################################################################## | ||
3375 | 3 | # | ||
3376 | 4 | # OpenERP, Open Source Management Solution | ||
3377 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
3378 | 6 | # | ||
3379 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3380 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3381 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3382 | 10 | # License, or (at your option) any later version. | ||
3383 | 11 | # | ||
3384 | 12 | # This program is distributed in the hope that it will be useful, | ||
3385 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3386 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3387 | 15 | # GNU Affero General Public License for more details. | ||
3388 | 16 | # | ||
3389 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3390 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3391 | 19 | # | ||
3392 | 20 | ############################################################################## | ||
3393 | 21 | import unittest | ||
3394 | 22 | import pooler | ||
3395 | 23 | import netsvc | ||
3396 | 24 | from osv import osv | ||
3397 | 25 | |||
3398 | 26 | class audittrail_test_case(unittest.TestCase): | ||
3399 | 27 | |||
3400 | 28 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
3401 | 29 | self.cr = cursor | ||
3402 | 30 | self.uid = user | ||
3403 | 31 | unittest.TestCase.__init__(self, methodName) | ||
3404 | 32 | |||
3405 | 33 | def setUp(self): | ||
3406 | 34 | try: | ||
3407 | 35 | self.pool = pooler.get_pool(self.cr.dbname) | ||
3408 | 36 | self.audittrail_rule = self.pool.get('audittrail.rule') | ||
3409 | 37 | self.audittrail_log=self.pool.get('audittrail.log') | ||
3410 | 38 | self.audittrail_log_line=self.pool.get('audittrail.log.line') | ||
3411 | 39 | except osv.except_osv,e: | ||
3412 | 40 | self.fail(e.name + e.value) | ||
3413 | 41 | except Exception,e: | ||
3414 | 42 | self.fail(e) | ||
3415 | 43 | |||
3416 | 44 | def tearDown(self): | ||
3417 | 45 | try: | ||
3418 | 46 | self.pool = None | ||
3419 | 47 | self.audittrail_rule = None | ||
3420 | 48 | self.audittrail_log = None | ||
3421 | 49 | self.audittrail_log_line= None | ||
3422 | 50 | except osv.except_osv,e: | ||
3423 | 51 | self.fail(e.name + e.value) | ||
3424 | 52 | except Exception,e: | ||
3425 | 53 | self.fail(e) | ||
3426 | 54 | |||
3427 | 55 | def test_1_Create(self): | ||
3428 | 56 | |||
3429 | 57 | try: | ||
3430 | 58 | global rule_id | ||
3431 | 59 | objects = self.pool.get('ir.model').search(self.cr,self.uid,[('name','=','Fields')]) | ||
3432 | 60 | objects_id = self.pool.get('ir.model').browse(self.cr,self.uid, objects)[0] | ||
3433 | 61 | user_ids=self.pool.get('res.users').search(self.cr,self.uid,[]) | ||
3434 | 62 | rule_id=self.audittrail_rule.create(self.cr,self.uid,{'name':'New Log', | ||
3435 | 63 | 'object_id':objects_id.id, | ||
3436 | 64 | 'user_id':[(6,0,user_ids)], | ||
3437 | 65 | 'log_read':True, | ||
3438 | 66 | 'log_write':True, | ||
3439 | 67 | 'log_unlink':True, | ||
3440 | 68 | 'log_create':True, | ||
3441 | 69 | 'state':'draft'}) | ||
3442 | 70 | |||
3443 | 71 | except osv.except_osv,e: | ||
3444 | 72 | self.fail(e.name + e.value) | ||
3445 | 73 | except Exception,e: | ||
3446 | 74 | self.fail(e) | ||
3447 | 75 | |||
3448 | 76 | def test_2_Subscribe(self): | ||
3449 | 77 | try: | ||
3450 | 78 | self.failUnless(rule_id,"No rule Created !") | ||
3451 | 79 | self.audittrail_rule.subscribe(self.cr,self.uid,[rule_id]) | ||
3452 | 80 | except osv.except_osv,e: | ||
3453 | 81 | self.fail(e.name + e.value) | ||
3454 | 82 | except Exception,e: | ||
3455 | 83 | self.fail(e) | ||
3456 | 84 | |||
3457 | 85 | def test_3_Unsubscribe(self): | ||
3458 | 86 | try: | ||
3459 | 87 | self.failUnless(rule_id,"No rule Created !") | ||
3460 | 88 | self.audittrail_rule.unsubscribe(self.cr,self.uid,[rule_id]) | ||
3461 | 89 | except osv.except_osv,e: | ||
3462 | 90 | self.fail(e.name + e.value) | ||
3463 | 91 | except Exception,e: | ||
3464 | 92 | self.fail(e) | ||
3465 | 93 | |||
3466 | 94 | def test_4_Unlink(self): | ||
3467 | 95 | try: | ||
3468 | 96 | self.failUnless(rule_id,"No rule Created !") | ||
3469 | 97 | self.audittrail_rule.unlink(self.cr,self.uid,[rule_id]) | ||
3470 | 98 | except osv.except_osv,e: | ||
3471 | 99 | self.fail(e.name + e.value) | ||
3472 | 100 | except Exception,e: | ||
3473 | 101 | self.fail(e) | ||
3474 | 102 | |||
3475 | 103 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3476 | 0 | 104 | ||
3477 | === modified file 'base_module_quality/unit_test/__init__.py' | |||
3478 | --- base_module_quality/unit_test/__init__.py 2010-01-12 09:18:39 +0000 | |||
3479 | +++ base_module_quality/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
3480 | @@ -2,23 +2,25 @@ | |||
3481 | 2 | ############################################################################## | 2 | ############################################################################## |
3482 | 3 | # | 3 | # |
3483 | 4 | # OpenERP, Open Source Management Solution | 4 | # OpenERP, Open Source Management Solution |
3484 | 5 | <<<<<<< TREE | ||
3485 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved | 6 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
3486 | 6 | # $Id$ | 7 | # $Id$ |
3487 | 8 | ======= | ||
3488 | 9 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
3489 | 10 | >>>>>>> MERGE-SOURCE | ||
3490 | 7 | # | 11 | # |
3491 | 8 | # This program is free software: you can redistribute it and/or modify | 12 | # This program is free software: you can redistribute it and/or modify |
3495 | 9 | # it under the terms of the GNU General Public License as published by | 13 | # it under the terms of the GNU Affero General Public License as |
3496 | 10 | # the Free Software Foundation, either version 3 of the License, or | 14 | # published by the Free Software Foundation, either version 3 of the |
3497 | 11 | # (at your option) any later version. | 15 | # License, or (at your option) any later version. |
3498 | 12 | # | 16 | # |
3499 | 13 | # This program is distributed in the hope that it will be useful, | 17 | # This program is distributed in the hope that it will be useful, |
3500 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3501 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3503 | 16 | # GNU General Public License for more details. | 20 | # GNU Affero General Public License for more details. |
3504 | 17 | # | 21 | # |
3506 | 18 | # You should have received a copy of the GNU General Public License | 22 | # You should have received a copy of the GNU Affero General Public License |
3507 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 23 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
3508 | 20 | # | 24 | # |
3509 | 21 | ############################################################################## | 25 | ############################################################################## |
3510 | 22 | |||
3511 | 23 | |||
3512 | 24 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 26 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
3513 | 25 | 27 | ||
3514 | === modified file 'base_module_quality/unit_test/unit_test.py' | |||
3515 | --- base_module_quality/unit_test/unit_test.py 2010-02-24 10:55:29 +0000 | |||
3516 | +++ base_module_quality/unit_test/unit_test.py 2010-03-08 07:28:31 +0000 | |||
3517 | @@ -1,6 +1,7 @@ | |||
3518 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
3519 | 2 | ############################################################################## | 2 | ############################################################################## |
3520 | 3 | # | 3 | # |
3521 | 4 | <<<<<<< TREE | ||
3522 | 4 | # OpenERP, Open Source Management Solution | 5 | # OpenERP, Open Source Management Solution |
3523 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved | 6 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
3524 | 6 | # $Id$ | 7 | # $Id$ |
3525 | @@ -17,98 +18,160 @@ | |||
3526 | 17 | # | 18 | # |
3527 | 18 | # You should have received a copy of the GNU General Public License | 19 | # You should have received a copy of the GNU General Public License |
3528 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
3529 | 21 | ======= | ||
3530 | 22 | # OpenERP, Open Source Management Solution | ||
3531 | 23 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
3532 | 24 | # | ||
3533 | 25 | # This program is free software: you can redistribute it and/or modify | ||
3534 | 26 | # it under the terms of the GNU Affero General Public License as | ||
3535 | 27 | # published by the Free Software Foundation, either version 3 of the | ||
3536 | 28 | # License, or (at your option) any later version. | ||
3537 | 29 | # | ||
3538 | 30 | # This program is distributed in the hope that it will be useful, | ||
3539 | 31 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3540 | 32 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3541 | 33 | # GNU Affero General Public License for more details. | ||
3542 | 34 | # | ||
3543 | 35 | # You should have received a copy of the GNU Affero General Public License | ||
3544 | 36 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3545 | 37 | >>>>>>> MERGE-SOURCE | ||
3546 | 20 | # | 38 | # |
3547 | 21 | ############################################################################## | 39 | ############################################################################## |
3548 | 22 | import os | 40 | import os |
3550 | 23 | 41 | import unittest | |
3551 | 24 | from osv import fields, osv | 42 | from osv import fields, osv |
3552 | 25 | from tools.translate import _ | 43 | from tools.translate import _ |
3553 | 26 | import pooler | 44 | import pooler |
3554 | 27 | from tools import config | 45 | from tools import config |
3555 | 46 | from cStringIO import StringIO | ||
3556 | 28 | from base_module_quality import base_module_quality | 47 | from base_module_quality import base_module_quality |
3557 | 48 | import types | ||
3558 | 49 | |||
3559 | 50 | class OpenERPTestLoader(unittest.TestLoader): | ||
3560 | 51 | |||
3561 | 52 | def loadTestsFromTestCase(self, testCaseClass,cursor=False,user=False): | ||
3562 | 53 | """Return a suite of all tests cases contained in testCaseClass""" | ||
3563 | 54 | if issubclass(testCaseClass, unittest.TestSuite): | ||
3564 | 55 | raise TypeError("Test cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?") | ||
3565 | 56 | testCaseNames = self.getTestCaseNames(testCaseClass) | ||
3566 | 57 | if not testCaseNames and hasattr(testCaseClass, 'runTest'): | ||
3567 | 58 | testCaseNames = ['runTest'] | ||
3568 | 59 | return self.suiteClass(map(testCaseClass, [cursor]*len(testCaseNames),[user]*len(testCaseNames),testCaseNames)) | ||
3569 | 60 | |||
3570 | 61 | |||
3571 | 29 | 62 | ||
3572 | 30 | class quality_test(base_module_quality.abstract_quality_check): | 63 | class quality_test(base_module_quality.abstract_quality_check): |
3573 | 31 | 64 | ||
3579 | 32 | def __init__(self): | 65 | def __init__(self): |
3580 | 33 | super(quality_test, self).__init__() | 66 | super(quality_test, self).__init__() |
3581 | 34 | self.bool_installed_only = True | 67 | self.bool_installed_only = True |
3582 | 35 | self.name = _("Unit Test") | 68 | self.name = _("Unit Test") |
3583 | 36 | self.note = _(""" | 69 | self.note = _(""" |
3584 | 37 | This test checks the Unit Test(PyUnit) Cases of the module. Note that 'unit_test/test.py' is needed in module. | 70 | This test checks the Unit Test(PyUnit) Cases of the module. Note that 'unit_test/test.py' is needed in module. |
3585 | 38 | 71 | ||
3586 | 39 | """) | 72 | """) |
3587 | 40 | self.min_score = 0 | ||
3588 | 41 | self.message = 'This test does not calculate score' | ||
3589 | 42 | self.bool_count_score = False | ||
3590 | 43 | return None | ||
3591 | 44 | |||
3592 | 45 | def run_test(self, cr, uid, module_path): | ||
3593 | 46 | pool = pooler.get_pool(cr.dbname) | ||
3594 | 47 | module_name = module_path.split('/')[-1] | ||
3595 | 48 | test_file = config['addons_path'] +'/' + module_name +'/unit_test/test.py' | ||
3596 | 49 | if not os.path.isfile(test_file): | ||
3597 | 50 | self.result += _("Module does not have 'unit_test/test.py' file") | ||
3598 | 51 | return None | ||
3599 | 52 | module_obj = pool.get('ir.module.module') | ||
3600 | 53 | module_ids = module_obj.search(cr, uid, [('name', '=', module_name)]) | ||
3601 | 54 | module = module_obj.browse(cr, uid, module_ids) | ||
3602 | 55 | if not len(module): | ||
3603 | 56 | self.result += _("Error! Module is not properly loaded/installed") | ||
3604 | 57 | return None | ||
3605 | 58 | module = module[0] | ||
3606 | 59 | test = module.name + '.' + 'unit_test.test' | ||
3607 | 60 | test_module = __import__(test) | ||
3608 | 61 | test_file = getattr(test_module, 'unit_test') | ||
3609 | 62 | test_obj = getattr(test_file, 'test') | ||
3610 | 63 | |||
3611 | 64 | test_result = test_obj.runTest(cr,uid) | ||
3612 | 65 | self.result = self.get_result(test_result) | ||
3613 | 66 | self.result_details += self.get_result_details(test_result) | ||
3614 | 67 | return None | ||
3615 | 68 | |||
3616 | 69 | def get_result(self, data_list): | ||
3617 | 70 | header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-40s \n', [_('Summary'), _('Status')]) | ||
3618 | 71 | result_unit = {} | ||
3619 | 72 | res_list = [] | ||
3620 | 73 | if data_list[0]: | ||
3621 | 74 | res = data_list[1].split('\n') | ||
3622 | 75 | res_list.append(res[-4:][0]) | ||
3623 | 76 | res_list.append(res[-4:][2]) | ||
3624 | 77 | result_unit['unit_test'] = res_list | ||
3625 | 78 | return self.format_table(header, data_list=result_unit) | ||
3626 | 79 | return "Unit Test Fail" | ||
3627 | 80 | |||
3628 | 81 | def get_result_details(self, data_list): | ||
3629 | 82 | detail = '''<html><head>%s</head><body><table class="tablestyle"> | ||
3630 | 83 | <tr><th class="tdatastyle">Test Cases</th ><th class="tdatastyle">Result</th>'''%(self.get_style()) | ||
3631 | 84 | html = '' | ||
3632 | 85 | |||
3633 | 86 | if data_list[0] == True: | ||
3634 | 87 | data = data_list[1].split('... ok') | ||
3635 | 88 | for case in map(lambda x:x[0].replace('\n',''),map(lambda x: x.split(' ('),data)): | ||
3636 | 89 | if case.find('Ran') != -1: | ||
3637 | 90 | case = case[case.index('Ran'):-2] | ||
3638 | 91 | html += '<tr><th class="tdatastyle">%s</th><th class="tdatastyle">OK</th></tr>'%(case) | ||
3639 | 92 | else: | ||
3640 | 93 | html += '<tr><td class="tdatastyle">%s</td><td class="tdatastyle">OK</td></tr>'%(case) | ||
3641 | 94 | res = detail + html + '</table></body></html>' | ||
3642 | 95 | return res | ||
3643 | 96 | else: | ||
3644 | 97 | detail_dict = {} | ||
3645 | 98 | detail += '''<th class="tdatastyle">Details</th></tr>''' | ||
3646 | 99 | data = data_list[1].split("======================================================================") | ||
3647 | 100 | test = data[0].split('\n') | ||
3648 | 101 | for err in (data_list[0].failures,data_list[0].errors): | ||
3649 | 102 | for value in err: | ||
3650 | 103 | detail_dict[value[0]._testMethodName] = value[1] | ||
3651 | 104 | for case in map(lambda x:x.split('...'), test): | ||
3652 | 105 | if len(case[0]) < 2: | ||
3653 | 106 | continue | ||
3654 | 107 | test_name = case[0].split(' (')[0] | ||
3655 | 108 | if not detail_dict.has_key(test_name): | ||
3656 | 109 | detail_dict[test_name] = '' | ||
3657 | 110 | html += '<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><td class="tdatastyle">%s</td></tr>'%(test_name, case[1], detail_dict[test_name]) | ||
3658 | 111 | return detail + html +'</tr></table></body></html>' | ||
3659 | 112 | return '' | ||
3660 | 113 | |||
3661 | 114 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3662 | 115 | \ No newline at end of file | 73 | \ No newline at end of file |
3663 | 74 | self.min_score = 0 | ||
3664 | 75 | self.message = 'This test does not calculate score' | ||
3665 | 76 | self.bool_count_score = False | ||
3666 | 77 | self.test_suite = [] | ||
3667 | 78 | return None | ||
3668 | 79 | |||
3669 | 80 | def run_test(self, cr, uid, module_path): | ||
3670 | 81 | pool = pooler.get_pool(cr.dbname) | ||
3671 | 82 | module_name = module_path.split('/')[-1] | ||
3672 | 83 | test_file = config['addons_path'] +'/' + module_name +'/unit_test/test.py' | ||
3673 | 84 | if not os.path.isfile(test_file): | ||
3674 | 85 | self.result += _("Module does not have 'unit_test/test.py' file") | ||
3675 | 86 | return None | ||
3676 | 87 | module_obj = pool.get('ir.module.module') | ||
3677 | 88 | module_ids = module_obj.search(cr, uid, [('name', '=', module_name)]) | ||
3678 | 89 | module = module_obj.browse(cr, uid, module_ids) | ||
3679 | 90 | if not len(module): | ||
3680 | 91 | self.result += _("Error! Module is not properly loaded/installed") | ||
3681 | 92 | return None | ||
3682 | 93 | module = module[0] | ||
3683 | 94 | test = module.name + '.' + 'unit_test.test' | ||
3684 | 95 | test_module = __import__(test) | ||
3685 | 96 | test_file = getattr(test_module, 'unit_test') | ||
3686 | 97 | test_obj = getattr(test_file, 'test') | ||
3687 | 98 | |||
3688 | 99 | out = StringIO() | ||
3689 | 100 | for name in dir(test_obj): | ||
3690 | 101 | obj = getattr(test_obj, name) | ||
3691 | 102 | if isinstance(obj, (type, types.ClassType)): | ||
3692 | 103 | testcase = obj | ||
3693 | 104 | if not issubclass(testcase, unittest.TestCase): | ||
3694 | 105 | self.result += _("Test cases should be derived from unittest.TestCase") | ||
3695 | 106 | return None | ||
3696 | 107 | |||
3697 | 108 | self.get_suites(cr,uid,testcase) | ||
3698 | 109 | suite = OpenERPTestLoader().loadTestsFromTestCase(testcase,cr,uid) | ||
3699 | 110 | self.test_suite.append(suite) | ||
3700 | 111 | finalsuite = unittest.TestSuite() | ||
3701 | 112 | for suite in self.test_suite: | ||
3702 | 113 | finalsuite.addTest(suite) | ||
3703 | 114 | res = unittest.TextTestRunner(stream=out,verbosity=2).run(finalsuite) | ||
3704 | 115 | if res.wasSuccessful(): | ||
3705 | 116 | test_result = (True,out.getvalue()) | ||
3706 | 117 | else: | ||
3707 | 118 | test_result = (res,out.getvalue()) | ||
3708 | 119 | self.result = self.get_result(test_result) | ||
3709 | 120 | self.result_details += self.get_result_details(test_result) | ||
3710 | 121 | return None | ||
3711 | 122 | |||
3712 | 123 | def get_suites(self,cr,uid,object): | ||
3713 | 124 | if 'third_party_cases' in dir(object): | ||
3714 | 125 | for testclass,case in object.third_party_cases.items(): | ||
3715 | 126 | self.get_suites(cr,uid,testclass) | ||
3716 | 127 | third_party_suite = unittest.TestSuite() | ||
3717 | 128 | for test in case: | ||
3718 | 129 | third_party_suite.addTest(testclass(cr,uid,test)) | ||
3719 | 130 | self.test_suite.append(third_party_suite) | ||
3720 | 131 | return True | ||
3721 | 132 | |||
3722 | 133 | def get_result(self, data_list): | ||
3723 | 134 | header = ('{| border="1" cellspacing="0" cellpadding="5" align="left" \n! %-40s \n! %-40s \n', [_('Summary'), _('Status')]) | ||
3724 | 135 | result_unit = {} | ||
3725 | 136 | res_list = [] | ||
3726 | 137 | if data_list[0]: | ||
3727 | 138 | res = data_list[1].split('\n') | ||
3728 | 139 | res_list.append(res[-4:][0]) | ||
3729 | 140 | res_list.append(res[-4:][2]) | ||
3730 | 141 | result_unit['unit_test'] = res_list | ||
3731 | 142 | return self.format_table(header, data_list=result_unit) | ||
3732 | 143 | return "Unit Test Fail" | ||
3733 | 144 | |||
3734 | 145 | def get_result_details(self, data_list): | ||
3735 | 146 | detail = '''<html><head>%s</head><body><table class="tablestyle"> | ||
3736 | 147 | <tr><th class="tdatastyle">Test Cases</th ><th class="tdatastyle">Result</th>'''%(self.get_style()) | ||
3737 | 148 | html = '' | ||
3738 | 149 | |||
3739 | 150 | if data_list[0] == True: | ||
3740 | 151 | data = data_list[1].split('... ok') | ||
3741 | 152 | for case in map(lambda x:x[0].replace('\n',''),map(lambda x: x.split(' ('),data)): | ||
3742 | 153 | if case.find('Ran') != -1: | ||
3743 | 154 | case = case[case.index('Ran'):-2] | ||
3744 | 155 | html += '<tr><th class="tdatastyle">%s</th><th class="tdatastyle">OK</th></tr>'%(case) | ||
3745 | 156 | else: | ||
3746 | 157 | html += '<tr><td class="tdatastyle">%s</td><td class="tdatastyle">OK</td></tr>'%(case) | ||
3747 | 158 | res = detail + html + '</table></body></html>' | ||
3748 | 159 | return res | ||
3749 | 160 | else: | ||
3750 | 161 | detail_dict = {} | ||
3751 | 162 | detail += '''<th class="tdatastyle">Details</th></tr>''' | ||
3752 | 163 | data = data_list[1].split("======================================================================") | ||
3753 | 164 | test = data[0].split('\n') | ||
3754 | 165 | for err in (data_list[0].failures,data_list[0].errors): | ||
3755 | 166 | for value in err: | ||
3756 | 167 | detail_dict[value[0]._testMethodName] = value[1] | ||
3757 | 168 | for case in map(lambda x:x.split('...'), test): | ||
3758 | 169 | if len(case[0]) < 2: | ||
3759 | 170 | continue | ||
3760 | 171 | test_name = case[0].split(' (')[0] | ||
3761 | 172 | if not detail_dict.has_key(test_name): | ||
3762 | 173 | detail_dict[test_name] = '' | ||
3763 | 174 | html += '<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><td class="tdatastyle">%s</td></tr>'%(test_name, case[1], detail_dict[test_name]) | ||
3764 | 175 | return detail + html +'</tr></table></body></html>' | ||
3765 | 176 | return '' | ||
3766 | 177 | |||
3767 | 178 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3768 | 116 | 179 | ||
3769 | === added directory 'crm/unit_test' | |||
3770 | === added file 'crm/unit_test/__init__.py' | |||
3771 | --- crm/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
3772 | +++ crm/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
3773 | @@ -0,0 +1,22 @@ | |||
3774 | 1 | # -*- coding: utf-8 -*- | ||
3775 | 2 | ############################################################################## | ||
3776 | 3 | # | ||
3777 | 4 | # OpenERP, Open Source Management Solution | ||
3778 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
3779 | 6 | # | ||
3780 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3781 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3782 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3783 | 10 | # License, or (at your option) any later version. | ||
3784 | 11 | # | ||
3785 | 12 | # This program is distributed in the hope that it will be useful, | ||
3786 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3787 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3788 | 15 | # GNU Affero General Public License for more details. | ||
3789 | 16 | # | ||
3790 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3791 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3792 | 19 | # | ||
3793 | 20 | ############################################################################## | ||
3794 | 21 | |||
3795 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3796 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
3797 | 1 | 24 | ||
3798 | === added file 'crm/unit_test/test.py' | |||
3799 | --- crm/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
3800 | +++ crm/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
3801 | @@ -0,0 +1,189 @@ | |||
3802 | 1 | # -*- coding: utf-8 -*- | ||
3803 | 2 | ############################################################################## | ||
3804 | 3 | # | ||
3805 | 4 | # OpenERP, Open Source Management Solution | ||
3806 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
3807 | 6 | # | ||
3808 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3809 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3810 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3811 | 10 | # License, or (at your option) any later version. | ||
3812 | 11 | # | ||
3813 | 12 | # This program is distributed in the hope that it will be useful, | ||
3814 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3815 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3816 | 15 | # GNU Affero General Public License for more details. | ||
3817 | 16 | # | ||
3818 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3819 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3820 | 19 | # | ||
3821 | 20 | ############################################################################## | ||
3822 | 21 | import unittest | ||
3823 | 22 | import pooler | ||
3824 | 23 | import netsvc | ||
3825 | 24 | from osv import osv | ||
3826 | 25 | |||
3827 | 26 | section_id = None | ||
3828 | 27 | case_category_id = None | ||
3829 | 28 | case_rule_id = None | ||
3830 | 29 | section_id_2 = None | ||
3831 | 30 | case_id = None | ||
3832 | 31 | segmentation_id = None | ||
3833 | 32 | segmentation_line_id = None | ||
3834 | 33 | |||
3835 | 34 | class crm_test_case(unittest.TestCase): | ||
3836 | 35 | |||
3837 | 36 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
3838 | 37 | self.cr = cursor | ||
3839 | 38 | self.uid = user | ||
3840 | 39 | unittest.TestCase.__init__(self, methodName) | ||
3841 | 40 | |||
3842 | 41 | def setUp(self): | ||
3843 | 42 | try: | ||
3844 | 43 | self.pool = pooler.get_pool(self.cr.dbname) | ||
3845 | 44 | self.crm_case_section = self.pool.get('crm.case.section') | ||
3846 | 45 | self.crm_case_categ = self.pool.get('crm.case.categ') | ||
3847 | 46 | self.crm_case_rule = self.pool.get('crm.case.rule') | ||
3848 | 47 | self.crm_case = self.pool.get('crm.case') | ||
3849 | 48 | self.crm_segmentation = self.pool.get('crm.segmentation') | ||
3850 | 49 | self.crm_segmentation_line = self.pool.get('crm.segmentation.line') | ||
3851 | 50 | except osv.except_osv,e: | ||
3852 | 51 | self.fail(e.name + e.value) | ||
3853 | 52 | except Exception,e: | ||
3854 | 53 | self.fail(e) | ||
3855 | 54 | |||
3856 | 55 | def tearDown(self): | ||
3857 | 56 | try: | ||
3858 | 57 | self.pool = None | ||
3859 | 58 | self.crm_case_section = None | ||
3860 | 59 | self.crm_case_categ = None | ||
3861 | 60 | self.crm_case_rule = None | ||
3862 | 61 | self.crm_case = None | ||
3863 | 62 | self.crm_segmentation = None | ||
3864 | 63 | self.crm_segmentation_line = None | ||
3865 | 64 | except osv.except_osv,e: | ||
3866 | 65 | self.fail(e.name + e.value) | ||
3867 | 66 | except Exception,e: | ||
3868 | 67 | self.fail(e) | ||
3869 | 68 | |||
3870 | 69 | def test_1_Create(self): | ||
3871 | 70 | try: | ||
3872 | 71 | global section_id,section_id_2,case_category_id,case_rule_id,case_id,segmentation_id,segmentation_line_id,partner_id,picking_ids,categ_id,res | ||
3873 | 72 | res = {} | ||
3874 | 73 | model_obj = self.pool.get('ir.model.data') | ||
3875 | 74 | |||
3876 | 75 | user = self.pool.get('res.users').search(self.cr,self.uid,[('name','=','Administrator')]) | ||
3877 | 76 | user_id = self.pool.get('res.users').browse(self.cr,self.uid,user)[0] | ||
3878 | 77 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
3879 | 78 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
3880 | 79 | partner_address = model_obj._get_id(self.cr, self.uid, 'base', 'res_partner_address_9') | ||
3881 | 80 | partner_address_id = model_obj.browse(self.cr, self.uid, partner_address).res_id | ||
3882 | 81 | categ = model_obj._get_id(self.cr, self.uid, 'base', 'res_partner_category_2') | ||
3883 | 82 | categ_id = model_obj.browse(self.cr, self.uid,categ).res_id | ||
3884 | 83 | |||
3885 | 84 | # Section | ||
3886 | 85 | section_id = self.crm_case_section.create(self.cr,self.uid,{'name':'My Section','code':'mysect', | ||
3887 | 86 | 'sequence':0,}) | ||
3888 | 87 | section_id_2 = self.crm_case_section.create(self.cr,self.uid,{'name':'My Client Section','code':'myclsect', | ||
3889 | 88 | 'sequence':0,}) | ||
3890 | 89 | # Case Category | ||
3891 | 90 | case_category_id = self.crm_case_categ.create(self.cr,self.uid,{'section_id':section_id,'name':'Client Installation'}) | ||
3892 | 91 | |||
3893 | 92 | # Case Rule | ||
3894 | 93 | case_rule_id = self.crm_case_rule.create(self.cr,self.uid,{'name':'My Rule','trg_state_from':'draft', | ||
3895 | 94 | 'trg_section_id':section_id, | ||
3896 | 95 | 'trg_user_id':user_id.id, | ||
3897 | 96 | 'act_state':'open','act_section_id':section_id_2}) | ||
3898 | 97 | |||
3899 | 98 | # CRM Case | ||
3900 | 99 | case_id = self.crm_case.create(self.cr,self.uid,{'name':'Client server problem','section_id':section_id, | ||
3901 | 100 | 'partner_id':partner_id,'partner_address_id':partner_address_id, | ||
3902 | 101 | 'user_id':user_id.id}) | ||
3903 | 102 | |||
3904 | 103 | ## Segmentation | ||
3905 | 104 | segmentation_id = self.crm_segmentation.create(self.cr,self.uid,{'name':'My Segmentation', | ||
3906 | 105 | 'description':'Developing new segmentation for the client', | ||
3907 | 106 | 'categ_id':categ_id}) | ||
3908 | 107 | |||
3909 | 108 | segmentation_line_id = self.crm_segmentation_line.create(self.cr,self.uid,{'segmentation_id':segmentation_id, | ||
3910 | 109 | 'name':'My segment line', | ||
3911 | 110 | 'expr_name':'sale', | ||
3912 | 111 | 'expr_operator':'>', | ||
3913 | 112 | 'expr_value':500,'operator':'and'}) | ||
3914 | 113 | |||
3915 | 114 | except osv.except_osv,e: | ||
3916 | 115 | self.fail(e.name + e.value) | ||
3917 | 116 | except Exception,e: | ||
3918 | 117 | self.fail(e) | ||
3919 | 118 | |||
3920 | 119 | |||
3921 | 120 | def test_2_CaseOpen(self): | ||
3922 | 121 | try: | ||
3923 | 122 | self.failUnless(case_id,"No Case Created !") | ||
3924 | 123 | self.crm_case.case_open(self.cr,self.uid,[case_id]) | ||
3925 | 124 | except osv.except_osv,e: | ||
3926 | 125 | self.fail(e.name + e.value) | ||
3927 | 126 | except Exception,e: | ||
3928 | 127 | self.fail(e) | ||
3929 | 128 | |||
3930 | 129 | def test_3_CasePending(self): | ||
3931 | 130 | try: | ||
3932 | 131 | self.failUnless(case_id,"No Case Created !") | ||
3933 | 132 | self.crm_case.case_pending(self.cr,self.uid,[case_id]) | ||
3934 | 133 | except osv.except_osv,e: | ||
3935 | 134 | self.fail(e.name + e.value) | ||
3936 | 135 | except Exception,e: | ||
3937 | 136 | self.fail(e) | ||
3938 | 137 | |||
3939 | 138 | def test_4_CaseClose(self): | ||
3940 | 139 | try: | ||
3941 | 140 | self.failUnless(case_id,"No Case Created !") | ||
3942 | 141 | self.crm_case.case_close(self.cr,self.uid,[case_id]) | ||
3943 | 142 | except osv.except_osv,e: | ||
3944 | 143 | self.fail(e.name + e.value) | ||
3945 | 144 | except Exception,e: | ||
3946 | 145 | self.fail(e) | ||
3947 | 146 | |||
3948 | 147 | def test_5_CaseReset(self): | ||
3949 | 148 | try: | ||
3950 | 149 | self.failUnless(case_id,"No Case Created !") | ||
3951 | 150 | self.crm_case.case_reset(self.cr,self.uid,[case_id]) | ||
3952 | 151 | except osv.except_osv,e: | ||
3953 | 152 | self.fail(e.name + e.value) | ||
3954 | 153 | except Exception,e: | ||
3955 | 154 | self.fail(e) | ||
3956 | 155 | |||
3957 | 156 | def test_6_SegmentationProcessStrat(self): | ||
3958 | 157 | try: | ||
3959 | 158 | self.failUnless(segmentation_id,"No Segmentation Created !") | ||
3960 | 159 | self.crm_segmentation.process_start(self.cr,self.uid,[segmentation_id]) | ||
3961 | 160 | except osv.except_osv,e: | ||
3962 | 161 | self.fail(e.name + e.value) | ||
3963 | 162 | except Exception,e: | ||
3964 | 163 | self.fail(e) | ||
3965 | 164 | |||
3966 | 165 | def test_7_RemoveCategory(self): | ||
3967 | 166 | try: | ||
3968 | 167 | self.failUnless(case_id,"No Case Created !") | ||
3969 | 168 | self.cr.execute("delete from res_partner_category_rel where partner_id = %s and category_id = %s", (partner_id,categ_id)) | ||
3970 | 169 | except osv.except_osv,e: | ||
3971 | 170 | self.fail(e.name + e.value) | ||
3972 | 171 | except Exception,e: | ||
3973 | 172 | self.fail(e) | ||
3974 | 173 | |||
3975 | 174 | def test_8_Unlink(self): | ||
3976 | 175 | try: | ||
3977 | 176 | self.failUnless(case_id,"No Case Created !") | ||
3978 | 177 | self.crm_case.unlink(self.cr,self.uid,[case_id]) | ||
3979 | 178 | self.crm_case_rule.unlink(self.cr,self.uid,[case_rule_id]) | ||
3980 | 179 | self.crm_case_categ.unlink(self.cr,self.uid,[case_category_id]) | ||
3981 | 180 | self.crm_case_section.unlink(self.cr,self.uid,[section_id_2]) | ||
3982 | 181 | self.crm_case_section.unlink(self.cr,self.uid,[section_id]) | ||
3983 | 182 | self.crm_segmentation_line.unlink(self.cr,self.uid,[segmentation_line_id]) | ||
3984 | 183 | self.crm_segmentation.unlink(self.cr,self.uid,[segmentation_id]) | ||
3985 | 184 | except osv.except_osv,e: | ||
3986 | 185 | self.fail(e.name + e.value) | ||
3987 | 186 | except Exception,e: | ||
3988 | 187 | self.fail(e) | ||
3989 | 188 | |||
3990 | 189 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3991 | 0 | 190 | ||
3992 | === added directory 'crm_configuration' | |||
3993 | === added directory 'crm_configuration/unit_test' | |||
3994 | === added file 'crm_configuration/unit_test/__init__.py' | |||
3995 | --- crm_configuration/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
3996 | +++ crm_configuration/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
3997 | @@ -0,0 +1,22 @@ | |||
3998 | 1 | # -*- coding: utf-8 -*- | ||
3999 | 2 | ############################################################################## | ||
4000 | 3 | # | ||
4001 | 4 | # OpenERP, Open Source Management Solution | ||
4002 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4003 | 6 | # | ||
4004 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4005 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4006 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4007 | 10 | # License, or (at your option) any later version. | ||
4008 | 11 | # | ||
4009 | 12 | # This program is distributed in the hope that it will be useful, | ||
4010 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4011 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4012 | 15 | # GNU Affero General Public License for more details. | ||
4013 | 16 | # | ||
4014 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4015 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4016 | 19 | # | ||
4017 | 20 | ############################################################################## | ||
4018 | 21 | |||
4019 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4020 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
4021 | 1 | 24 | ||
4022 | === added file 'crm_configuration/unit_test/test.py' | |||
4023 | --- crm_configuration/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
4024 | +++ crm_configuration/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
4025 | @@ -0,0 +1,165 @@ | |||
4026 | 1 | # -*- coding: utf-8 -*- | ||
4027 | 2 | ############################################################################## | ||
4028 | 3 | # | ||
4029 | 4 | # OpenERP, Open Source Management Solution | ||
4030 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4031 | 6 | # | ||
4032 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4033 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4034 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4035 | 10 | # License, or (at your option) any later version. | ||
4036 | 11 | # | ||
4037 | 12 | # This program is distributed in the hope that it will be useful, | ||
4038 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4039 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4040 | 15 | # GNU Affero General Public License for more details. | ||
4041 | 16 | # | ||
4042 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4043 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4044 | 19 | # | ||
4045 | 20 | ############################################################################## | ||
4046 | 21 | |||
4047 | 22 | import unittest | ||
4048 | 23 | import pooler | ||
4049 | 24 | import netsvc | ||
4050 | 25 | from osv import osv | ||
4051 | 26 | import time | ||
4052 | 27 | import crm.unit_test.test as crm | ||
4053 | 28 | |||
4054 | 29 | |||
4055 | 30 | meeting_stage_id = [] | ||
4056 | 31 | oppor_stage_id = [] | ||
4057 | 32 | meeting_section_id = None | ||
4058 | 33 | opportunity_section_id = None | ||
4059 | 34 | |||
4060 | 35 | class crm_configuration_test_case(unittest.TestCase): | ||
4061 | 36 | |||
4062 | 37 | third_party_cases={crm.crm_test_case: ['test_1_Create']} | ||
4063 | 38 | |||
4064 | 39 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
4065 | 40 | self.cr = cursor | ||
4066 | 41 | self.uid = user | ||
4067 | 42 | unittest.TestCase.__init__(self, methodName) | ||
4068 | 43 | |||
4069 | 44 | def setUp(self): | ||
4070 | 45 | try: | ||
4071 | 46 | self.pool = pooler.get_pool(self.cr.dbname) | ||
4072 | 47 | self.crm_case_stage = self.pool.get('crm.case.stage') | ||
4073 | 48 | self.crm_case_section = self.pool.get('crm.case.section') | ||
4074 | 49 | self.crm_case_categ = self.pool.get('crm.case.categ') | ||
4075 | 50 | self.crm_case_rule = self.pool.get('crm.case.rule') | ||
4076 | 51 | self.crm_case = self.pool.get('crm.case') | ||
4077 | 52 | self.crm_segmentation = self.pool.get('crm.segmentation') | ||
4078 | 53 | self.crm_segmentation_line = self.pool.get('crm.segmentation.line') | ||
4079 | 54 | |||
4080 | 55 | except osv.except_osv,e: | ||
4081 | 56 | self.fail(e.name + e.value) | ||
4082 | 57 | except Exception,e: | ||
4083 | 58 | self.fail(e) | ||
4084 | 59 | |||
4085 | 60 | def tearDown(self): | ||
4086 | 61 | try: | ||
4087 | 62 | self.pool = None | ||
4088 | 63 | self.crm_case_stage = None | ||
4089 | 64 | self.crm_case = None | ||
4090 | 65 | self.crm_case_section | ||
4091 | 66 | self.crm_case_categ = None | ||
4092 | 67 | self.crm_case_rule = None | ||
4093 | 68 | self.crm_segmentation = None | ||
4094 | 69 | self.crm_segmentation_line = None | ||
4095 | 70 | except osv.except_osv,e: | ||
4096 | 71 | self.fail(e.name + e.value) | ||
4097 | 72 | except Exception,e: | ||
4098 | 73 | self.fail(e) | ||
4099 | 74 | |||
4100 | 75 | def test_1_create(self): | ||
4101 | 76 | try: | ||
4102 | 77 | global meeting_stage_id,meeting_section_id,opportunity_section_id,oppor_stage_id | ||
4103 | 78 | meeting_stage_id = [] | ||
4104 | 79 | oppor_stage_id = [] | ||
4105 | 80 | |||
4106 | 81 | meeting_section_id = self.crm_case_section.create(self.cr,self.uid,{'name':'Meeting','code':'Mtngs','sequence':0}) | ||
4107 | 82 | opportunity_section_id = self.crm_case_section.create(self.cr,self.uid,{'name':'Opportunity','code':'oppor','sequence':0}) | ||
4108 | 83 | for name in ['Fixed','Not Fixed']: | ||
4109 | 84 | meeting = self.crm_case_stage.create(self.cr,self.uid,{'name':name,'section_id':meeting_section_id}) | ||
4110 | 85 | meeting_stage_id.append(meeting) | ||
4111 | 86 | oppor = self.crm_case_stage.create(self.cr,self.uid,{'name':name,'section_id':opportunity_section_id}) | ||
4112 | 87 | oppor_stage_id.append(oppor) | ||
4113 | 88 | self.crm_case.write(self.cr,self.uid,[crm.case_id],vals = {'partner_name':'New Client '}) | ||
4114 | 89 | except osv.except_osv,e: | ||
4115 | 90 | self.fail(e.name + e.value) | ||
4116 | 91 | except Exception,e: | ||
4117 | 92 | self.fail(e) | ||
4118 | 93 | |||
4119 | 94 | def test_2_createPartner(self): | ||
4120 | 95 | try: | ||
4121 | 96 | self.cr.commit() | ||
4122 | 97 | self.failUnless(meeting_stage_id,"No Case Stage Created !") | ||
4123 | 98 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4124 | 99 | wizard_res = wizard_service.exp_create(self.cr.dbname,self.uid, 'crm.case.partner_create') | ||
4125 | 100 | datas = {'form': {'close': 0}, 'ids': [crm.case_id],'id': crm.case_id } | ||
4126 | 101 | state = 'confirm' | ||
4127 | 102 | wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4128 | 103 | except osv.except_osv,e: | ||
4129 | 104 | self.fail(e.name + e.value) | ||
4130 | 105 | except Exception,e: | ||
4131 | 106 | self.fail(e) | ||
4132 | 107 | |||
4133 | 108 | def test_3_createMeeting(self): | ||
4134 | 109 | try: | ||
4135 | 110 | self.cr.commit() | ||
4136 | 111 | self.failUnless(meeting_stage_id,"No Case Stage Created !") | ||
4137 | 112 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4138 | 113 | wizard_res = wizard_service.exp_create(self.cr.dbname,self.uid, 'crm.case.meeting') | ||
4139 | 114 | datas = {'form': {'date': time.strftime('%Y-%m-%d %H:%M:%S'), 'duration': 2.0}, 'ids': [crm.case_id], 'report_type': 'pdf', 'model': 'crm.case', 'id': crm.case_id} | ||
4140 | 115 | state = 'order' | ||
4141 | 116 | wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4142 | 117 | except osv.except_osv,e: | ||
4143 | 118 | self.fail(e.name + e.value) | ||
4144 | 119 | except Exception,e: | ||
4145 | 120 | self.fail(e) | ||
4146 | 121 | |||
4147 | 122 | def test_4_createOpportunity(self): | ||
4148 | 123 | try: | ||
4149 | 124 | self.cr.commit() | ||
4150 | 125 | self.failUnless(meeting_stage_id,"No Case Stage Created !") | ||
4151 | 126 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4152 | 127 | wizard_res = wizard_service.exp_create(self.cr.dbname,self.uid, 'crm.case.opportunity_set') | ||
4153 | 128 | state='init' | ||
4154 | 129 | datas={'form':{},'ids': [crm.case_id], 'report_type': 'pdf', 'model': 'crm.case', 'id':crm.case_id} | ||
4155 | 130 | while state != 'end': | ||
4156 | 131 | res = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4157 | 132 | if 'datas' in res: | ||
4158 | 133 | datas['form'].update( res['datas'].get('form',{}) ) | ||
4159 | 134 | if res['type']=='form': | ||
4160 | 135 | for field in res['fields'].keys(): | ||
4161 | 136 | datas['form'][field] = res['datas'][field] | ||
4162 | 137 | state = res['state'][-1][0] | ||
4163 | 138 | elif res['type']=='action': | ||
4164 | 139 | state = res['state'] | ||
4165 | 140 | except osv.except_osv,e: | ||
4166 | 141 | self.fail(e.name + e.value) | ||
4167 | 142 | except Exception,e: | ||
4168 | 143 | self.fail(e) | ||
4169 | 144 | |||
4170 | 145 | def test_5_Unlink(self): | ||
4171 | 146 | try: | ||
4172 | 147 | self.failUnless(meeting_stage_id,"No Case Stage Created !") | ||
4173 | 148 | self.crm_case.unlink(self.cr,self.uid,[crm.case_id]) | ||
4174 | 149 | self.crm_case_rule.unlink(self.cr,self.uid,[crm.case_rule_id]) | ||
4175 | 150 | self.crm_case_categ.unlink(self.cr,self.uid,[crm.case_category_id]) | ||
4176 | 151 | self.crm_case_section.unlink(self.cr,self.uid,[crm.section_id_2] + [crm.section_id]) | ||
4177 | 152 | self.crm_segmentation_line.unlink(self.cr,self.uid,[crm.segmentation_line_id]) | ||
4178 | 153 | self.crm_segmentation.unlink(self.cr,self.uid,[crm.segmentation_id]) | ||
4179 | 154 | self.crm_case_stage.unlink(self.cr,self.uid,meeting_stage_id) | ||
4180 | 155 | self.crm_case_stage.unlink(self.cr,self.uid,oppor_stage_id) | ||
4181 | 156 | sect = self.crm_case.search(self.cr,self.uid,[('section_id','in',[meeting_section_id,opportunity_section_id])]) | ||
4182 | 157 | self.crm_case.unlink(self.cr,self.uid,sect) | ||
4183 | 158 | self.crm_case_section.unlink(self.cr,self.uid,[meeting_section_id]+[opportunity_section_id]) | ||
4184 | 159 | self.pool.get('res.partner').unlink(self.cr,self.uid,[res['action']['res_id']]) | ||
4185 | 160 | except osv.except_osv,e: | ||
4186 | 161 | self.fail(e.name + e.value) | ||
4187 | 162 | except Exception,e: | ||
4188 | 163 | self.fail(e) | ||
4189 | 164 | |||
4190 | 165 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4191 | 0 | 166 | ||
4192 | === added directory 'crm_profiling/unit_test' | |||
4193 | === added file 'crm_profiling/unit_test/__init__.py' | |||
4194 | --- crm_profiling/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
4195 | +++ crm_profiling/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
4196 | @@ -0,0 +1,22 @@ | |||
4197 | 1 | # -*- coding: utf-8 -*- | ||
4198 | 2 | ############################################################################## | ||
4199 | 3 | # | ||
4200 | 4 | # OpenERP, Open Source Management Solution | ||
4201 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4202 | 6 | # | ||
4203 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4204 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4205 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4206 | 10 | # License, or (at your option) any later version. | ||
4207 | 11 | # | ||
4208 | 12 | # This program is distributed in the hope that it will be useful, | ||
4209 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4210 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4211 | 15 | # GNU Affero General Public License for more details. | ||
4212 | 16 | # | ||
4213 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4214 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4215 | 19 | # | ||
4216 | 20 | ############################################################################## | ||
4217 | 21 | |||
4218 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4219 | 0 | 23 | ||
4220 | === added file 'crm_profiling/unit_test/test.py' | |||
4221 | --- crm_profiling/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
4222 | +++ crm_profiling/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
4223 | @@ -0,0 +1,138 @@ | |||
4224 | 1 | # -*- coding: utf-8 -*- | ||
4225 | 2 | ############################################################################## | ||
4226 | 3 | # | ||
4227 | 4 | # OpenERP, Open Source Management Solution | ||
4228 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4229 | 6 | # | ||
4230 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4231 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4232 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4233 | 10 | # License, or (at your option) any later version. | ||
4234 | 11 | # | ||
4235 | 12 | # This program is distributed in the hope that it will be useful, | ||
4236 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4237 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4238 | 15 | # GNU Affero General Public License for more details. | ||
4239 | 16 | # | ||
4240 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4241 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4242 | 19 | # | ||
4243 | 20 | ############################################################################## | ||
4244 | 21 | |||
4245 | 22 | import unittest | ||
4246 | 23 | import pooler | ||
4247 | 24 | import netsvc | ||
4248 | 25 | from osv import osv | ||
4249 | 26 | |||
4250 | 27 | questionnaire_id = None | ||
4251 | 28 | question_1 = None | ||
4252 | 29 | choice_ids = None | ||
4253 | 30 | |||
4254 | 31 | class crm_profiling_test_case(unittest.TestCase): | ||
4255 | 32 | |||
4256 | 33 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
4257 | 34 | self.cr = cursor | ||
4258 | 35 | self.uid = user | ||
4259 | 36 | unittest.TestCase.__init__(self, methodName) | ||
4260 | 37 | |||
4261 | 38 | def setUp(self): | ||
4262 | 39 | try: | ||
4263 | 40 | self.pool = pooler.get_pool(self.cr.dbname) | ||
4264 | 41 | self.crm_profiling_question = self.pool.get('crm_profiling.question') | ||
4265 | 42 | self.crm_profiling_questionnaire = self.pool.get('crm_profiling.questionnaire') | ||
4266 | 43 | self.crm_profiling_answer = self.pool.get('crm_profiling.answer') | ||
4267 | 44 | self.crm_segmentation = self.pool.get('crm.segmentation') | ||
4268 | 45 | self.crm_segmentation_line = self.pool.get('crm.segmentation.line') | ||
4269 | 46 | except osv.except_osv,e: | ||
4270 | 47 | self.fail(e.name + e.value) | ||
4271 | 48 | except Exception,e: | ||
4272 | 49 | self.fail(e) | ||
4273 | 50 | |||
4274 | 51 | def tearDown(self): | ||
4275 | 52 | try: | ||
4276 | 53 | self.pool = None | ||
4277 | 54 | self.crm_profiling_question = None | ||
4278 | 55 | self.crm_profiling_questionnaire = None | ||
4279 | 56 | self.crm_profiling_answer = None | ||
4280 | 57 | self.crm_segmentation = None | ||
4281 | 58 | self.crm_segmentation_line = None | ||
4282 | 59 | except osv.except_osv,e: | ||
4283 | 60 | self.fail(e.name + e.value) | ||
4284 | 61 | except Exception,e: | ||
4285 | 62 | self.fail(e) | ||
4286 | 63 | |||
4287 | 64 | def test_1_create(self): | ||
4288 | 65 | try: | ||
4289 | 66 | global questionnaire_id,question_ids,choice_ids,segmentation_id,segmentation_line_id,partner_id,categ_id | ||
4290 | 67 | question_ids = [] | ||
4291 | 68 | choice_ids = [] | ||
4292 | 69 | model_obj = self.pool.get('ir.model.data') | ||
4293 | 70 | |||
4294 | 71 | categ = model_obj._get_id(self.cr, self.uid, 'base', 'res_partner_category_2') | ||
4295 | 72 | categ_id = model_obj.browse(self.cr, self.uid,categ).res_id | ||
4296 | 73 | parent = model_obj._get_id(self.cr, self.uid, 'crm_profiling', 'crm_segmentation6') | ||
4297 | 74 | parent_id = model_obj.browse(self.cr, self.uid,parent).res_id | ||
4298 | 75 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
4299 | 76 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
4300 | 77 | |||
4301 | 78 | # Questions | ||
4302 | 79 | quest =['Which ERP has best Accounting module','Which ERP has higher marketing value'] | ||
4303 | 80 | for question in quest: | ||
4304 | 81 | question_1 = self.crm_profiling_question.create(self.cr,self.uid,{'name' :question}) | ||
4305 | 82 | for choice in ['OpenERP','MSDY','MSDY']: | ||
4306 | 83 | choice_1 = self.crm_profiling_answer.create(self.cr,self.uid,{'name':'MSDY','question_id':question_1}) | ||
4307 | 84 | choice_ids.append(choice_1) | ||
4308 | 85 | question_ids.append(question_1) | ||
4309 | 86 | questionnaire_id = self.crm_profiling_questionnaire.create(self.cr,self.uid,{'name':'ERP Compare', | ||
4310 | 87 | 'description':'ERP marketing questionnaire', | ||
4311 | 88 | 'questions_ids':[(6,0,question_ids)]}) | ||
4312 | 89 | |||
4313 | 90 | ## Segmentation | ||
4314 | 91 | segmentation_id = self.crm_segmentation.create(self.cr,self.uid,{'name':'My Segmentation', | ||
4315 | 92 | 'description':'Developing new segmentation for the client', | ||
4316 | 93 | 'categ_id':categ_id, | ||
4317 | 94 | 'parent_id':parent_id, | ||
4318 | 95 | 'answer_yes':[(6,0,choice_ids[0:3])]}) | ||
4319 | 96 | |||
4320 | 97 | segmentation_line_id = self.crm_segmentation_line.create(self.cr,self.uid,{'segmentation_id':segmentation_id, | ||
4321 | 98 | 'name':'My segment line', | ||
4322 | 99 | 'expr_name':'sale', | ||
4323 | 100 | 'expr_operator':'>', | ||
4324 | 101 | 'expr_value':500,'operator':'and'}) | ||
4325 | 102 | except osv.except_osv,e: | ||
4326 | 103 | self.fail(e.name + e.value) | ||
4327 | 104 | except Exception,e: | ||
4328 | 105 | self.fail(e) | ||
4329 | 106 | |||
4330 | 107 | def test_2_SegmentationProcessStrat(self): | ||
4331 | 108 | try: | ||
4332 | 109 | self.failUnless(segmentation_id,"No Segmentation Created !") | ||
4333 | 110 | self.crm_segmentation.process_start(self.cr,self.uid,[segmentation_id]) | ||
4334 | 111 | except osv.except_osv,e: | ||
4335 | 112 | self.fail(e.name + e.value) | ||
4336 | 113 | except Exception,e: | ||
4337 | 114 | self.fail(e) | ||
4338 | 115 | |||
4339 | 116 | def test_3_RemoveCategory(self): | ||
4340 | 117 | try: | ||
4341 | 118 | self.failUnless(segmentation_id,"No Segmentation Created !") | ||
4342 | 119 | self.cr.execute("delete from res_partner_category_rel where partner_id = %s and category_id = %s", (partner_id,categ_id)) | ||
4343 | 120 | except osv.except_osv,e: | ||
4344 | 121 | self.fail(e.name + e.value) | ||
4345 | 122 | except Exception,e: | ||
4346 | 123 | self.fail(e) | ||
4347 | 124 | |||
4348 | 125 | def test_4_Unlink(self): | ||
4349 | 126 | try: | ||
4350 | 127 | self.failUnless(segmentation_id,"No Segmentation Created !") | ||
4351 | 128 | self.crm_segmentation_line.unlink(self.cr,self.uid,[segmentation_line_id]) | ||
4352 | 129 | self.crm_segmentation.unlink(self.cr,self.uid,[segmentation_id]) | ||
4353 | 130 | self.crm_profiling_answer.unlink(self.cr,self.uid,choice_ids) | ||
4354 | 131 | self.crm_profiling_question.unlink(self.cr,self.uid,question_ids) | ||
4355 | 132 | self.crm_profiling_questionnaire.unlink(self.cr,self.uid,[questionnaire_id]) | ||
4356 | 133 | except osv.except_osv,e: | ||
4357 | 134 | self.fail(e.name + e.value) | ||
4358 | 135 | except Exception,e: | ||
4359 | 136 | self.fail(e) | ||
4360 | 137 | |||
4361 | 138 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4362 | 0 | 139 | ||
4363 | === added directory 'delivery/unit_test' | |||
4364 | === added file 'delivery/unit_test/__init__.py' | |||
4365 | --- delivery/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
4366 | +++ delivery/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
4367 | @@ -0,0 +1,22 @@ | |||
4368 | 1 | # -*- coding: utf-8 -*- | ||
4369 | 2 | ############################################################################## | ||
4370 | 3 | # | ||
4371 | 4 | # OpenERP, Open Source Management Solution | ||
4372 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4373 | 6 | # | ||
4374 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4375 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4376 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4377 | 10 | # License, or (at your option) any later version. | ||
4378 | 11 | # | ||
4379 | 12 | # This program is distributed in the hope that it will be useful, | ||
4380 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4381 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4382 | 15 | # GNU Affero General Public License for more details. | ||
4383 | 16 | # | ||
4384 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4385 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4386 | 19 | # | ||
4387 | 20 | ############################################################################## | ||
4388 | 21 | |||
4389 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4390 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
4391 | 1 | 24 | ||
4392 | === added file 'delivery/unit_test/test.py' | |||
4393 | --- delivery/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
4394 | +++ delivery/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
4395 | @@ -0,0 +1,154 @@ | |||
4396 | 1 | # -*- coding: utf-8 -*- | ||
4397 | 2 | ############################################################################## | ||
4398 | 3 | # | ||
4399 | 4 | # OpenERP, Open Source Management Solution | ||
4400 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4401 | 6 | # | ||
4402 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4403 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4404 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4405 | 10 | # License, or (at your option) any later version. | ||
4406 | 11 | # | ||
4407 | 12 | # This program is distributed in the hope that it will be useful, | ||
4408 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4409 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4410 | 15 | # GNU Affero General Public License for more details. | ||
4411 | 16 | # | ||
4412 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4413 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4414 | 19 | # | ||
4415 | 20 | ############################################################################## | ||
4416 | 21 | import unittest | ||
4417 | 22 | import pooler | ||
4418 | 23 | import netsvc | ||
4419 | 24 | from osv import osv | ||
4420 | 25 | import sale.unit_test.test as sale | ||
4421 | 26 | import product.unit_test.test as prod | ||
4422 | 27 | |||
4423 | 28 | |||
4424 | 29 | delivery_id = None | ||
4425 | 30 | |||
4426 | 31 | class delivery_test_case(unittest.TestCase): | ||
4427 | 32 | |||
4428 | 33 | third_party_cases={sale.sale_order_test_case: ['test_1_Create']} | ||
4429 | 34 | |||
4430 | 35 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
4431 | 36 | self.cr = cursor | ||
4432 | 37 | self.uid = user | ||
4433 | 38 | unittest.TestCase.__init__(self, methodName) | ||
4434 | 39 | |||
4435 | 40 | def setUp(self): | ||
4436 | 41 | try: | ||
4437 | 42 | self.pool = pooler.get_pool(self.cr.dbname) | ||
4438 | 43 | self.sale_order = self.pool.get('sale.order') | ||
4439 | 44 | self.delivery_carrier = self.pool.get('delivery.carrier') | ||
4440 | 45 | self.delivery_grid = self.pool.get('delivery.grid') | ||
4441 | 46 | self.delivery_grid_line = self.pool.get('delivery.grid.line') | ||
4442 | 47 | self.stock_picking=self.pool.get('stock.picking') | ||
4443 | 48 | self.stock_move=self.pool.get('stock.move') | ||
4444 | 49 | except osv.except_osv,e: | ||
4445 | 50 | self.fail(e.name + e.value) | ||
4446 | 51 | except Exception,e: | ||
4447 | 52 | self.fail(e) | ||
4448 | 53 | |||
4449 | 54 | def tearDown(self): | ||
4450 | 55 | try: | ||
4451 | 56 | self.pool = None | ||
4452 | 57 | self.sale_order = None | ||
4453 | 58 | self.product_pricelist = None | ||
4454 | 59 | self.delivery_carrier = None | ||
4455 | 60 | self.delivery_grid = None | ||
4456 | 61 | self.delivery_grid_line = None | ||
4457 | 62 | self.stock_picking= None | ||
4458 | 63 | self.stock_move= None | ||
4459 | 64 | except osv.except_osv,e: | ||
4460 | 65 | self.fail(e.name + e.value) | ||
4461 | 66 | except Exception,e: | ||
4462 | 67 | self.fail(e) | ||
4463 | 68 | |||
4464 | 69 | def test_1_Create(self): | ||
4465 | 70 | |||
4466 | 71 | try: | ||
4467 | 72 | global order_id,delivery_id,sale_order_line_id,grid_line_id | ||
4468 | 73 | model_obj = self.pool.get('ir.model.data') | ||
4469 | 74 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
4470 | 75 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
4471 | 76 | pricelist_id = self.pool.get('res.partner').browse(self.cr, self.uid,partner_id).property_product_pricelist.id | ||
4472 | 77 | product = model_obj._get_id(self.cr,self.uid, 'product', 'product_product_pc2') | ||
4473 | 78 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
4474 | 79 | delivery_id = self.delivery_carrier.create(self.cr,self.uid,{'name':'Test','product_id':product_id, | ||
4475 | 80 | 'partner_id':partner_id,}) | ||
4476 | 81 | self.sale_order.write(self.cr,self.uid,sale.order_id,{'carrier_id':delivery_id}) | ||
4477 | 82 | delivery_grid_id=self.delivery_grid.create(self.cr,self.uid,{'name':'Test-Pricelist','carrier_id':delivery_id,}) | ||
4478 | 83 | grid_line_id=self.delivery_grid_line.create(self.cr,self.uid,{'name':'Test-grid-line', | ||
4479 | 84 | 'grid_id':delivery_grid_id, | ||
4480 | 85 | 'type':'price','operator':'=', | ||
4481 | 86 | 'max_value':300.00, | ||
4482 | 87 | 'price_type':'variable', | ||
4483 | 88 | 'variable_factor':'weight', | ||
4484 | 89 | 'list_price':100.00, | ||
4485 | 90 | 'standard_price':20.00}) | ||
4486 | 91 | |||
4487 | 92 | except osv.except_osv,e: | ||
4488 | 93 | self.fail(e.name + e.value) | ||
4489 | 94 | except Exception,e: | ||
4490 | 95 | self.fail(e) | ||
4491 | 96 | |||
4492 | 97 | def test_2_ConfirmOrder(self): | ||
4493 | 98 | try: | ||
4494 | 99 | self.failUnless(sale.order_id,"No Sale Order Created !") | ||
4495 | 100 | wf_service = netsvc.LocalService("workflow") | ||
4496 | 101 | res = wf_service.trg_validate(self.uid, 'sale.order',sale.order_id, 'order_confirm', self.cr) | ||
4497 | 102 | except osv.except_osv,e: | ||
4498 | 103 | self.fail(e.name + e.value) | ||
4499 | 104 | except Exception,e: | ||
4500 | 105 | self.fail(e) | ||
4501 | 106 | |||
4502 | 107 | def test_3_check_avalibility_Order(self): | ||
4503 | 108 | try: | ||
4504 | 109 | global stock_pick_id | ||
4505 | 110 | self.failUnless(sale.order_id,"No Sale Order Created !") | ||
4506 | 111 | stock_pick = self.stock_picking.search(self.cr,self.uid,[('sale_id','=',sale.order_id)]) | ||
4507 | 112 | stock_pick_id = self.stock_picking.browse(self.cr,self.uid,stock_pick)[0] | ||
4508 | 113 | self.stock_picking.write(self.cr,self.uid,[stock_pick_id.id],{'type':'delivery'}) | ||
4509 | 114 | self.stock_picking.force_assign(self.cr,self.uid,[stock_pick_id.id]) | ||
4510 | 115 | except osv.except_osv,e: | ||
4511 | 116 | self.fail(e.name + e.value) | ||
4512 | 117 | except Exception,e: | ||
4513 | 118 | self.fail(e) | ||
4514 | 119 | |||
4515 | 120 | def test_4_wizard_test(self): | ||
4516 | 121 | try: | ||
4517 | 122 | self.cr.commit() | ||
4518 | 123 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4519 | 124 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'stock.partial_picking') | ||
4520 | 125 | stock_mov = self.stock_move.search(self.cr,self.uid,[('picking_id','=',stock_pick_id.id)]) | ||
4521 | 126 | stock_move_id=self.stock_move.browse(self.cr,self.uid,stock_mov)[0] | ||
4522 | 127 | move_id = 'move'+ str(stock_move_id.id) | ||
4523 | 128 | datas = {'form': {'moves': [stock_move_id.id], move_id: 6.0}, 'ids': [stock_pick_id.id], 'id':stock_pick_id.id} | ||
4524 | 129 | state = 'split' | ||
4525 | 130 | res = wizard_service.exp_execute(self.cr.dbname, self.uid,wizard_res , datas, state, {}) | ||
4526 | 131 | except osv.except_osv,e: | ||
4527 | 132 | self.fail(e.name + e.value) | ||
4528 | 133 | except Exception,e: | ||
4529 | 134 | self.fail(e) | ||
4530 | 135 | |||
4531 | 136 | def test_5_Unlink(self): | ||
4532 | 137 | try: | ||
4533 | 138 | self.failUnless(sale.order_id,"No Sales Order Created !") | ||
4534 | 139 | self.pool.get('stock.picking').unlink(self.cr, self.uid, [stock_pick_id.id]) | ||
4535 | 140 | self.sale_order.action_cancel(self.cr, self.uid, [sale.order_id]) | ||
4536 | 141 | self.sale_order.unlink(self.cr, self.uid, [sale.order_id]) | ||
4537 | 142 | self.delivery_grid_line.unlink(self.cr,self.uid,grid_line_id) | ||
4538 | 143 | self.delivery_carrier.unlink(self.cr,self.uid,delivery_id) | ||
4539 | 144 | self.pool.get('product.product').unlink(self.cr,self.uid,[prod.product_id]) | ||
4540 | 145 | self.pool.get('product.pricelist.item').unlink(self.cr, self.uid,[prod.product_pricelist_items_id]) | ||
4541 | 146 | self.pool.get('product.pricelist.version').unlink(self.cr,self.uid,[prod.product_pricelist_version_id]) | ||
4542 | 147 | self.pool.get('product.pricelist').unlink(self.cr,self.uid,[prod.product_pricelist_id]) | ||
4543 | 148 | self.pool.get('product.pricelist.type').unlink(self.cr,self.uid,[prod.pricelist_type_id]) | ||
4544 | 149 | except osv.except_osv,e: | ||
4545 | 150 | self.fail(e.name + e.value) | ||
4546 | 151 | except Exception,e: | ||
4547 | 152 | self.fail(e) | ||
4548 | 153 | |||
4549 | 154 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4550 | 0 | 155 | ||
4551 | === added directory 'event/unit_test' | |||
4552 | === added file 'event/unit_test/__init__.py' | |||
4553 | --- event/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
4554 | +++ event/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
4555 | @@ -0,0 +1,22 @@ | |||
4556 | 1 | # -*- coding: utf-8 -*- | ||
4557 | 2 | ############################################################################## | ||
4558 | 3 | # | ||
4559 | 4 | # OpenERP, Open Source Management Solution | ||
4560 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4561 | 6 | # | ||
4562 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4563 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4564 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4565 | 10 | # License, or (at your option) any later version. | ||
4566 | 11 | # | ||
4567 | 12 | # This program is distributed in the hope that it will be useful, | ||
4568 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4569 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4570 | 15 | # GNU Affero General Public License for more details. | ||
4571 | 16 | # | ||
4572 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4573 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4574 | 19 | # | ||
4575 | 20 | ############################################################################## | ||
4576 | 21 | |||
4577 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4578 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
4579 | 1 | 24 | ||
4580 | === added file 'event/unit_test/test.py' | |||
4581 | --- event/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
4582 | +++ event/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
4583 | @@ -0,0 +1,182 @@ | |||
4584 | 1 | # -*- coding: utf-8 -*- | ||
4585 | 2 | ############################################################################## | ||
4586 | 3 | # | ||
4587 | 4 | # OpenERP, Open Source Management Solution | ||
4588 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4589 | 6 | # | ||
4590 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4591 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4592 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4593 | 10 | # License, or (at your option) any later version. | ||
4594 | 11 | # | ||
4595 | 12 | # This program is distributed in the hope that it will be useful, | ||
4596 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4597 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4598 | 15 | # GNU Affero General Public License for more details. | ||
4599 | 16 | # | ||
4600 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4601 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4602 | 19 | # | ||
4603 | 20 | ############################################################################## | ||
4604 | 21 | |||
4605 | 22 | import unittest | ||
4606 | 23 | import pooler | ||
4607 | 24 | import netsvc | ||
4608 | 25 | from osv import osv | ||
4609 | 26 | import datetime | ||
4610 | 27 | import time | ||
4611 | 28 | |||
4612 | 29 | event_id = None | ||
4613 | 30 | registration_id = None | ||
4614 | 31 | |||
4615 | 32 | |||
4616 | 33 | class event_test_case(unittest.TestCase): | ||
4617 | 34 | |||
4618 | 35 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
4619 | 36 | self.cr = cursor | ||
4620 | 37 | self.uid = user | ||
4621 | 38 | unittest.TestCase.__init__(self, methodName) | ||
4622 | 39 | |||
4623 | 40 | def setUp(self): | ||
4624 | 41 | try: | ||
4625 | 42 | self.pool = pooler.get_pool(self.cr.dbname) | ||
4626 | 43 | self.event_event = self.pool.get('event.event') | ||
4627 | 44 | self.event_registration = self.pool.get('event.registration') | ||
4628 | 45 | except osv.except_osv,e: | ||
4629 | 46 | self.fail(e.name + e.value) | ||
4630 | 47 | except Exception,e: | ||
4631 | 48 | self.fail(e) | ||
4632 | 49 | |||
4633 | 50 | def tearDown(self): | ||
4634 | 51 | try: | ||
4635 | 52 | self.pool = None | ||
4636 | 53 | self.event_event = None | ||
4637 | 54 | self.event_registration = None | ||
4638 | 55 | except osv.except_osv,e: | ||
4639 | 56 | self.fail(e.name + e.value) | ||
4640 | 57 | except Exception,e: | ||
4641 | 58 | self.fail(e) | ||
4642 | 59 | |||
4643 | 60 | def test_1_create(self): | ||
4644 | 61 | try: | ||
4645 | 62 | global event_id,registration_id | ||
4646 | 63 | model_obj = self.pool.get('ir.model.data') | ||
4647 | 64 | |||
4648 | 65 | product = model_obj._get_id(self.cr,self.uid, 'product', 'product_product_pc2') | ||
4649 | 66 | product_id = model_obj.browse(self.cr, self.uid, product).res_id | ||
4650 | 67 | event_parent = model_obj._get_id(self.cr,self.uid, 'event', 'event_0') | ||
4651 | 68 | event_parent_id = model_obj.browse(self.cr, self.uid, event_parent).res_id | ||
4652 | 69 | partner = model_obj._get_id(self.cr,self.uid, 'base', 'res_partner_9') | ||
4653 | 70 | partner_id = model_obj.browse(self.cr, self.uid, partner,).res_id | ||
4654 | 71 | partner_address = model_obj._get_id(self.cr, self.uid, 'base_contact', 'res_partner_contact_simonis0') | ||
4655 | 72 | partner_address_id = model_obj.browse(self.cr, self.uid, partner_address).res_id | ||
4656 | 73 | |||
4657 | 74 | event_id = self.event_event.create(self.cr,self.uid,{'name':'My Event', | ||
4658 | 75 | 'date_begin':time.strftime('%Y-%m-%d %H:%M:%S'), | ||
4659 | 76 | 'date_end':datetime.date.today() + datetime.timedelta(days=2), | ||
4660 | 77 | 'product_id':product_id, | ||
4661 | 78 | 'register_max':500, | ||
4662 | 79 | 'register_min':25, | ||
4663 | 80 | 'parent_id':event_parent_id, | ||
4664 | 81 | 'mail_auto_confirm':1,'reply_to':'vir@tinyerp.com'}) | ||
4665 | 82 | |||
4666 | 83 | |||
4667 | 84 | registration_id = self.event_registration.create(self.cr,self.uid,{'event_id':event_id,'partner_id':partner_id, | ||
4668 | 85 | 'contact_id':partner_address_id, | ||
4669 | 86 | 'invoice_label':'Event Invoice', | ||
4670 | 87 | 'partner_invoice_id':partner_id}) | ||
4671 | 88 | self.cr.commit() | ||
4672 | 89 | except osv.except_osv,e: | ||
4673 | 90 | self.fail(e.name + e.value) | ||
4674 | 91 | except Exception,e: | ||
4675 | 92 | self.fail(e) | ||
4676 | 93 | |||
4677 | 94 | def test_2_ConfirmRegistration(self): | ||
4678 | 95 | try: | ||
4679 | 96 | self.cr.commit() | ||
4680 | 97 | self.failUnless(registration_id,"No registration Created !") | ||
4681 | 98 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4682 | 99 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'event.confirm_registration') | ||
4683 | 100 | datas = {'model': 'event.registration', 'form': {}, 'id':registration_id ,'ids': [registration_id]} | ||
4684 | 101 | state = 'init' | ||
4685 | 102 | wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4686 | 103 | except osv.except_osv,e: | ||
4687 | 104 | self.fail(e.name + e.value) | ||
4688 | 105 | except Exception,e: | ||
4689 | 106 | self.fail | ||
4690 | 107 | |||
4691 | 108 | def test_3_RegistrationClose(self): | ||
4692 | 109 | try: | ||
4693 | 110 | self.cr.commit() | ||
4694 | 111 | self.failUnless(registration_id,"No registration Created !") | ||
4695 | 112 | self.event_registration.button_reg_close(self.cr,self.uid,[registration_id]) | ||
4696 | 113 | except osv.except_osv,e: | ||
4697 | 114 | self.fail(e.name + e.value) | ||
4698 | 115 | except Exception,e: | ||
4699 | 116 | self.fail | ||
4700 | 117 | |||
4701 | 118 | def test_4_makeInvoice(self): | ||
4702 | 119 | try: | ||
4703 | 120 | global res2 | ||
4704 | 121 | self.cr.commit() | ||
4705 | 122 | self.failUnless(registration_id,"No registration Created !") | ||
4706 | 123 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4707 | 124 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'event.reg_make_invoice') | ||
4708 | 125 | datas = {'model': 'event.registration', 'form': {}, 'id': registration_id, 'ids': [registration_id]} | ||
4709 | 126 | state = 'init' | ||
4710 | 127 | res2 = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4711 | 128 | except osv.except_osv,e: | ||
4712 | 129 | self.fail(e.name + e.value) | ||
4713 | 130 | except Exception,e: | ||
4714 | 131 | self.fail | ||
4715 | 132 | |||
4716 | 133 | def test_5_ListRegisteredPartner(self): | ||
4717 | 134 | try: | ||
4718 | 135 | self.cr.commit() | ||
4719 | 136 | self.failUnless(event_id,"No Event Created !") | ||
4720 | 137 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4721 | 138 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, passwd, 'event.event_reg_partners') | ||
4722 | 139 | datas = {'model': 'event.event', 'form': {}, 'id': event_id, 'ids': [event_id]} | ||
4723 | 140 | state = 'init' | ||
4724 | 141 | res2 = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4725 | 142 | except osv.except_osv,e: | ||
4726 | 143 | self.fail(e.name + e.value) | ||
4727 | 144 | except Exception,e: | ||
4728 | 145 | self.fail | ||
4729 | 146 | |||
4730 | 147 | def test_6_Registrations(self): | ||
4731 | 148 | try: | ||
4732 | 149 | self.cr.commit() | ||
4733 | 150 | self.failUnless(event_id,"No Event Created !") | ||
4734 | 151 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4735 | 152 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'wizard_event_registration') | ||
4736 | 153 | datas = {'model': 'event.event', 'form': {}, 'id': event_id, 'ids': [event_id]} | ||
4737 | 154 | state = 'init' | ||
4738 | 155 | res2 = wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4739 | 156 | except osv.except_osv,e: | ||
4740 | 157 | self.fail(e.name + e.value) | ||
4741 | 158 | except Exception,e: | ||
4742 | 159 | self.fail | ||
4743 | 160 | |||
4744 | 161 | def test_7_EventDone(self): | ||
4745 | 162 | try: | ||
4746 | 163 | self.cr.commit() | ||
4747 | 164 | self.failUnless(event_id,"No Event Created !") | ||
4748 | 165 | self.event_event.button_done(self.cr,self.uid,[event_id]) | ||
4749 | 166 | except osv.except_osv,e: | ||
4750 | 167 | self.fail(e.name + e.value) | ||
4751 | 168 | except Exception,e: | ||
4752 | 169 | self.fail(e) | ||
4753 | 170 | |||
4754 | 171 | def test_8_Unlink(self): | ||
4755 | 172 | try: | ||
4756 | 173 | self.failUnless(event_id,"No Event Created !") | ||
4757 | 174 | self.event_registration.unlink(self.cr,self.uid,[registration_id]) | ||
4758 | 175 | self.event_event.unlink(self.cr,self.uid,[event_id]) | ||
4759 | 176 | self.pool.get('account.invoice').unlink(self.cr,self.uid,res2['datas']['invoice_ids']) | ||
4760 | 177 | except osv.except_osv,e: | ||
4761 | 178 | self.fail(e.name + e.value) | ||
4762 | 179 | except Exception,e: | ||
4763 | 180 | self.fail(e) | ||
4764 | 181 | |||
4765 | 182 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4766 | 0 | 183 | ||
4767 | === added directory 'event_project/unit_test' | |||
4768 | === added file 'event_project/unit_test/__init__.py' | |||
4769 | --- event_project/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
4770 | +++ event_project/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
4771 | @@ -0,0 +1,22 @@ | |||
4772 | 1 | # -*- coding: utf-8 -*- | ||
4773 | 2 | ############################################################################## | ||
4774 | 3 | # | ||
4775 | 4 | # OpenERP, Open Source Management Solution | ||
4776 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4777 | 6 | # | ||
4778 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4779 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4780 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4781 | 10 | # License, or (at your option) any later version. | ||
4782 | 11 | # | ||
4783 | 12 | # This program is distributed in the hope that it will be useful, | ||
4784 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4785 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4786 | 15 | # GNU Affero General Public License for more details. | ||
4787 | 16 | # | ||
4788 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4789 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4790 | 19 | # | ||
4791 | 20 | ############################################################################## | ||
4792 | 21 | |||
4793 | 22 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4794 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
4795 | 1 | 24 | ||
4796 | === added file 'event_project/unit_test/test.py' | |||
4797 | --- event_project/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
4798 | +++ event_project/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
4799 | @@ -0,0 +1,149 @@ | |||
4800 | 1 | # -*- coding: utf-8 -*- | ||
4801 | 2 | ############################################################################## | ||
4802 | 3 | # | ||
4803 | 4 | # OpenERP, Open Source Management Solution | ||
4804 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4805 | 6 | # | ||
4806 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4807 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4808 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4809 | 10 | # License, or (at your option) any later version. | ||
4810 | 11 | # | ||
4811 | 12 | # This program is distributed in the hope that it will be useful, | ||
4812 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4813 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4814 | 15 | # GNU Affero General Public License for more details. | ||
4815 | 16 | # | ||
4816 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4817 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4818 | 19 | # | ||
4819 | 20 | ############################################################################## | ||
4820 | 21 | import unittest | ||
4821 | 22 | import pooler | ||
4822 | 23 | import netsvc | ||
4823 | 24 | from osv import osv | ||
4824 | 25 | import event.unit_test.test as event_proj | ||
4825 | 26 | |||
4826 | 27 | class event_project_test_case(unittest.TestCase): | ||
4827 | 28 | |||
4828 | 29 | third_party_cases={event_proj.event_test_case: ['test_1_create']} | ||
4829 | 30 | |||
4830 | 31 | def __init__(self, cursor=False,user=False,methodName='runTest'): | ||
4831 | 32 | self.cr = cursor | ||
4832 | 33 | self.uid = user | ||
4833 | 34 | unittest.TestCase.__init__(self, methodName) | ||
4834 | 35 | |||
4835 | 36 | def setUp(self): | ||
4836 | 37 | try: | ||
4837 | 38 | self.pool = pooler.get_pool(self.cr.dbname) | ||
4838 | 39 | self.event_event = self.pool.get('event.event') | ||
4839 | 40 | self.event_registration = self.pool.get('event.registration') | ||
4840 | 41 | except osv.except_osv,e: | ||
4841 | 42 | self.fail(e.name + e.value) | ||
4842 | 43 | except Exception,e: | ||
4843 | 44 | self.fail(e) | ||
4844 | 45 | |||
4845 | 46 | def tearDown(self): | ||
4846 | 47 | try: | ||
4847 | 48 | self.pool = None | ||
4848 | 49 | self.event_event = None | ||
4849 | 50 | self.event_registration = None | ||
4850 | 51 | except osv.except_osv,e: | ||
4851 | 52 | self.fail(e.name + e.value) | ||
4852 | 53 | except Exception,e: | ||
4853 | 54 | self.fail(e) | ||
4854 | 55 | |||
4855 | 56 | def test_1_CreateRetroPlanning(self): | ||
4856 | 57 | try: | ||
4857 | 58 | self.cr.commit() | ||
4858 | 59 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4859 | 60 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'event.project') | ||
4860 | 61 | datas = {'form': {'project_id': 3}, 'ids': [event_proj.event_id], 'id': event_proj.event_id} | ||
4861 | 62 | state = 'done' | ||
4862 | 63 | wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4863 | 64 | except osv.except_osv,e: | ||
4864 | 65 | self.fail(e.name + e.value) | ||
4865 | 66 | except Exception,e: | ||
4866 | 67 | self.fail | ||
4867 | 68 | |||
4868 | 69 | def test_2_ConfirmRegistration(self): | ||
4869 | 70 | try: | ||
4870 | 71 | self.cr.commit() | ||
4871 | 72 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4872 | 73 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'event.confirm_registration') | ||
4873 | 74 | datas = {'model': 'event.registration', 'form': {}, 'id':event_proj.registration_id , 'ids': [event_proj.registration_id]} | ||
4874 | 75 | state = 'init' | ||
4875 | 76 | wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4876 | 77 | except osv.except_osv,e: | ||
4877 | 78 | self.fail(e.name + e.value) | ||
4878 | 79 | except Exception,e: | ||
4879 | 80 | self.fail | ||
4880 | 81 | |||
4881 | 82 | def test_3_RegistrationClose(self): | ||
4882 | 83 | try: | ||
4883 | 84 | self.failUnless(event_proj.event_id,"No Event Created !") | ||
4884 | 85 | self.event_registration.button_reg_close(self.cr,self.uid,[event_proj.registration_id]) | ||
4885 | 86 | except osv.except_osv,e: | ||
4886 | 87 | self.fail(e.name + e.value) | ||
4887 | 88 | except Exception,e: | ||
4888 | 89 | self.fail | ||
4889 | 90 | |||
4890 | 91 | def test_4_makeInvoice(self): | ||
4891 | 92 | try: | ||
4892 | 93 | self.cr.commit() | ||
4893 | 94 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4894 | 95 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'event.reg_make_invoice') | ||
4895 | 96 | datas = {'model': 'event.registration', 'form': {}, 'id': event_proj.registration_id,'ids': [event_proj.registration_id]} | ||
4896 | 97 | state = 'init' | ||
4897 | 98 | wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4898 | 99 | except osv.except_osv,e: | ||
4899 | 100 | self.fail(e.name + e.value) | ||
4900 | 101 | except Exception,e: | ||
4901 | 102 | self.fail | ||
4902 | 103 | |||
4903 | 104 | def test_5_ListRegisteredPartner(self): | ||
4904 | 105 | try: | ||
4905 | 106 | self.cr.commit() | ||
4906 | 107 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4907 | 108 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'event.event_reg_partners') | ||
4908 | 109 | datas = {'model': 'event.event', 'form': {}, 'id': event_proj.event_id, 'ids': [event_proj.event_id]} | ||
4909 | 110 | state = 'init' | ||
4910 | 111 | wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4911 | 112 | except osv.except_osv,e: | ||
4912 | 113 | self.fail(e.name + e.value) | ||
4913 | 114 | except Exception,e: | ||
4914 | 115 | self.fail | ||
4915 | 116 | |||
4916 | 117 | def test_6_Registrations(self): | ||
4917 | 118 | try: | ||
4918 | 119 | self.cr.commit() | ||
4919 | 120 | wizard_service = netsvc.ExportService.getService("wizard") | ||
4920 | 121 | wizard_res = wizard_service.exp_create(self.cr.dbname, self.uid, 'wizard_event_registration') | ||
4921 | 122 | datas = {'model': 'event.event', 'form': {}, 'id': event_proj.event_id, 'ids': [event_proj.event_id]} | ||
4922 | 123 | state = 'init' | ||
4923 | 124 | wizard_service.exp_execute(self.cr.dbname, self.uid, wizard_res , datas, state, {}) | ||
4924 | 125 | except osv.except_osv,e: | ||
4925 | 126 | self.fail(e.name + e.value) | ||
4926 | 127 | except Exception,e: | ||
4927 | 128 | self.fail | ||
4928 | 129 | |||
4929 | 130 | def test_7_EventDone(self): | ||
4930 | 131 | try: | ||
4931 | 132 | self.failUnless(event_proj.event_id,"No Event Created !") | ||
4932 | 133 | self.event_event.button_done(self.cr,self.uid,[event_proj.event_id]) | ||
4933 | 134 | except osv.except_osv,e: | ||
4934 | 135 | self.fail(e.name + e.value) | ||
4935 | 136 | except Exception,e: | ||
4936 | 137 | self.fail(e) | ||
4937 | 138 | |||
4938 | 139 | def test_8_Unlink(self): | ||
4939 | 140 | try: | ||
4940 | 141 | self.failUnless(event_proj.event_id,"No Event Created !") | ||
4941 | 142 | self.event_registration.unlink(self.cr,self.uid,[event_proj.registration_id]) | ||
4942 | 143 | self.event_event.unlink(self.cr,self.uid,[event_proj.event_id]) | ||
4943 | 144 | except osv.except_osv,e: | ||
4944 | 145 | self.fail(e.name + e.value) | ||
4945 | 146 | except Exception,e: | ||
4946 | 147 | self.fail(e) | ||
4947 | 148 | |||
4948 | 149 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4949 | 0 | 150 | ||
4950 | === added directory 'hr/unit_test' | |||
4951 | === added file 'hr/unit_test/__init__.py' | |||
4952 | --- hr/unit_test/__init__.py 1970-01-01 00:00:00 +0000 | |||
4953 | +++ hr/unit_test/__init__.py 2010-03-08 07:28:31 +0000 | |||
4954 | @@ -0,0 +1,23 @@ | |||
4955 | 1 | # -*- coding: utf-8 -*- | ||
4956 | 2 | ############################################################################## | ||
4957 | 3 | # | ||
4958 | 4 | # OpenERP, Open Source Management Solution | ||
4959 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4960 | 6 | # | ||
4961 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4962 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4963 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4964 | 10 | # License, or (at your option) any later version. | ||
4965 | 11 | # | ||
4966 | 12 | # This program is distributed in the hope that it will be useful, | ||
4967 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4968 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4969 | 15 | # GNU Affero General Public License for more details. | ||
4970 | 16 | # | ||
4971 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4972 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4973 | 19 | # | ||
4974 | 20 | ############################################################################## | ||
4975 | 21 | |||
4976 | 22 | |||
4977 | 23 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4978 | 0 | 24 | ||
4979 | === added file 'hr/unit_test/test.py' | |||
4980 | --- hr/unit_test/test.py 1970-01-01 00:00:00 +0000 | |||
4981 | +++ hr/unit_test/test.py 2010-03-08 07:28:31 +0000 | |||
4982 | @@ -0,0 +1,104 @@ | |||
4983 | 1 | # -*- coding: utf-8 -*- | ||
4984 | 2 | ############################################################################## | ||
4985 | 3 | # | ||
4986 | 4 | # OpenERP, Open Source Management Solution | ||
4987 | 5 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). | ||
4988 | 6 | # | ||
4989 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4990 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4991 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4992 | 10 | # License, or (at your option) any later version. | ||
4993 | 11 | # | ||
4994 | 12 | # This program is distributed in the hope that it will be useful, | ||
4995 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4996 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4997 | 15 | # GNU Affero General Public License for more details. | ||
4998 | 16 | # | ||
4999 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
5000 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
The diff has been truncated for viewing.
Hello, module.
This branch consists unit test cases for the addons modules. which will be used to perform unit test in base_quality_
regards,
nch(OpenERP)