From aef10266151facd2321c83caba7b96ebdfb5cbb6 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Thu, 10 Apr 2014 09:04:35 +0200 Subject: [PATCH] [ADD] Scenario that test coherence of credit run after manually altering an invoice level --- .../09_credit_control_run_jul.feature | 8 +++--- .../11_credit_control_manual_setting.feature | 21 +++++++++++++++- .../steps/account_credit_control_changer.py | 25 +++++++++++++++++++ 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/account_credit_control/scenarios/features/09_credit_control_run_jul.feature b/account_credit_control/scenarios/features/09_credit_control_run_jul.feature index 159fdc1ec..9bd9df52d 100644 --- a/account_credit_control/scenarios/features/09_credit_control_run_jul.feature +++ b/account_credit_control/scenarios/features/09_credit_control_run_jul.feature @@ -13,10 +13,10 @@ Feature: Ensure that email credit line generation first pass is correct @account_credit_control_mark - Scenario: mark lines - Given there is "draft" credit lines - And I mark all draft email to state "to_be_sent" - Then the draft line should be in state "to_be_sent" + Scenario: mark lines + Given there is "draft" credit lines + And I mark all draft email to state "to_be_sent" + Then the draft line should be in state "to_be_sent" @account_credit_control_run_month Scenario: Create run diff --git a/account_credit_control/scenarios/features/11_credit_control_manual_setting.feature b/account_credit_control/scenarios/features/11_credit_control_manual_setting.feature index af11289dd..bfe2aa811 100644 --- a/account_credit_control/scenarios/features/11_credit_control_manual_setting.feature +++ b/account_credit_control/scenarios/features/11_credit_control_manual_setting.feature @@ -8,7 +8,7 @@ # Features Generic tags (none for all) ############################################################################## -@account_credit_control @account_credit_control_run @account_credit_control_run_aug +@account_credit_control @account_credit_control_run @account_credit_control_run_change_level Feature: Ensure that manually changing an invoice level feature works as expected @@ -21,3 +21,22 @@ Feature: Ensure that manually changing an invoice level feature works as expect When I confirm the level change And I should have "3" credit control lines overriden And one new credit control line of level "10 days net" related to invoice "SAJ/2014/0004" + Then I force date of generated credit line to "2013-09-15" + + @account_credit_control_run_month_sept + Scenario: Create run + Given there is "draft" credit lines + And I mark all draft email to state "to_be_sent" + Then the draft line should be in state "to_be_sent" + Given I need a "credit.control.run" with oid: credit_control.manual_change + And having: + | name | value | + | date | 2013-09-30 | + When I launch the credit run + Then my credit run should be in state "done" + + @account_credit_control_manual_next_step + Scenario: Check manually managed line on run + Given the invoice "SAJ/2014/0004" with manual changes + And the invoice has "1" line of level "1" for policy "3 time policy" + And the invoice has "1" line of level "2" for policy "3 time policy" diff --git a/account_credit_control/scenarios/features/steps/account_credit_control_changer.py b/account_credit_control/scenarios/features/steps/account_credit_control_changer.py index 855e36365..b3625b1c0 100644 --- a/account_credit_control/scenarios/features/steps/account_credit_control_changer.py +++ b/account_credit_control/scenarios/features/steps/account_credit_control_changer.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- @given(u'I change level for invoice "{invoice_name}" to "{level_name}" of policy "{policy_name}"') def impl(ctx, invoice_name, level_name, policy_name): invoice = model('account.invoice').get([('number', '=', invoice_name)]) @@ -46,6 +47,30 @@ def impl(ctx, level_name, invoice_name): assert len(created_id) == 1 created = model('credit.control.line').get(created_id[0]) + ctx.created = created assert_equal(created.policy_level_id.id, level.id) assert_equal(created.invoice_id.id, invoice.id) assert_equal(created.invoice_id.credit_policy_id.id, level.policy_id.id) + +@then(u'I force date of generated credit line to "{date}"') +def impl(ctx, date): + assert_true(ctx.created) + ctx.created.write({'date': date}) + +@given(u'the invoice "{invoice_name}" with manual changes') +def impl(ctx, invoice_name): + invoice = model('account.invoice').get([('number', '=', invoice_name)]) + assert_true(invoice, msg='No invoices found') + man_lines = (x for x in invoice.credit_control_line_ids if x.manually_overriden) + assert_true(next(man_lines, None), 'No manual change on the invoice') + ctx.invoice = invoice + +@given(u'the invoice has "{line_number:d}" line of level "{level:d}" for policy "{policy_name}"') +def impl(ctx, line_number, level, policy_name): + assert_true(ctx.invoice) + policy = model('credit.control.policy').get([('name', '=', policy_name)]) + assert_true(policy) + lines = model('credit.control.line').search([('invoice_id', '=', ctx.invoice.id), + ('level', '=', level), + ('policy_id', '=', policy.id)]) + assert_equal(len(lines), line_number)