From 71fd99a7c7eaec7cec68bea10c9553a6e3d8a6b4 Mon Sep 17 00:00:00 2001 From: bde Date: Wed, 29 Jun 2011 18:46:26 +0530 Subject: [PATCH 1/5] [ADD] Added YML Test Case bzr revid: bde@tiny2-desktop-20110629131626-88q6nir4is9zzga5 --- addons/account_asset/__openerp__.py | 2 + addons/account_asset/account_asset.py | 3 +- addons/account_asset/test/account_asset.yml | 68 +++++++++++++++++++++ 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 addons/account_asset/test/account_asset.yml diff --git a/addons/account_asset/__openerp__.py b/addons/account_asset/__openerp__.py index be631a91e45..d0429a27169 100755 --- a/addons/account_asset/__openerp__.py +++ b/addons/account_asset/__openerp__.py @@ -36,6 +36,8 @@ ], "demo_xml" : [ ], + 'test': ['test/account_asset.yml', + ], "update_xml" : [ "security/ir.model.access.csv", "account_asset_wizard.xml", diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index c67a60e0da2..380bf3368a5 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -116,9 +116,7 @@ class account_asset_asset(osv.osv): old_depreciation_line_ids = depreciation_lin_obj.search(cr, uid, [('asset_id', '=', asset.id), ('move_id', '=', False)]) if old_depreciation_line_ids: depreciation_lin_obj.unlink(cr, uid, old_depreciation_line_ids, context=context) - amount_to_depr = residual_amount = asset.value_residual - depreciation_date = datetime.strptime(self._get_last_depreciation_date(cr, uid, [asset.id], context)[asset.id], '%Y-%m-%d') day = depreciation_date.day month = depreciation_date.month @@ -350,6 +348,7 @@ class account_asset_asset(osv.osv): if period and (period.date_start<=date_start): result += self._compute_move(cr, uid, property, period, context) return result + account_asset_asset() class account_asset_depreciation_line(osv.osv): diff --git a/addons/account_asset/test/account_asset.yml b/addons/account_asset/test/account_asset.yml new file mode 100644 index 00000000000..3fe5a0fb352 --- /dev/null +++ b/addons/account_asset/test/account_asset.yml @@ -0,0 +1,68 @@ +- + In order to test Account Asset feature first i created Asset Category then Account Asset +- + Creating a account.asset.category record +- + !record {model: account.asset.category, id: account_asset_category_fixed_assets0}: + account_asset_id: account.xfa + account_depreciation_id: account.xfa + account_expense_depreciation_id: account.a_recv + company_id: base.main_company + journal_id: account.bank_journal + method: linear + method_time: delay + name: Fixed Assets + +- + Creating a account.asset.asset record +- + !record {model: account.asset.asset, id: account_asset_asset_car0}: + category_id: account_asset_category_fixed_assets0 + code: a + company_id: base.main_company + currency_id: base.EUR + method: linear + method_time: delay + method_delay: 5 + method_period: 12 + name: Car + partner_id: base.res_partner_14 + period_id: account.period_6 + purchase_date: '2011-06-29' + purchase_value: 5000.0 + salvage_value: 2000.0 + state: draft +- + I check that Initially Account Asset is in the "Draft" state +- + !assert {model: account.asset.asset, id: account_asset_asset_car0}: + - state == 'draft' +- + I Confirm Account Asset using Confirm Asset button +- + !python {model: account.asset.asset}: | + self.validate(cr, uid, [ref("account_asset_asset_car0")]) +- + I compute Account Asset using Compute button and check the number of depreciation lines created are proper +- + !python {model: account.asset.asset}: | + self.compute_depreciation_board(cr, uid, [ref("account_asset_asset_car0")]) + for value in self.browse(cr, uid, [ref("account_asset_asset_car0")]): + assert value.method_delay == len(value.depreciation_line_ids) +- + I Create Account Asset Move using using create move method +- + !python {model: account.asset.depreciation.line}: | + ids = self.search(cr, uid, [('asset_id','=',ref('account_asset_asset_car0'))]) + self.create_move(cr, uid, ids) +- + I check that After creating all the moves of asset the state is in "Close" state +- + !assert {model: account.asset.asset, id: account_asset_asset_car0}: + - state == 'close' +- + I check that after the state is closed the rsidual value becomes 0 +- + !assert {model: account.asset.asset, id: account_asset_asset_car0}: + - value_residual == 0.0 + From 29b51be017f248583d2d1ee8e18f59e086e6b547 Mon Sep 17 00:00:00 2001 From: bde Date: Thu, 30 Jun 2011 14:46:01 +0530 Subject: [PATCH 2/5] [IMP] Improved YML Test Case bzr revid: bde@tiny2-desktop-20110630091601-uz9qjkhe2y9nwmwu --- addons/account_asset/test/account_asset.yml | 59 +++++++++------------ 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/addons/account_asset/test/account_asset.yml b/addons/account_asset/test/account_asset.yml index 3fe5a0fb352..00734be3f7e 100644 --- a/addons/account_asset/test/account_asset.yml +++ b/addons/account_asset/test/account_asset.yml @@ -1,68 +1,57 @@ - - In order to test Account Asset feature first i created Asset Category then Account Asset + In order to test Account Asset feature first I will create Asset Category - - Creating a account.asset.category record + I will Create an Asset Category Record - - !record {model: account.asset.category, id: account_asset_category_fixed_assets0}: + !record {model: account.asset.category, id: account_asset_category_landbuildings0}: account_asset_id: account.xfa account_depreciation_id: account.xfa - account_expense_depreciation_id: account.a_recv - company_id: base.main_company - journal_id: account.bank_journal - method: linear - method_time: delay - name: Fixed Assets - + account_expense_depreciation_id: account.a_expense + journal_id: account.expenses_journal + name: Land & Buildings - - Creating a account.asset.asset record + I will Create an Account Asset Record - - !record {model: account.asset.asset, id: account_asset_asset_car0}: - category_id: account_asset_category_fixed_assets0 + !record {model: account.asset.asset, id: account_asset_asset_Land0}: + category_id: account_asset_category_landbuildings0 code: a - company_id: base.main_company - currency_id: base.EUR - method: linear - method_time: delay - method_delay: 5 - method_period: 12 - name: Car + name: Land partner_id: base.res_partner_14 period_id: account.period_6 - purchase_date: '2011-06-29' purchase_value: 5000.0 salvage_value: 2000.0 state: draft - - I check that Initially Account Asset is in the "Draft" state + I will check initially that Account Asset is in the "Draft" state - - !assert {model: account.asset.asset, id: account_asset_asset_car0}: + !assert {model: account.asset.asset, id: account_asset_asset_Land0}: - state == 'draft' - - I Confirm Account Asset using Confirm Asset button + I will Confirm Account Asset using Confirm Asset button - !python {model: account.asset.asset}: | - self.validate(cr, uid, [ref("account_asset_asset_car0")]) + self.validate(cr, uid, [ref("account_asset_asset_Land0")]) - - I compute Account Asset using Compute button and check the number of depreciation lines created are proper + I will compute Account Asset using Compute button and check the number of depreciation lines created are proper - !python {model: account.asset.asset}: | - self.compute_depreciation_board(cr, uid, [ref("account_asset_asset_car0")]) - for value in self.browse(cr, uid, [ref("account_asset_asset_car0")]): - assert value.method_delay == len(value.depreciation_line_ids) + self.compute_depreciation_board(cr, uid, [ref("account_asset_asset_Land0")]) + value = self.browse(cr, uid, [ref("account_asset_asset_Land0")])[0] + assert value.method_delay == len(value.depreciation_line_ids) - - I Create Account Asset Move using using create move method + I will Create Account Asset Move using using create move method - !python {model: account.asset.depreciation.line}: | - ids = self.search(cr, uid, [('asset_id','=',ref('account_asset_asset_car0'))]) + ids = self.search(cr, uid, [('asset_id','=',ref('account_asset_asset_Land0'))]) self.create_move(cr, uid, ids) - - I check that After creating all the moves of asset the state is in "Close" state + I will check that After creating all the moves of the asset the state is in "Close" state - - !assert {model: account.asset.asset, id: account_asset_asset_car0}: + !assert {model: account.asset.asset, id: account_asset_asset_Land0}: - state == 'close' - - I check that after the state is closed the rsidual value becomes 0 + I will check when the state of Account asset is close the residual value becomes 0 - - !assert {model: account.asset.asset, id: account_asset_asset_car0}: + !assert {model: account.asset.asset, id: account_asset_asset_Land0}: - value_residual == 0.0 From bc362510c409f73ccd2d34591be7310ca2473216 Mon Sep 17 00:00:00 2001 From: bde Date: Thu, 30 Jun 2011 15:28:09 +0530 Subject: [PATCH 3/5] [IMP] Improved the YML Test Case bzr revid: bde@tiny2-desktop-20110630095809-7q01fu15bpameshc --- addons/account_asset/test/account_asset.yml | 22 ++++++++------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/addons/account_asset/test/account_asset.yml b/addons/account_asset/test/account_asset.yml index 00734be3f7e..638d55e45f3 100644 --- a/addons/account_asset/test/account_asset.yml +++ b/addons/account_asset/test/account_asset.yml @@ -1,7 +1,7 @@ - - In order to test Account Asset feature first I will create Asset Category + In order to test Account Asset feature first I create Asset Category - - I will Create an Asset Category Record + I Create an Asset Category Record - !record {model: account.asset.category, id: account_asset_category_landbuildings0}: account_asset_id: account.xfa @@ -10,7 +10,7 @@ journal_id: account.expenses_journal name: Land & Buildings - - I will Create an Account Asset Record + I Create an Account Asset Record - !record {model: account.asset.asset, id: account_asset_asset_Land0}: category_id: account_asset_category_landbuildings0 @@ -22,36 +22,30 @@ salvage_value: 2000.0 state: draft - - I will check initially that Account Asset is in the "Draft" state + I check Initially that Account Asset is in the "Draft" state - !assert {model: account.asset.asset, id: account_asset_asset_Land0}: - state == 'draft' - - I will Confirm Account Asset using Confirm Asset button + I Confirm Account Asset using Confirm Asset button - !python {model: account.asset.asset}: | self.validate(cr, uid, [ref("account_asset_asset_Land0")]) - - I will compute Account Asset using Compute button and check the number of depreciation lines created are proper + I Compute Account Asset using Compute button and check the number of depreciation lines created are proper - !python {model: account.asset.asset}: | self.compute_depreciation_board(cr, uid, [ref("account_asset_asset_Land0")]) value = self.browse(cr, uid, [ref("account_asset_asset_Land0")])[0] assert value.method_delay == len(value.depreciation_line_ids) - - I will Create Account Asset Move using using create move method + I Create Account Asset Move using using create move method - !python {model: account.asset.depreciation.line}: | ids = self.search(cr, uid, [('asset_id','=',ref('account_asset_asset_Land0'))]) self.create_move(cr, uid, ids) - - I will check that After creating all the moves of the asset the state is in "Close" state + I Check that After creating all the moves of the asset the state is in "Close" state - !assert {model: account.asset.asset, id: account_asset_asset_Land0}: - state == 'close' -- - I will check when the state of Account asset is close the residual value becomes 0 -- - !assert {model: account.asset.asset, id: account_asset_asset_Land0}: - - value_residual == 0.0 - From 2ec1ebd07c82361311ca44c7b6cab4ca90f6b7c6 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Thu, 30 Jun 2011 16:00:46 +0530 Subject: [PATCH 4/5] [IMP] Account_asset: Yml improved bzr revid: mra@mra-laptop-20110630103046-xiocrhjdefoi9lm1 --- addons/account_asset/test/account_asset.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/addons/account_asset/test/account_asset.yml b/addons/account_asset/test/account_asset.yml index 638d55e45f3..fd3f972c8c7 100644 --- a/addons/account_asset/test/account_asset.yml +++ b/addons/account_asset/test/account_asset.yml @@ -1,7 +1,7 @@ - - In order to test Account Asset feature first I create Asset Category + In order to test Account Asset I create Asset and confirm it and check it's Depriciation lines - - I Create an Asset Category Record + I Create an Asset Category - !record {model: account.asset.category, id: account_asset_category_landbuildings0}: account_asset_id: account.xfa @@ -10,7 +10,7 @@ journal_id: account.expenses_journal name: Land & Buildings - - I Create an Account Asset Record + I Create an Account Asset - !record {model: account.asset.asset, id: account_asset_asset_Land0}: category_id: account_asset_category_landbuildings0 @@ -19,7 +19,6 @@ partner_id: base.res_partner_14 period_id: account.period_6 purchase_value: 5000.0 - salvage_value: 2000.0 state: draft - I check Initially that Account Asset is in the "Draft" state @@ -32,20 +31,26 @@ !python {model: account.asset.asset}: | self.validate(cr, uid, [ref("account_asset_asset_Land0")]) - - I Compute Account Asset using Compute button and check the number of depreciation lines created are proper + I check Asset is in running state after pressing Confirm button on asset +- + !assert {model: account.asset.asset, id: account_asset_asset_Land0}: + - state == 'open' +- + I Compute Account Asset using Compute button and check the number of depreciation lines created - !python {model: account.asset.asset}: | self.compute_depreciation_board(cr, uid, [ref("account_asset_asset_Land0")]) + # pressing computation button can be remove if creation of depreciation lines while asset is created value = self.browse(cr, uid, [ref("account_asset_asset_Land0")])[0] assert value.method_delay == len(value.depreciation_line_ids) - - I Create Account Asset Move using using create move method + I Create Account Move using create move button on depreciation lines - !python {model: account.asset.depreciation.line}: | ids = self.search(cr, uid, [('asset_id','=',ref('account_asset_asset_Land0'))]) self.create_move(cr, uid, ids) - - I Check that After creating all the moves of the asset the state is in "Close" state + I Check that After creating all the moves of depreciation lines the state is in "Close" state - !assert {model: account.asset.asset, id: account_asset_asset_Land0}: - state == 'close' From 9ae8f375828726d6ce8a515830374cb7ec347ea5 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Thu, 30 Jun 2011 16:04:45 +0530 Subject: [PATCH 5/5] [IMP] Account_asset: Yml improved bzr revid: mra@mra-laptop-20110630103445-7b1ffhugdaefccve --- addons/account_asset/test/account_asset.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_asset/test/account_asset.yml b/addons/account_asset/test/account_asset.yml index fd3f972c8c7..04a2486db58 100644 --- a/addons/account_asset/test/account_asset.yml +++ b/addons/account_asset/test/account_asset.yml @@ -14,7 +14,7 @@ - !record {model: account.asset.asset, id: account_asset_asset_Land0}: category_id: account_asset_category_landbuildings0 - code: a + code: land name: Land partner_id: base.res_partner_14 period_id: account.period_6