onesteinbv / addons-onestein

Odoo modules developed by Onestein
https://www.onestein.nl/
GNU Affero General Public License v3.0
59 stars 102 forks source link

Failing odoo.sh tests, need to change test class #50

Closed eimantasnejus closed 6 years ago

eimantasnejus commented 6 years ago

Hi, we are pleased with account_cost_center module's functionality, however we use odoo.sh extensively and the way that module's unit tests are written currently causes it to fail. It happens, because every instance of odoo.sh is loaded instantly with all related modules, and modules, dealing with accounting usually face an issue of not finding appropriate Chart of Accounts (COA) and failing unit tests as a result. This happens with the module account_cost_center as well, as you can see from error log (I will add it as a comment, to avoid clogging this issue).

Luckily, this problem can be easily fixed by changing the class, used for running unit tests, related to accounting, simply change TransactionCase with AccountingTestCase, which will run unit tests after COA is loaded.

So, you can solve it by changing two lines of code in addons-onestein/account_cost_center/tests/test_cost_center.py:

# from odoo.tests import common
from odoo.addons.account.tests.account_test_classes import AccountingTestCase

# class TestAccountCostCenter(common.TransactionCase):
class TestAccountCostCenter(AccountingTestCase):

Old code is commented, recommended new code is written below. We are very interested in seeing this change in branch 11.0 as soon as possible, in order to see green odoo.sh again, thanks! :)

eimantasnejus commented 6 years ago

2018-05-22 14:43:53,159 4 INFO focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: ====================================================================== 2018-05-22 14:43:53,159 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: ERROR: test_01_check_lines (odoo.addons.account_cost_center.tests.test_cost_center.TestAccountCostCenter) 2018-05-22 14:43:53,162 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: Traceback (most recent call last): 2018-05-22 14:43:53,164 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: File "/home/odoo/src/user/external/addons-onestein/account_cost_center/tests/test_cost_center.py", line 29, in setUp 2018-05-22 14:43:53,167 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: 'type': 'in_invoice', 2018-05-22 14:43:53,169 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: File "/home/odoo/src/odoo/addons/account/models/account_invoice.py", line 457, in create 2018-05-22 14:43:53,171 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: getattr(invoice, onchange_method)() 2018-05-22 14:43:53,173 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: File "/home/odoo/src/odoo/addons/account/models/account_invoice.py", line 642, in _onchange_partner_id 2018-05-22 14:43:53,175 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: raise RedirectWarning(msg, action.id, _('Go to the configuration panel')) 2018-05-22 14:43:53,177 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: odoo.exceptions.RedirectWarning: ('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.', 279, 'Go to the configuration panel') 2018-05-22 14:43:53,179 4 INFO focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: ====================================================================== 2018-05-22 14:43:53,179 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: ERROR: test_02_confirm_invoice (odoo.addons.account_cost_center.tests.test_cost_center.TestAccountCostCenter) 2018-05-22 14:43:53,180 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: Traceback (most recent call last): 2018-05-22 14:43:53,182 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: File "/home/odoo/src/user/external/addons-onestein/account_cost_center/tests/test_cost_center.py", line 29, in setUp 2018-05-22 14:43:53,184 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: 'type': 'in_invoice', 2018-05-22 14:43:53,186 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: File "/home/odoo/src/odoo/addons/account/models/account_invoice.py", line 457, in create 2018-05-22 14:43:53,188 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: getattr(invoice, onchange_method)() 2018-05-22 14:43:53,189 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: File "/home/odoo/src/odoo/addons/account/models/account_invoice.py", line 642, in _onchange_partner_id 2018-05-22 14:43:53,192 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_costcenter: ` raise RedirectWarning(msg, action.id, ('Go to the configuration panel')) 2018-05-22 14:43:53,193 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: odoo.exceptions.RedirectWarning: ('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.', 279, 'Go to the configuration panel') 2018-05-22 14:43:53,195 4 INFO focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: ====================================================================== 2018-05-22 14:43:53,195 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: ERROR: test_03_fields_view_get (odoo.addons.account_cost_center.tests.test_cost_center.TestAccountCostCenter) 2018-05-22 14:43:53,197 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: Traceback (most recent call last): 2018-05-22 14:43:53,199 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: File "/home/odoo/src/user/external/addons-onestein/account_cost_center/tests/test_cost_center.py", line 29, in setUp 2018-05-22 14:43:53,201 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: 'type': 'in_invoice', 2018-05-22 14:43:53,203 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: File "/home/odoo/src/odoo/addons/account/models/account_invoice.py", line 457, in create 2018-05-22 14:43:53,205 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: getattr(invoice, onchange_method)() 2018-05-22 14:43:53,207 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: File "/home/odoo/src/odoo/addons/account/models/account_invoice.py", line 642, in _onchange_partner_id 2018-05-222 14:43:53,209 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_costcenter: ` raise RedirectWarning(msg, action.id, ('Go to the configuration panel')) 2018-05-22 14:43:53,211 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: ` odoo.exceptions.RedirectWarning: ('Cannot find a chart of accounts for this company, You should configure it. \nPlease go to Account Configuration.', 279, 'Go to the configuration panel') 2018-05-22 14:43:53,213 4 INFO focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: Ran 3 tests in 0.332s 2018-05-22 14:43:53,214 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: FAILED 2018-05-22 14:43:53,216 4 INFO focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.addons.account_cost_center.tests.test_cost_center: (errors=3) 2018-05-22 14:43:53,216 4 ERROR focusate-lt-accounting-feature-66-asset-cost-center-en-59820 odoo.modules.module: Module account_cost_center: 0 failures, 3 errors

astirpe commented 6 years ago

Thanks @eimantasnejus ! I just applied the changes you suggested. Could you check?

eimantasnejus commented 6 years ago

Thanks for this extremely fast response @astirpe , it took a bit to rebuild odoo.sh instance, but, as expected, test class change did the trick and all tests ran smoothly, thanks again!

astirpe commented 6 years ago

Thanks to you for the contribution!