mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Merge pull request #122 from acsone/7.0-fix-async_move_line_importer-test-suite-sbi
[FIX] adapt test suite for 2015 year change
This commit is contained in:
@@ -99,43 +99,64 @@ def journal_period_draft(self, journal_period_id, context):
|
|||||||
context=context)
|
context=context)
|
||||||
|
|
||||||
|
|
||||||
|
def get_journal_copy_id(self, journal_id, context=None):
|
||||||
|
return self.registry('account.journal').copy(self.cr, self.uid,
|
||||||
|
journal_id, {}, context)
|
||||||
|
|
||||||
|
|
||||||
|
def create_fiscalyear(self, year, company_id):
|
||||||
|
fiscalyear_obj = self.registry('account.fiscalyear')
|
||||||
|
fiscalyear_id = fiscalyear_obj.create(self.cr, self.uid, {
|
||||||
|
'name': year,
|
||||||
|
'code': year,
|
||||||
|
'date_start': year + '-01-01',
|
||||||
|
'date_stop': year + '-12-31',
|
||||||
|
'company_id': company_id
|
||||||
|
})
|
||||||
|
fiscalyear_obj.create_period(self.cr, self.uid, [fiscalyear_id])
|
||||||
|
return fiscalyear_id
|
||||||
|
|
||||||
|
|
||||||
class TestAccountJournalPeriodClose(common.TransactionCase):
|
class TestAccountJournalPeriodClose(common.TransactionCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestAccountJournalPeriodClose, self).setUp()
|
super(TestAccountJournalPeriodClose, self).setUp()
|
||||||
|
company_id = self.ref('base.main_company')
|
||||||
|
fiscalyear_id = create_fiscalyear(self, '2013', company_id)
|
||||||
|
journal_id = self.ref('account.sales_journal')
|
||||||
|
self.period_id = self.registry('account.period')\
|
||||||
|
.search(self.cr, self.uid, [('fiscalyear_id', '=', fiscalyear_id)],
|
||||||
|
limit=1)[0]
|
||||||
|
self.journal_id = get_journal_copy_id(self, journal_id)
|
||||||
|
|
||||||
def test_close_period_open_journal(self):
|
def test_close_period_open_journal(self):
|
||||||
context = {}
|
context = {}
|
||||||
journal_id = self.ref('account.sales_journal')
|
close_period(self, self.period_id, context)
|
||||||
period_id = self.ref('account.period_1')
|
|
||||||
close_period(self, period_id, context)
|
|
||||||
journal_period_id = create_journal_period(self,
|
journal_period_id = create_journal_period(self,
|
||||||
period_id,
|
self.period_id,
|
||||||
journal_id,
|
self.journal_id,
|
||||||
context)
|
context)
|
||||||
journal_period_draft(self, journal_period_id, context)
|
journal_period_draft(self, journal_period_id, context)
|
||||||
self.registry('account.move')\
|
self.registry('account.move')\
|
||||||
.create(self.cr,
|
.create(self.cr,
|
||||||
self.uid,
|
self.uid,
|
||||||
get_simple_account_move_values(self,
|
get_simple_account_move_values(self,
|
||||||
period_id,
|
self.period_id,
|
||||||
journal_id),
|
self.journal_id),
|
||||||
context=context)
|
context=context)
|
||||||
# Here, no exception should be raised because the journal's state is
|
# Here, no exception should be raised because the journal's state is
|
||||||
# draft although the period is closed
|
# draft although the period is closed
|
||||||
|
|
||||||
def test_open_period_close_journal(self):
|
def test_open_period_close_journal(self):
|
||||||
context = {}
|
context = {}
|
||||||
journal_id = self.ref('account.sales_journal')
|
|
||||||
period_id = self.ref('account.period_1')
|
|
||||||
journal_period_id = create_journal_period(self,
|
journal_period_id = create_journal_period(self,
|
||||||
period_id,
|
self.period_id,
|
||||||
journal_id,
|
self.journal_id,
|
||||||
context)
|
context)
|
||||||
journal_period_done(self, journal_period_id, context)
|
journal_period_done(self, journal_period_id, context)
|
||||||
move_values = get_simple_account_move_values(self,
|
move_values = get_simple_account_move_values(self,
|
||||||
period_id,
|
self.period_id,
|
||||||
journal_id)
|
self.journal_id)
|
||||||
# I check if the exception is correctly raised at create of an account
|
# I check if the exception is correctly raised at create of an account
|
||||||
# move which is linked with a closed journal
|
# move which is linked with a closed journal
|
||||||
self.assertRaises(osv.except_osv,
|
self.assertRaises(osv.except_osv,
|
||||||
@@ -144,16 +165,14 @@ class TestAccountJournalPeriodClose(common.TransactionCase):
|
|||||||
|
|
||||||
def test_change_journal_on_move(self):
|
def test_change_journal_on_move(self):
|
||||||
context = {}
|
context = {}
|
||||||
journal_id = self.ref('account.sales_journal')
|
|
||||||
journal_cash_id = self.ref('account.cash_journal')
|
journal_cash_id = self.ref('account.cash_journal')
|
||||||
period_id = self.ref('account.period_1')
|
|
||||||
journal_period_id = create_journal_period(self,
|
journal_period_id = create_journal_period(self,
|
||||||
period_id,
|
self.period_id,
|
||||||
journal_id,
|
self.journal_id,
|
||||||
context)
|
context)
|
||||||
journal_period_done(self, journal_period_id, context)
|
journal_period_done(self, journal_period_id, context)
|
||||||
move_values = get_simple_account_move_values(self,
|
move_values = get_simple_account_move_values(self,
|
||||||
period_id,
|
self.period_id,
|
||||||
journal_cash_id)
|
journal_cash_id)
|
||||||
self.registry('account.move').create(self.cr,
|
self.registry('account.move').create(self.cr,
|
||||||
self.uid,
|
self.uid,
|
||||||
@@ -173,11 +192,9 @@ class TestAccountJournalPeriodClose(common.TransactionCase):
|
|||||||
context = {}
|
context = {}
|
||||||
|
|
||||||
jour_per_obj = self.registry('account.journal.period')
|
jour_per_obj = self.registry('account.journal.period')
|
||||||
journal_id = self.ref('account.sales_journal')
|
|
||||||
period_id = self.ref('account.period_1')
|
|
||||||
move_values = get_simple_account_move_values(self,
|
move_values = get_simple_account_move_values(self,
|
||||||
period_id,
|
self.period_id,
|
||||||
journal_id)
|
self.journal_id)
|
||||||
self.registry('account.move').create(self.cr,
|
self.registry('account.move').create(self.cr,
|
||||||
self.uid,
|
self.uid,
|
||||||
move_values,
|
move_values,
|
||||||
@@ -185,8 +202,8 @@ class TestAccountJournalPeriodClose(common.TransactionCase):
|
|||||||
journal_period_ids =\
|
journal_period_ids =\
|
||||||
jour_per_obj.search(self.cr,
|
jour_per_obj.search(self.cr,
|
||||||
self.uid,
|
self.uid,
|
||||||
[('period_id', '=', period_id),
|
[('period_id', '=', self.period_id),
|
||||||
('journal_id', '=', journal_id),
|
('journal_id', '=', self.journal_id),
|
||||||
],
|
],
|
||||||
context=context)
|
context=context)
|
||||||
# I check if the exception is correctly raised at closing journal that
|
# I check if the exception is correctly raised at closing journal that
|
||||||
@@ -198,15 +215,13 @@ class TestAccountJournalPeriodClose(common.TransactionCase):
|
|||||||
|
|
||||||
def test_duplicate_journal_period(self):
|
def test_duplicate_journal_period(self):
|
||||||
context = {}
|
context = {}
|
||||||
journal_id = self.ref('account.sales_journal')
|
create_journal_period(self, self.period_id, self.journal_id, context)
|
||||||
period_id = self.ref('account.period_1')
|
|
||||||
create_journal_period(self, period_id, journal_id, context)
|
|
||||||
# I check if the exception is correctly raised at adding both same
|
# I check if the exception is correctly raised at adding both same
|
||||||
# journal on a period
|
# journal on a period
|
||||||
self.cr._default_log_exceptions = False
|
self.cr._default_log_exceptions = False
|
||||||
try:
|
try:
|
||||||
self.assertRaises(IntegrityError,
|
self.assertRaises(IntegrityError,
|
||||||
create_journal_period,
|
create_journal_period,
|
||||||
self, period_id, journal_id, context)
|
self, self.period_id, self.journal_id, context)
|
||||||
finally:
|
finally:
|
||||||
self.cr._default_log_exceptions = True
|
self.cr._default_log_exceptions = True
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import base64
|
import time
|
||||||
import tempfile
|
|
||||||
|
|
||||||
import openerp.tests.common as test_common
|
import openerp.tests.common as test_common
|
||||||
from openerp import addons
|
from openerp import addons
|
||||||
@@ -28,14 +27,15 @@ from openerp import addons
|
|||||||
class TestMoveLineImporter(test_common.SingleTransactionCase):
|
class TestMoveLineImporter(test_common.SingleTransactionCase):
|
||||||
|
|
||||||
def get_file(self, filename):
|
def get_file(self, filename):
|
||||||
"""Retrive file from test data"""
|
"""Retrieve file from test data,
|
||||||
|
encode it as base64
|
||||||
|
and adjust it for current year
|
||||||
|
"""
|
||||||
path = addons.get_module_resource('async_move_line_importer',
|
path = addons.get_module_resource('async_move_line_importer',
|
||||||
'tests', 'data', filename)
|
'tests', 'data', filename)
|
||||||
with open(path) as test_data:
|
test_data = open(path).read()
|
||||||
with tempfile.TemporaryFile() as out:
|
test_data = test_data.replace('2014', time.strftime('%Y'))
|
||||||
base64.encode(test_data, out)
|
return test_data.encode("base64")
|
||||||
out.seek(0)
|
|
||||||
return out.read()
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestMoveLineImporter, self).setUp()
|
super(TestMoveLineImporter, self).setUp()
|
||||||
|
|||||||
Reference in New Issue
Block a user