Skip to content

Commit

Permalink
[IMP] tests cases: use float_compare instead of ==
Browse files Browse the repository at this point in the history
  • Loading branch information
mdi-odoo authored and rim-odoo committed Jul 22, 2014
1 parent dad761a commit bb5fd86
Show file tree
Hide file tree
Showing 28 changed files with 495 additions and 324 deletions.
6 changes: 4 additions & 2 deletions addons/account/test/account_fiscalyear_close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,7 @@
-
I check that the past accounts are taken into account in partner credit
-
!assert {model: res.partner, id: base.res_partner_2, string: Total Receivable does not takes unreconciled moves of previous years}:
- credit == 1040.0
!python {model: res.partner}: |
from openerp.tools import float_compare
credit = self.browse(cr, uid, ref('base.res_partner_2')).credit
assert float_compare(credit, 1040.0, precision_digits=2) == 0, "Total Receivable does not takes unreconciled moves of previous years"
6 changes: 4 additions & 2 deletions addons/account/test/account_supplier_invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
I verify that account move is created
-
!python {model: account.invoice}: |
from openerp.tools import float_compare
move_obj = self.pool.get('account.move')
inv = self.browse(cr, uid, ref('account_invoice_supplier0'))
move = inv.move_id
Expand All @@ -73,7 +74,7 @@
amt_compute = move_obj._amount_compute(cr, uid, list(ids), 'amount', None, {'lang': u'en_US', 'active_model': 'ir.ui.menu',
'active_ids': [ref('menu_action_move_journal_line_form')], 'tz': False, 'active_id': ref('menu_action_move_journal_line_form')}, where ='')
move_amount = amt_compute.values()
assert(inv.move_id and move.period_id.id == get_period and move_amount[0] == 3100.0), ('Journal Entries has not been created')
assert(inv.move_id and move.period_id.id == get_period and float_compare(move_amount[0], 3100.0, precision_digits=2) == 0), ('Journal Entries has not been created')
-
I cancel the account move which is in posted state and verifies that it gives warning message
-
Expand All @@ -92,5 +93,6 @@
I verify that 'Period Sum' and 'Year sum' of the tax code are the expected values
-
!python {model: account.tax.code}: |
from openerp.tools import float_compare
tax_code = self.browse(cr, uid, ref('tax_case'))
assert(tax_code.sum_period == 100.0 and tax_code.sum == 100.0), "Incorrect 'Period Sum' / 'Year sum' expected twice 100.0, got period=%r and year=%r)" % (tax_code.sum_period,tax_code.sum)
assert(float_compare(tax_code.sum_period, 100.0, precision_digits=2) == 0 and float_compare(tax_code.sum, 100.0, precision_digits=2) == 0), "Incorrect 'Period Sum' / 'Year sum' expected twice 100.0, got period=%r and year=%r)" % (tax_code.sum_period,tax_code.sum)
26 changes: 14 additions & 12 deletions addons/account/test/test_edi_invoice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
-
!python {model: account.invoice}: |
import time
from openerp.tools import float_compare
edi_document = {
"__id": "account:b33adf8a-decd-11f0-a4de-702a04e25700.random_invoice_763jsms",
"__module": "account",
Expand Down Expand Up @@ -141,14 +142,14 @@
for inv_line in invoice_new.invoice_line:
if inv_line.name == 'PC Assemble SC234':
assert inv_line.uos_id.name == "Unit" , "uom is not same"
assert inv_line.price_unit == 10 , "price unit is not same"
assert inv_line.quantity == 1 , "product qty is not same"
assert inv_line.price_subtotal == 10, "price sub total is not same"
assert float_compare(inv_line.price_unit, 10, precision_digits=2) == 0, "price unit is not same"
assert float_compare(inv_line.quantity, 1, precision_digits=2) == 0, "product qty is not same"
assert float_compare(inv_line.price_subtotal, 10, precision_digits=2) == 0, "price sub total is not same"
elif inv_line.name == 'PC on Demand':
assert inv_line.uos_id.name == "Unit" , "uom is not same"
assert inv_line.price_unit == 100 , "price unit is not same"
assert inv_line.quantity == 5 , "product qty is not same"
assert inv_line.price_subtotal == 500, "price sub total is not same"
assert float_compare(inv_line.price_unit, 100, precision_digits=2) == 0, "price unit is not same"
assert float_compare(inv_line.quantity, 5, precision_digits=2) == 0, "product qty is not same"
assert float_compare(inv_line.price_subtotal, 500, precision_digits=2) == 0, "price sub total is not same"
else:
raise AssertionError('unknown invoice line: %s' % inv_line)
for inv_tax in invoice_new.tax_line:
Expand All @@ -159,6 +160,7 @@
-
!python {model: account.invoice}: |
import time
from openerp.tools import float_compare
edi_document = {
"__id": "account:b22acf7a-ddcd-11e0-a4db-701a04e25543.random_invoice_763jsms",
"__module": "account",
Expand Down Expand Up @@ -249,14 +251,14 @@
for inv_line in invoice_new.invoice_line:
if inv_line.name == 'Basic PC':
assert inv_line.uos_id.name == "PCE" , "uom is not same"
assert inv_line.price_unit == 10 , "price unit is not same"
assert inv_line.quantity == 1 , "product qty is not same"
assert inv_line.price_subtotal == 10, "price sub total is not same"
assert float_compare(inv_line.price_unit, 10, precision_digits=2) == 0, "price unit is not same"
assert float_compare(inv_line.quantity, 1, precision_digits=2) == 0, "product qty is not same"
assert float_compare(inv_line.price_subtotal, 10, precision_digits=2) == 0, "price sub total is not same"
elif inv_line.name == 'Medium PC':
assert inv_line.uos_id.name == "PCE" , "uom is not same"
assert inv_line.price_unit == 100 , "price unit is not same"
assert inv_line.quantity == 5 , "product qty is not same"
assert inv_line.price_subtotal == 500, "price sub total is not same"
assert float_compare(inv_line.price_unit, 100, precision_digits=2) == 0, "price unit is not same"
assert float_compare(inv_line.quantity, 5, precision_digits=2) == 0, "product qty is not same"
assert float_compare(inv_line.price_subtotal, 500, precision_digits=2) == 0, "price sub total is not same"
else:
raise AssertionError('unknown invoice line: %s' % inv_line)
for inv_tax in invoice_new.tax_line:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
I test the generated invoice
-
!python {model: account.invoice}: |
from openerp.tools import float_compare
aid = ref('account_analytic_analysis.contract_main')
ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context)
assert len(ids)>=1, 'No invoice created for the contract'
for invoice in self.browse(cr, uid, ids,context=context):
assert invoice.amount_untaxed == 150.0, "The invoice total is different than 150!"
assert float_compare(invoice.amount_untaxed, 150.0, precision_digits=2) == 0, "The invoice total is different than 150!"
90 changes: 60 additions & 30 deletions addons/account_anglo_saxon/test/anglo_saxon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,17 @@
-
I check the Stock Interim account (Received) is credited successfully.
-
!assert {model: account.account, id : account_anglo_stock_input, string : Stock Interim account (Received) is not credited successfully.}:
- credit == 9
!python {model: account.account}: |
from openerp.tools import float_compare
credit = self.browse(cr, uid, ref('account_anglo_stock_input')).credit
float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Received) is not credited successfully."
-
I check the Stock valuation account is debited sucessfully.
-
!assert {model: account.account, id : account_anglo_stock_valuation, string : Stock valuation account is not debited successfully.}:
- debit == 9
!python {model: account.account}: |
from openerp.tools import float_compare
debit = self.browse(cr, uid, ref('account_anglo_stock_valuation')).debit
float_compare(debit, 9, precision_digits=2) == 0, "Stock valuation account is not debited successfully."
-
I Validate Invoice of Purchase Order.
-
Expand All @@ -148,18 +152,24 @@
-
I check the Stock Interim account (Received) is debited sucessfully when Invoice validated.
-
!assert {model: account.account, id : account_anglo_stock_input, string : Stock Interim account (Received) is not debited successfully.}:
- debit == 9
!python {model: account.account}: |
from openerp.tools import float_compare
debit = self.browse(cr, uid, ref('account_anglo_stock_input')).debit
float_compare(debit, 9, precision_digits=2) == 0, "Stock Interim account (Received) is not debited successfully."
-
I check the Price difference creditor Account is debited sucessfully when Invoice validated.
-
!assert {model: account.account, id : account_anglo_price_difference, string : Price difference creditor Account is not debited successfully.}:
- debit == 1
!python {model: account.account}: |
from openerp.tools import float_compare
debit = self.browse(cr, uid, ref('account_anglo_price_difference')).debit
float_compare(debit, 1, precision_digits=2) == 0, "Price difference creditor Account is not debited successfully."
-
I check Payable(creditor) Account is Credited sucessfully when Invoice validated.
-
!assert {model: account.account, id : account_anglo_payable, string : Payable(creditor) Account is not Credited successfully.}:
- credit == 10
!python {model: account.account}: |
from openerp.tools import float_compare
credit = self.browse(cr, uid, ref('account_anglo_payable')).credit
float_compare(credit, 10, precision_digits=2) == 0, "Payable(creditor) Account is not Credited successfully."
-
I open the Invoice.
-
Expand All @@ -179,13 +189,17 @@
-
I check Payable(Creditors) Account is Debited sucessfully after invoice paid.
-
!assert {model: account.account, id : account_anglo_payable, string : Payable(Creditors) Account is not Debited successfully.}:
- debit == 10
!python {model: account.account}: |
from openerp.tools import float_compare
debit = self.browse(cr, uid, ref('account_anglo_payable')).debit
assert float_compare(debit, 10, precision_digits=2) == 0, "Payable(Creditors) Account is not Debited successfully."
-
I check Bank/Cash account is credited sucessfully after invoice paid.
-
!assert {model: account.account, id : account_anglo_cash, string: Bank/Cash account is not credited successfully.}:
- credit == 10
!python {model: account.account}: |
from openerp.tools import float_compare
credit = self.browse(cr, uid, ref('account_anglo_cash')).credit
float_compare(credit, 10, precision_digits=2) == 0, "Bank/Cash account is not credited successfully."
-
I create an Outgoing Picking order
-
Expand Down Expand Up @@ -225,13 +239,17 @@
-
I check Stock Interim account (Delivery) is debited successfully.
-
!assert {model: account.account, id : account_anglo_stock_output, string : Stock Interim account (Delivery) is not debited successfully.}:
- debit == 9
!python {model: account.account}: |
from openerp.tools import float_compare
debit = self.browse(cr, uid, ref('account_anglo_stock_output')).debit
float_compare(debit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not debited successfully."
-
I check the Stock valuation account is credited sucessfully.
-
!assert {model: account.account, id : account_anglo_stock_valuation, string : Stock valuation account is not credited successfully.}:
- credit == 9
!python {model: account.account}: |
from openerp.tools import float_compare
credit = self.browse(cr, uid, ref('account_anglo_stock_valuation')).credit
float_compare(credit, 9, precision_digits=2) == 0, "Stock valuation account is not credited successfully."
-
As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order.
-
Expand All @@ -256,23 +274,31 @@
-
I check Income Account is Credited sucessfully when Invoice validated.
-
!assert {model: account.account, id : account_anglo_income, string : Income Account is not Credited successfully.}:
- credit == 20
!python {model: account.account}: |
from openerp.tools import float_compare
credit = self.browse(cr, uid, ref('account_anglo_income')).credit
float_compare(credit, 20, precision_digits=2) == 0, "Income Account is not Credited successfully."
-
I check Cost of goods sold account for debit.
-
!assert {model: account.account, id : account_anglo_cogs, string : Cost of goods sale is not Debited successfully.}:
- debit == 9
!python {model: account.account}: |
from openerp.tools import float_compare
debit = self.browse(cr, uid, ref('account_anglo_cogs')).debit
float_compare(debit, 9, precision_digits=2) == 0, "Cost of goods sale is not Debited successfully."
-
I check Stock Interim account (Delivery)
-
!assert {model: account.account, id : account_anglo_stock_output, string : Stock Interim account (Delivery) is not credited successfully.}:
- credit == 9
!python {model: account.account}: |
from openerp.tools import float_compare
credit = self.browse(cr, uid, ref('account_anglo_stock_output')).credit
float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not credited successfully."
-
I check Receivable(Debtor) Account for debit.
-
!assert {model: account.account, id : account_anglo_receivable, string : Receivable(Debtors) Account is not Debited successfully.}:
- debit == 20
!python {model: account.account}: |
from openerp.tools import float_compare
debit = self.browse(cr, uid, ref('account_anglo_receivable')).debit
float_compare(debit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Debited successfully."
-
I pay the invoice.
-
Expand All @@ -289,10 +315,14 @@
-
I check Receivable(Debtor) Account for credit.
-
!assert {model: account.account, id : account_anglo_receivable, string : Receivable(Debtors) Account is not Credited successfully.}:
- credit == 20
!python {model: account.account}: |
from openerp.tools import float_compare
credit = self.browse(cr, uid, ref('account_anglo_receivable')).credit
float_compare(credit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Credited successfully."
-
I check Bank/Cash account is debited sucessfully after invoice paid.
-
!assert {model: account.account, id : account_anglo_cash, string: Bank/Cash account is not successfully credited.}:
- debit == 20
!python {model: account.account}: |
from openerp.tools import float_compare
debit = self.browse(cr, uid, ref('account_anglo_cash')).debit
float_compare(debit, 20, precision_digits=2) == 0, "Bank/Cash account is not successfully credited."
Loading

0 comments on commit bb5fd86

Please sign in to comment.