Test importing translated data
This commit is contained in:
1 parent
a976b965d8
commit
be9cc4daee
2 files changed
+30
No files matched your search
@@ -35,6 +35,12 @@ class ImportDataChar(ModelSQL):
|
||||
char = fields.Char('Char')
|
||||
|
||||
|
||||
class ImportDataTranslate(ModelSQL):
|
||||
"Import Data Translate"
|
||||
__name__ = 'test.import_data.translate'
|
||||
translate = fields.Char("Translate", translate=True)
|
||||
|
||||
|
||||
class ImportDataText(ModelSQL):
|
||||
"Import Data Text"
|
||||
__name__ = 'test.import_data.text'
|
||||
@@ -175,6 +181,7 @@ def register(module):
|
||||
ImportDataFloat,
|
||||
ImportDataNumeric,
|
||||
ImportDataChar,
|
||||
ImportDataTranslate,
|
||||
ImportDataText,
|
||||
ImportDataDate,
|
||||
ImportDataDateTime,
|
||||
|
||||
@@ -8,6 +8,7 @@ from decimal import Decimal
|
||||
from trytond.model.exceptions import ImportDataError
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import activate_module, with_transaction
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class ImportDataTestCase(unittest.TestCase):
|
||||
@@ -139,6 +140,28 @@ class ImportDataTestCase(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
Char.import_data(['char'], [['test'], ['foo'], ['bar']]), 3)
|
||||
|
||||
@with_transaction()
|
||||
def test_translate(self):
|
||||
"Test translate"
|
||||
pool = Pool()
|
||||
Translate = pool.get('test.import_data.translate')
|
||||
|
||||
self.assertEqual(
|
||||
Translate.import_data(
|
||||
['translate:lang=en', 'translate:lang=fr'],
|
||||
[['foo', 'bar'], ['', '']]),
|
||||
2)
|
||||
|
||||
with Transaction().set_context(language='en'):
|
||||
record1, record2 = Translate.search([])
|
||||
self.assertEqual(record1.translate, 'foo')
|
||||
self.assertEqual(record2.translate, '')
|
||||
|
||||
with Transaction().set_context(language='en'):
|
||||
record1, record2 = Translate.search([])
|
||||
self.assertEqual(record1.translate, 'foo')
|
||||
self.assertEqual(record2.translate, '')
|
||||
|
||||
@with_transaction()
|
||||
def test_text(self):
|
||||
'Test text'
|
||||
|
||||
Reference in new issue
Block a user