[IMP] hr_expense: improve the test cases
authorJagdish Panchal (Open ERP) <jap@tinyerp.com>
Mon, 28 Nov 2011 13:27:28 +0000 (18:57 +0530)
committerJagdish Panchal (Open ERP) <jap@tinyerp.com>
Mon, 28 Nov 2011 13:27:28 +0000 (18:57 +0530)
bzr revid: jap@tinyerp.com-20111128132728-vrojcnoba1gz5is1

1  2 
addons/hr_expense/__openerp__.py
addons/hr_expense/test/expense_demo.yml
addons/hr_expense/test/expense_process.yml

@@@ -63,7 -63,7 +63,8 @@@ re-invoice your customer's expenses if 
          'hr_expense_demo.xml',
          ],
      'test': [
-              'test/confirm2heldinvoiced.yml',
+              'test/expense_process.yml',
++             'test/expense_demo.yml',
               ],
      'installable': True,
      'active': False,
index 0000000,0000000..6364e44
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,11 @@@
++-
++  !record {model: hr.expense.expense, id: hr.employee3, view: False}:
++    employee_id: 'hr.employee3'
++    name : 'Antoine Philippe'
++-
++  !record {model: product.product, id: car_travel, view: False}:
++    hr_expense_ok: 'True
++-
++  !record {model: hr.expense.line, id: expense_line, view: False}:
++    product_id: 'car_travel'
++    name: 'Car Travel Expenses'
index 0000000,6db6f4d..654b28b
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,46 +1,50 @@@
+ -
+   In Order to test process of "Employee Expenses".
+ -
 -  I confirm "Expense Bill of September" of one employee of Marketing Department.
++  I confirm "Expense Bill of September" for one employee of Marketing Department.
+ -
+   !workflow {model: hr.expense.expense, action: confirm, ref: sep_expenses}
+ -
 -  I check state of expense after confirmed
++  I check state of expense after confirmed.
+ -
+   !assert {model: hr.expense.expense, id: sep_expenses}:
+     - state == 'confirm'
+ -
+   I accept this expense.
+ -
+   !workflow {model: hr.expense.expense, action: validate, ref: sep_expenses}
+ -
+   I make Invoice for the expense.
+ -
+   !python {model: hr.expense.expense}: |
+     self.invoice(cr, uid, [ref('sep_expenses')])
 -    
+ -
+   I check invoice details after invoiced.
+ -
+   !python {model: hr.expense.expense}: |
+     sep_expenses = self.browse(cr, uid, ref("sep_expenses"), context=context)
+     assert sep_expenses.state == 'invoiced', "Expense should be in 'Invoiced' state."
+     assert sep_expenses.invoice_id, "Expense should have link of Invoice."
++    assert sep_expenses.invoice_id.currency_id == sep_expenses.currency_id,"Invoice currency is not correspond with supplier invoice currency"
++    assert sep_expenses.invoice_id.origin == sep_expenses.name,"Invoice origin is not correspond with supplier invoice"
++    assert sep_expenses.invoice_id.type == 'in_invoice', "Invoice type is not supplier invoice"
++    assert sep_expenses.invoice_id.amount_total == sep_expenses.amount,"Invoice total amount is not correspond with supplier invoice total"
++    assert len(sep_expenses.invoice_id.invoice_line) == len(sep_expenses.line_ids),"Lines of Invoice and supplier invoice Line are not correspond"
+ -
 -  I paid the expense
++  I paid the expense.
+ -
+   !python {model: hr.expense.expense}: |
+     self.expense_paid(cr, uid, [ref('sep_expenses')])
+ -
+   I check the expense after paid.
+ -
+   !assert {model: hr.expense.expense, id: sep_expenses}:
+     - state == 'paid'
+ -
 -  I print this expense
++  I print this expense.
+ - 
+   !python {model: hr.expense.expense}: |
+     import netsvc, tools, os
+     (data, format) = netsvc.LocalService('report.hr.expense').create(cr, uid, [ref('hr_expense.sep_expenses')], {}, {})
+     if tools.config['test_report_directory']:
 -        file(os.path.join(tools.config['test_report_directory'], 'hr_expense-report.'+format), 'wb+').write(data)
++        file(os.path.join(tools.config['test_report_directory'], 'hr_expense-report.'+format), 'wb+').write(data)