[FIX] improve test

This commit is contained in:
vrenaville
2014-10-10 17:48:09 +02:00
parent 7d29ec2f33
commit 0f9ee8776e

View File

@@ -1,3 +1,96 @@
-
In order to test the process of payment order, I start with the supplier invoice.
-
!python {model: account.invoice}: |
self.write(cr, uid, [ref('account.demo_invoice_0')], {'check_total': -14})
-
In order to test account move line of journal, I check that there is no move attached to the invoice.
-
!python {model: account.invoice}: |
invoice = self.browse(cr, uid, ref("account.demo_invoice_0"))
assert (not invoice.move_id), "Moves are wrongly created for invoice."
-
I open the invoice.
-
!workflow {model: account.invoice, action: invoice_open, ref: account.demo_invoice_0}
-
I check that the invoice state is now "Open".
-
!assert {model: account.invoice, id: account.demo_invoice_0, severity: error, string: Invoice should be in 'Open' state}:
- state == 'open'
-
I create a payment order
-
!record {model: payment.order, id: date1_payment_order}:
#date_created
#date_done
date_prefered: due
#date_scheduled
#line_ids:
mode: account_payment.payment_mode_1
#reference
state: draft
total: -14
#user_id
-
I confirm the payment order.
-
!workflow {model: payment.order, action: open, ref: date1_payment_order}
-
I check that payment order is now "Confirmed".
-
!assert {model: payment.order, id: date1_payment_order, severity: error, string: Payment Order should be 'Confirmed'.}:
- state == 'open'
-
!record {model: payment.order.create, id: payment_order_create_0}:
duedate: !eval time.strftime('%Y-%m-%d')
-
I search for the invoice entries to make the payment.
-
!python {model: payment.order.create}: |
self.search_entries(cr, uid, [ref("payment_order_create_0")], {
"active_model": "payment.order", "active_ids": [ref("date1_payment_order")],
"active_id": ref("date1_payment_order"), })
-
I create payment lines entries.
-
!python {model: payment.order.create}: |
invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account.demo_invoice_0"))
move_line = invoice.move_id.line_id[0]
self.write(cr, uid, [ref("payment_order_create_0")], {'entries': [(6,0,[move_line.id])]})
self.create_payment(cr, uid, [ref("payment_order_create_0")], {
"active_model": "payment.order", "active_ids": [ref("date1_payment_order")],
"active_id": ref("date1_payment_order")})
-
After making all payments, I finish the payment order.
-
!python {model: payment.order}: |
self.set_done(cr, uid, [ref("date1_payment_order")])
-
I check that payment order is now "Done".
-
!assert {model: payment.order, id: date1_payment_order, severity: error, string: Payment Order should be in 'Done' state}:
- state == 'done'
-
I check that payment line is created with proper data.
-
!python {model: payment.order}: |
invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account.demo_invoice_0"))
payment = self.browse(cr, uid, ref("date1_payment_order"))
payment_line = payment.line_ids[0]
assert payment_line.move_line_id, "move line is not created in payment line."
assert invoice.move_id.name == payment_line.ml_inv_ref.number, "invoice reference number is not same created."
assert invoice.partner_id == payment_line.partner_id, "Partner is not correct."
assert invoice.date_due == payment_line.ml_maturity_date, "Due date is not correct."
assert invoice.amount_total == payment_line.amount, "Payment amount is not correct."
-
In order to test if the correct date is set in the bank statement
I create a bank statement
@@ -6,17 +99,17 @@
name: Statement for Date
journal_id: account.bank_journal
company_id: base.main_company
balance_end_real : 1000.0
balance_end_real : -14.0
-
I create a statement line for a SO
I import payment order lines for the bank statement.
-
!record {model: account.bank.statement.line, id: statement_line_date}:
name: Test autocompletion based on Sale Order Number
statement_id: statement_test_date1
ref: DATE1
account_id : account.a_sale
date: !eval time.strftime('%Y-12-20')
amount: 1000.0
!python {model: account.payment.populate.statement}: |
payment = self.pool.get('payment.order').browse(cr, uid, ref("date1_payment_order"))
payment_line = payment.line_ids[0]
import_payment_id = self.create(cr, uid, {'lines': [(6,0,[payment_line.id])]})
self.populate_statement(cr, uid, [import_payment_id], {"statement_id": ref("statement_test_date1"),
"active_model": "account.bank.statement", "journal_type": "cash",
"active_id": ref("statement_test_date1")})
-
I confirm the bank statement
-
@@ -29,4 +122,4 @@
import time
line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1)
line = self.browse(cr, uid, line_ids)[0]
assert line.date == time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date
assert line.date == time.strftime('%Y-01-31'), "Date (year-01-31) not equal to = %s" % line.date