From 5fb5ec4e02ff097268f8cd5c254d0fc98d82b806 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Wed, 19 Nov 2014 14:02:56 +0100 Subject: [PATCH] Add tests to check if the reports and csv export are generated --- account_journal_report_xls/__openerp__.py | 6 + .../export_csv_journal_by_fiscal_year.yml | 83 ++++++++++++++ .../tests/export_csv_journal_by_period.yml | 107 ++++++++++++++++++ .../tests/print_journal_by_fiscal_year.yml | 83 ++++++++++++++ .../tests/print_journal_by_period.yml | 107 ++++++++++++++++++ 5 files changed, 386 insertions(+) create mode 100644 account_journal_report_xls/tests/export_csv_journal_by_fiscal_year.yml create mode 100644 account_journal_report_xls/tests/export_csv_journal_by_period.yml create mode 100644 account_journal_report_xls/tests/print_journal_by_fiscal_year.yml create mode 100644 account_journal_report_xls/tests/print_journal_by_period.yml diff --git a/account_journal_report_xls/__openerp__.py b/account_journal_report_xls/__openerp__.py index 4355f87c..dcd88583 100644 --- a/account_journal_report_xls/__openerp__.py +++ b/account_journal_report_xls/__openerp__.py @@ -34,5 +34,11 @@ 'data': [ 'wizard/print_journal_wizard.xml', ], + 'test': [ + 'tests/print_journal_by_fiscal_year.yml', + 'tests/print_journal_by_period.yml', + 'tests/export_csv_journal_by_fiscal_year.yml', + 'tests/export_csv_journal_by_period.yml', + ], 'installable': True, } diff --git a/account_journal_report_xls/tests/export_csv_journal_by_fiscal_year.yml b/account_journal_report_xls/tests/export_csv_journal_by_fiscal_year.yml new file mode 100644 index 00000000..0275c402 --- /dev/null +++ b/account_journal_report_xls/tests/export_csv_journal_by_fiscal_year.yml @@ -0,0 +1,83 @@ +- + In order to test the Excel General Ledger webkit wizard I will print report on all the journals +- + !python {model: account.account}: | + ctx = {} + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_fiscalyear_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='xls_export', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report with entries sorted by date +- + !python {model: account.account}: | + ctx = {} + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'sort_selection': 'l.date', + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_fiscalyear_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='xls_export', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report without grouped entries +- + !python {model: account.account}: | + ctx = {} + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'group_entries': False, + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_fiscalyear_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='xls_export', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report with currency +- + !python {model: account.account}: | + ctx = {} + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'amount_currency': False, + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_fiscalyear_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='xls_export', + our_module='account_journal_report_xls') + diff --git a/account_journal_report_xls/tests/export_csv_journal_by_period.yml b/account_journal_report_xls/tests/export_csv_journal_by_period.yml new file mode 100644 index 00000000..bc2e0f07 --- /dev/null +++ b/account_journal_report_xls/tests/export_csv_journal_by_period.yml @@ -0,0 +1,107 @@ +- + In order to test the Excel General Ledger webkit wizard I will print report on all the journals +- + !python {model: account.account}: | + ctx = {} + fiscalyear_id = self.pool['account.fiscalyear'].search(cr, uid, [])[0] + wizard = self.pool['account.print.journal.xls'] + period_ids = wizard.fy_period_ids(cr, uid, fiscalyear_id) + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'fiscalyear_id': fiscalyear_id, + 'period_from': period_ids[0], + 'period_to': period_ids[-1], + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_period_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='xls_export', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report with entries sorted by date +- + !python {model: account.account}: | + ctx = {} + fiscalyear_id = self.pool['account.fiscalyear'].search(cr, uid, [])[0] + wizard = self.pool['account.print.journal.xls'] + period_ids = wizard.fy_period_ids(cr, uid, fiscalyear_id) + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'sort_selection': 'l.date', + 'fiscalyear_id': fiscalyear_id, + 'period_from': period_ids[0], + 'period_to': period_ids[-1], + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_period_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='xls_export', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report without grouped entries +- + !python {model: account.account}: | + ctx = {} + fiscalyear_id = self.pool['account.fiscalyear'].search(cr, uid, [])[0] + wizard = self.pool['account.print.journal.xls'] + period_ids = wizard.fy_period_ids(cr, uid, fiscalyear_id) + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'group_entries': False, + 'fiscalyear_id': fiscalyear_id, + 'period_from': period_ids[0], + 'period_to': period_ids[-1], + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_period_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='xls_export', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report with currency +- + !python {model: account.account}: | + ctx = {} + fiscalyear_id = self.pool['account.fiscalyear'].search(cr, uid, [])[0] + wizard = self.pool['account.print.journal.xls'] + period_ids = wizard.fy_period_ids(cr, uid, fiscalyear_id) + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'amount_currency': False, + 'fiscalyear_id': fiscalyear_id, + 'period_from': period_ids[0], + 'period_to': period_ids[-1], + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_period_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='xls_export', + our_module='account_journal_report_xls') + diff --git a/account_journal_report_xls/tests/print_journal_by_fiscal_year.yml b/account_journal_report_xls/tests/print_journal_by_fiscal_year.yml new file mode 100644 index 00000000..27d6826f --- /dev/null +++ b/account_journal_report_xls/tests/print_journal_by_fiscal_year.yml @@ -0,0 +1,83 @@ +- + In order to test the Excel General Ledger webkit wizard I will print report on all the journals +- + !python {model: account.account}: | + ctx = {} + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_fiscalyear_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='print_report', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report with entries sorted by date +- + !python {model: account.account}: | + ctx = {} + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'sort_selection': 'l.date', + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_fiscalyear_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='print_report', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report without grouped entries +- + !python {model: account.account}: | + ctx = {} + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'group_entries': False, + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_fiscalyear_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='print_report', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report with currency +- + !python {model: account.account}: | + ctx = {} + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'amount_currency': False, + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_fiscalyear_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='print_report', + our_module='account_journal_report_xls') + diff --git a/account_journal_report_xls/tests/print_journal_by_period.yml b/account_journal_report_xls/tests/print_journal_by_period.yml new file mode 100644 index 00000000..eb36060c --- /dev/null +++ b/account_journal_report_xls/tests/print_journal_by_period.yml @@ -0,0 +1,107 @@ +- + In order to test the Excel General Ledger webkit wizard I will print report on all the journals +- + !python {model: account.account}: | + ctx = {} + fiscalyear_id = self.pool['account.fiscalyear'].search(cr, uid, [])[0] + wizard = self.pool['account.print.journal.xls'] + period_ids = wizard.fy_period_ids(cr, uid, fiscalyear_id) + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'fiscalyear_id': fiscalyear_id, + 'period_from': period_ids[0], + 'period_to': period_ids[-1], + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_period_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='print_report', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report with entries sorted by date +- + !python {model: account.account}: | + ctx = {} + fiscalyear_id = self.pool['account.fiscalyear'].search(cr, uid, [])[0] + wizard = self.pool['account.print.journal.xls'] + period_ids = wizard.fy_period_ids(cr, uid, fiscalyear_id) + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'sort_selection': 'l.date', + 'fiscalyear_id': fiscalyear_id, + 'period_from': period_ids[0], + 'period_to': period_ids[-1], + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_period_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='print_report', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report without grouped entries +- + !python {model: account.account}: | + ctx = {} + fiscalyear_id = self.pool['account.fiscalyear'].search(cr, uid, [])[0] + wizard = self.pool['account.print.journal.xls'] + period_ids = wizard.fy_period_ids(cr, uid, fiscalyear_id) + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'group_entries': False, + 'fiscalyear_id': fiscalyear_id, + 'period_from': period_ids[0], + 'period_to': period_ids[-1], + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_period_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='print_report', + our_module='account_journal_report_xls') + +- + In order to test the Excel General Ledger webkit wizard I will print report with currency +- + !python {model: account.account}: | + ctx = {} + fiscalyear_id = self.pool['account.fiscalyear'].search(cr, uid, [])[0] + wizard = self.pool['account.print.journal.xls'] + period_ids = wizard.fy_period_ids(cr, uid, fiscalyear_id) + data_dict = {'chart_account_id': ref('account.chart0'), + 'journal_ids': self.pool['account.journal'].search(cr, uid, []), + 'amount_currency': False, + 'fiscalyear_id': fiscalyear_id, + 'period_from': period_ids[0], + 'period_to': period_ids[-1], + } + ctx.update({'model': 'account.account', + 'active_ids': [ref('account.chart0')], + 'active_id': ref('account.chart0')}) + from openerp.tools import test_reports + test_reports.try_report_action( + cr, uid, + 'account_journal_report_xls.action_print_journal_by_period_xls', + wiz_data=data_dict, + context=ctx, + wiz_buttons='print_report', + our_module='account_journal_report_xls') +