From 89e7700d21796d4be8bec6b522d2db7bfbde4fe3 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Fri, 13 Dec 2013 17:25:10 +0100 Subject: [PATCH 1/7] [add] tests for account_statement_base_completion: customer invoice --- .../__openerp__.py | 5 ++- .../test/TODO.txt | 3 ++ .../test/completion_test.yml | 31 ++++++++++++++++++ .../test/invoice.yml | 32 +++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 account_statement_base_completion/test/TODO.txt create mode 100644 account_statement_base_completion/test/completion_test.yml create mode 100644 account_statement_base_completion/test/invoice.yml diff --git a/account_statement_base_completion/__openerp__.py b/account_statement_base_completion/__openerp__.py index d868a314..3147822f 100644 --- a/account_statement_base_completion/__openerp__.py +++ b/account_statement_base_completion/__openerp__.py @@ -66,7 +66,10 @@ 'security/ir.model.access.csv', ], 'demo_xml': [], - 'test': [], + 'test': [ + 'test/invoice.yml', + 'test/completion_test.yml' + ], 'installable': True, 'images': [], 'auto_install': False, diff --git a/account_statement_base_completion/test/TODO.txt b/account_statement_base_completion/test/TODO.txt new file mode 100644 index 00000000..42bd3f37 --- /dev/null +++ b/account_statement_base_completion/test/TODO.txt @@ -0,0 +1,3 @@ +* statement default company, or company required? +* on_change +* statment doesn't have a company, why? \ No newline at end of file diff --git a/account_statement_base_completion/test/completion_test.yml b/account_statement_base_completion/test/completion_test.yml new file mode 100644 index 00000000..4936094f --- /dev/null +++ b/account_statement_base_completion/test/completion_test.yml @@ -0,0 +1,31 @@ +- + In order to test the banking framework, I first need to create a profile +- + !record {model: account.statement.profile, id: profile_test1}: + name: Bank EUR Profile + journal_id: account.bank_journal + commission_account_id: account.a_expense + company_id: base.main_company + balance_check: True + rule_ids: + - bank_statement_completion_rule_4 + - bank_statement_completion_rule_5 + - bank_statement_completion_rule_2 + - bank_statement_completion_rule_3 +- + Now I create a statement +- + !record {model: account.bank.statement, id: statement_test1}: + name: Statement 2 + profile_id: profile_test1 + company_id: base.main_company + line_ids: + - name: Test autocompletion based on Invoice Number + ref: CI0001 + date: '2013-12-13' + amount: 2100.0 +- + I run the auto complete +- + !python {model: account.bank.statement}: | + result = self.button_auto_completion(cr, uid, [ref("statement_test1")]) diff --git a/account_statement_base_completion/test/invoice.yml b/account_statement_base_completion/test/invoice.yml new file mode 100644 index 00000000..5b6845f5 --- /dev/null +++ b/account_statement_base_completion/test/invoice.yml @@ -0,0 +1,32 @@ +- + I create a customer Invoice to be found by the completion. +- + !record {model: account.invoice, id: invoice_for_completion_1}: + account_id: account.a_recv + company_id: base.main_company + currency_id: base.EUR + internal_number: CI0001 + invoice_line: + - account_id: account.a_sale + name: '[PCSC234] PC Assemble SC234' + price_unit: 450.0 + quantity: 1.0 + product_id: product.product_product_3 + uos_id: product.product_uom_unit + journal_id: account.bank_journal + partner_id: base.res_partner_12 + reference_type: none +- + I confirm the Invoice +- + !workflow {model: account.invoice, action: invoice_open, ref: invoice_for_completion_1} +- + I check that the invoice state is "Open" +- + !assert {model: account.invoice, id: invoice_for_completion_1}: + - state == 'open' +- + I check that it is given the number "CI0001" +- + !assert {model: account.invoice, id: invoice_for_completion_1, string: Check CI number}: + - number == 'CI0001' From ea399af06b5d5726f03ac4041135363390364754 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Fri, 13 Dec 2013 20:08:52 +0100 Subject: [PATCH 2/7] [add] statement completion: more tests --- .../__openerp__.py | 1 + .../test/completion_test.yml | 18 +++++++++++++++--- .../test/invoice.yml | 2 +- .../test/partner.yml | 5 +++++ 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 account_statement_base_completion/test/partner.yml diff --git a/account_statement_base_completion/__openerp__.py b/account_statement_base_completion/__openerp__.py index 3147822f..b7e6bdc6 100644 --- a/account_statement_base_completion/__openerp__.py +++ b/account_statement_base_completion/__openerp__.py @@ -67,6 +67,7 @@ ], 'demo_xml': [], 'test': [ + 'test/partner.yml', 'test/invoice.yml', 'test/completion_test.yml' ], diff --git a/account_statement_base_completion/test/completion_test.yml b/account_statement_base_completion/test/completion_test.yml index 4936094f..976a2dac 100644 --- a/account_statement_base_completion/test/completion_test.yml +++ b/account_statement_base_completion/test/completion_test.yml @@ -20,10 +20,22 @@ profile_id: profile_test1 company_id: base.main_company line_ids: - - name: Test autocompletion based on Invoice Number + - name: Test autocompletion based on Customer Invoice Number ref: CI0001 - date: '2013-12-13' - amount: 2100.0 + date: '2013-12-20' + amount: 210.0 + - name: Test autocompletion based on Supplier Invoice Number + ref: T2S12345 + date: '2013-12-19' + amount: -65.0 + - name: Test autocompletion based on Partner Name Vauxoo + ref: / + date: '2013-12-17' + amount: 600.0 + - name: test autocompletion based on text (XXX66Z) matching with partner form information (note that Ref does not exist) + ref: ZU788 + date: '2013-12-24' + amount: -932.4 - I run the auto complete - diff --git a/account_statement_base_completion/test/invoice.yml b/account_statement_base_completion/test/invoice.yml index 5b6845f5..5619f0cd 100644 --- a/account_statement_base_completion/test/invoice.yml +++ b/account_statement_base_completion/test/invoice.yml @@ -9,7 +9,7 @@ invoice_line: - account_id: account.a_sale name: '[PCSC234] PC Assemble SC234' - price_unit: 450.0 + price_unit: 210.0 quantity: 1.0 product_id: product.product_product_3 uos_id: product.product_uom_unit diff --git a/account_statement_base_completion/test/partner.yml b/account_statement_base_completion/test/partner.yml new file mode 100644 index 00000000..bc8fca6c --- /dev/null +++ b/account_statement_base_completion/test/partner.yml @@ -0,0 +1,5 @@ +- + I fill in the field Bank Statement Label in a Partner +- + !record {model: res.partner, id: base.res_partner_6}: + bank_statement_label: XXX66Z From 1a2da08be81af7966424a8b640d80204aa02480f Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Fri, 13 Dec 2013 21:10:44 +0100 Subject: [PATCH 3/7] [imp] completion tests --- .../__openerp__.py | 1 + .../test/completion_test.yml | 58 +++++++++++++------ 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/account_statement_base_completion/__openerp__.py b/account_statement_base_completion/__openerp__.py index b7e6bdc6..2e15450b 100644 --- a/account_statement_base_completion/__openerp__.py +++ b/account_statement_base_completion/__openerp__.py @@ -69,6 +69,7 @@ 'test': [ 'test/partner.yml', 'test/invoice.yml', + 'test/supplier_invoice.yml', 'test/completion_test.yml' ], 'installable': True, diff --git a/account_statement_base_completion/test/completion_test.yml b/account_statement_base_completion/test/completion_test.yml index 976a2dac..796c4b6e 100644 --- a/account_statement_base_completion/test/completion_test.yml +++ b/account_statement_base_completion/test/completion_test.yml @@ -19,25 +19,49 @@ name: Statement 2 profile_id: profile_test1 company_id: base.main_company - line_ids: - - name: Test autocompletion based on Customer Invoice Number - ref: CI0001 - date: '2013-12-20' - amount: 210.0 - - name: Test autocompletion based on Supplier Invoice Number - ref: T2S12345 - date: '2013-12-19' - amount: -65.0 - - name: Test autocompletion based on Partner Name Vauxoo - ref: / - date: '2013-12-17' - amount: 600.0 - - name: test autocompletion based on text (XXX66Z) matching with partner form information (note that Ref does not exist) - ref: ZU788 - date: '2013-12-24' - amount: -932.4 +- + I create a statement line for a CI +- + !record {model: account.bank.statement.line, id: statement_line_ci}: + name: Test autocompletion based on Customer Invoice Number + statement_id: statement_test1 + ref: CI0001 + date: '2013-12-20' + amount: 210.0 +- + I create a statement line for a SI +- + !record {model: account.bank.statement.line, id: statement_line_si}: + name: Test autocompletion based on Supplier Invoice Number + statement_id: statement_test1 + ref: T2S12345 + date: '2013-12-19' + amount: -65.0 +- + I create a statement line for the Partner Name +- + !record {model: account.bank.statement.line, id: statement_line_partner_name}: + name: Test autocompletion based on Partner Name Vauxoo + statement_id: statement_test1 + ref: / + date: '2013-12-17' + amount: 600.0 +- + I create a statement line for the Partner Label +- + !record {model: account.bank.statement.line, id: statement_line_partner_label}: + name: test autocompletion based on text (XXX66Z) matching with partner form information (note that Ref does not exist) + statement_id: statement_test1 + ref: ZU788 + date: '2013-12-24' + amount: -932.4 - I run the auto complete - !python {model: account.bank.statement}: | result = self.button_auto_completion(cr, uid, [ref("statement_test1")]) +- + Now I can check that all is nice and shiny, line 1 +- + !assert {model: account.bank.statement.line, id: statement_line_ci, string: Check completion by CI number}: + - partner_id == ref('res_partner_12') \ No newline at end of file From b16ece087d7e421c1e4df30d301a5ee6553e1f0a Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Fri, 20 Dec 2013 11:55:21 +0100 Subject: [PATCH 4/7] [imp] bank statements: check 4 lines --- .../test/completion_test.yml | 20 ++++++++++++++++++- .../test/supplier_invoice.yml | 14 +++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 account_statement_base_completion/test/supplier_invoice.yml diff --git a/account_statement_base_completion/test/completion_test.yml b/account_statement_base_completion/test/completion_test.yml index 4d8ae085..5b87a959 100644 --- a/account_statement_base_completion/test/completion_test.yml +++ b/account_statement_base_completion/test/completion_test.yml @@ -13,7 +13,8 @@ - bank_statement_completion_rule_2 - bank_statement_completion_rule_3 - - Now I create a statement + Now I create a statement. I create statment lines separately because I need + to find each one by XML id - !record {model: account.bank.statement, id: statement_test1}: name: Statement 2 @@ -67,3 +68,20 @@ - !assert {model: account.bank.statement.line, id: statement_line_ci, string: Check completion by CI number}: - partner_id.id == _ref("base.res_partner_12") +- + Line 2. I expect the Supplier invoice number to be recognised. The supplier + invoice was created by the account module demo data, and we confirmed it + here. +- + !assert {model: account.bank.statement.line, id: statement_line_si, string: Check completion by SI number}: + - partner_id.id == _ref("base.res_partner_17") +- + Line 3. I check that the partner name has been recognised. +- + !assert {model: account.bank.statement.line, id: statement_line_partner_name, string: Check completion by partner name}: + - partner_id.name == 'Vauxoo' +- + Line 4. I check that the partner special label has been recognised. +- + !assert {model: account.bank.statement.line, id: statement_line_partner_label, string: Check completion by partner label}: + - partner_id.id == _ref("base.res_partner_6") diff --git a/account_statement_base_completion/test/supplier_invoice.yml b/account_statement_base_completion/test/supplier_invoice.yml new file mode 100644 index 00000000..24dbad82 --- /dev/null +++ b/account_statement_base_completion/test/supplier_invoice.yml @@ -0,0 +1,14 @@ +- + I add a reference to an existing supplier invoce +- + !record {model: account.invoice, id: account.demo_invoice_0}: + supplier_invoice_number: T2S12345 +- + Now I confirm it +- + !workflow {model: account.invoice, action: invoice_open, ref: account.demo_invoice_0} +- + I check that the supplier number is there +- + !assert {model: account.invoice, id: account.demo_invoice_0, string: Check supplier number}: + - supplier_invoice_number == 'T2S12345' From 562250842a564e6d4b9611c64417934b94dc8547 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Fri, 20 Dec 2013 15:16:41 +0100 Subject: [PATCH 5/7] [fix] yaml: !record is to create. use python write --- .../test/supplier_invoice.yml | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/account_statement_base_completion/test/supplier_invoice.yml b/account_statement_base_completion/test/supplier_invoice.yml index 24dbad82..1bd826f9 100644 --- a/account_statement_base_completion/test/supplier_invoice.yml +++ b/account_statement_base_completion/test/supplier_invoice.yml @@ -1,8 +1,20 @@ +- + I check that my invoice is a supplier invoice +- + !assert {model: account.invoice, id: account.demo_invoice_0, string: Check invoice type}: + - type == 'in_invoice' - I add a reference to an existing supplier invoce - - !record {model: account.invoice, id: account.demo_invoice_0}: - supplier_invoice_number: T2S12345 + !python {model: account.invoice}: | + self.write(cr, uid, ref('account.demo_invoice_0'), { + 'supplier_invoice_number': 'T2S12345' + }) +- + I check a second time that my invoice is still a supplier invoice +- + !assert {model: account.invoice, id: account.demo_invoice_0, string: Check invoice type 2}: + - type == 'in_invoice' - Now I confirm it - @@ -12,3 +24,8 @@ - !assert {model: account.invoice, id: account.demo_invoice_0, string: Check supplier number}: - supplier_invoice_number == 'T2S12345' +- + I check a third time that my invoice is still a supplier invoice +- + !assert {model: account.invoice, id: account.demo_invoice_0, string: Check invoice type 3}: + - type == 'in_invoice' From 53f2c55faaec540881484305b2ee2a6a4de79541 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Fri, 20 Dec 2013 17:25:50 +0100 Subject: [PATCH 6/7] [del] TODO --- account_statement_base_completion/test/TODO.txt | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 account_statement_base_completion/test/TODO.txt diff --git a/account_statement_base_completion/test/TODO.txt b/account_statement_base_completion/test/TODO.txt deleted file mode 100644 index 42bd3f37..00000000 --- a/account_statement_base_completion/test/TODO.txt +++ /dev/null @@ -1,3 +0,0 @@ -* statement default company, or company required? -* on_change -* statment doesn't have a company, why? \ No newline at end of file From ed60c48bea698646c55741b47466f69f407b943a Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Tue, 7 Jan 2014 12:27:26 +0100 Subject: [PATCH 7/7] [add] yaml tests for module account_statement_transactionid_completion --- .../__openerp__.py | 5 ++- .../test/completion_transactionid_test.yml | 44 +++++++++++++++++++ .../test/sale.yml | 11 +++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 account_statement_transactionid_completion/test/completion_transactionid_test.yml create mode 100644 account_statement_transactionid_completion/test/sale.yml diff --git a/account_statement_transactionid_completion/__openerp__.py b/account_statement_transactionid_completion/__openerp__.py index d8c20ea3..46513591 100644 --- a/account_statement_transactionid_completion/__openerp__.py +++ b/account_statement_transactionid_completion/__openerp__.py @@ -48,7 +48,10 @@ "data.xml", ], 'demo_xml': [], - 'test': [], + 'test': [ + 'test/sale.yml', + 'test/completion_transactionid_test.yml', + ], 'installable': True, 'images': [], 'auto_install': True, diff --git a/account_statement_transactionid_completion/test/completion_transactionid_test.yml b/account_statement_transactionid_completion/test/completion_transactionid_test.yml new file mode 100644 index 00000000..5b1cb4bd --- /dev/null +++ b/account_statement_transactionid_completion/test/completion_transactionid_test.yml @@ -0,0 +1,44 @@ +- + In order to test the banking framework, I first need to create a profile +- + !record {model: account.statement.profile, id: statement_profile_transactionid}: + name: Bank EUR Profile (transaction ID) + journal_id: account.bank_journal + commission_account_id: account.a_expense + company_id: base.main_company + balance_check: True + rule_ids: + - bank_statement_completion_rule_4 + - account_statement_base_completion.bank_statement_completion_rule_4 + - account_statement_base_completion.bank_statement_completion_rule_5 + - account_statement_base_completion.bank_statement_completion_rule_2 + - account_statement_base_completion.bank_statement_completion_rule_3 +- + Now I create a statement. I create statment lines separately because I need + to find each one by XML id +- + !record {model: account.bank.statement, id: statement_transactionid_test1}: + name: Statement with transaction ID + profile_id: statement_profile_transactionid + company_id: base.main_company +- + I create a statement line for a SO with transaction ID +- + !record {model: account.bank.statement.line, id: statement_line_transactionid}: + name: Test autocompletion based on SO with transaction ID + statement_id: statement_transactionid_test1 + transaction_id: XXX66Z + ref: 6 + date: '2014-01-06' + amount: 118.4 +- + I run the auto complete +- + !python {model: account.bank.statement}: | + result = self.button_auto_completion(cr, uid, [ref("statement_profile_transactionid")]) +- + Now I can check that all is nice and shiny, line 1. I expect the SO has been + recognised from the transaction ID. +- + !assert {model: account.bank.statement.line, id: statement_line_transactionid, string: Check completion by SO transaction ID}: + - partner_id.name == u'Agrolait' diff --git a/account_statement_transactionid_completion/test/sale.yml b/account_statement_transactionid_completion/test/sale.yml new file mode 100644 index 00000000..a8ba93a9 --- /dev/null +++ b/account_statement_transactionid_completion/test/sale.yml @@ -0,0 +1,11 @@ +- + I create a new Sale Order with transaction ID +- + !record {model: sale.order, id: so_with_transaction_id}: + partner_id: base.res_partner_2 + note: Invoice after delivery + payment_term: account.account_payment_term + transaction_id: XXX66Z + order_line: + - product_id: product.product_product_7 + product_uom_qty: 8