forked from OCA/l10n-spain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] l10n_es_aeat: Bytestring concatenation on file export to boe (S…
…olves compatibility problems with python3) (#1) * Adds tests for exporting files to boe with an export config (#2)
- Loading branch information
1 parent
21492b6
commit 002f258
Showing
3 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2017 FactorLibre - Hugo Santos <[email protected]> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 | ||
from odoo.tests import common | ||
|
||
|
||
class TestL10nEsAeatExportConfig(common.TransactionCase): | ||
|
||
def setUp(self): | ||
super(TestL10nEsAeatExportConfig, self).setUp() | ||
|
||
def test_onchange_export_config_line(self): | ||
export_config_line_env = self.env['aeat.model.export.config.line'] | ||
with self.env.do_in_onchange(): | ||
export_line_float = export_config_line_env.new() | ||
export_line_float.export_type = 'float' | ||
export_line_float.onchange_type() | ||
self.assertEqual(export_line_float.alignment, 'right', | ||
'Export type float must be aligned to the right') | ||
export_line_str = export_config_line_env.new() | ||
export_line_str.export_type = 'string' | ||
export_line_str.onchange_type() | ||
self.assertEqual(export_line_str.alignment, 'left', | ||
'Export type string must be aligned to the left') | ||
export_line_subtype = export_config_line_env.new() | ||
export_line_subtype.alignment = 'left' | ||
export_line_subtype.decimal_size = 10 | ||
export_line_subtype.apply_sign = True | ||
export_line_subtype.subconfig_id = export_line_str.id | ||
export_line_subtype.onchange_subconfig() | ||
self.assertFalse(export_line_subtype.alignment, | ||
'Alignment must be False for a subtype line') | ||
self.assertEqual(export_line_subtype.decimal_size, 0) | ||
self.assertFalse(export_line_subtype.apply_sign, | ||
'Apply sign must be False for a subtype line') | ||
|
||
def test_export_config_file(self): | ||
export_config = self.env['aeat.model.export.config'].create({ | ||
'name': 'Test Export Config', | ||
'model_number': '000', | ||
'config_line_ids': [ | ||
(0, 0, { | ||
'sequence': 1, | ||
'name': '<T', | ||
'fixed_value': '<T', | ||
'export_type': 'string', | ||
'size': 3, | ||
'alignment': 'left' | ||
}), | ||
(0, 0, { | ||
'sequence': 2, | ||
'name': 'Empty spaces', | ||
'fixed_value': '', | ||
'export_type': 'string', | ||
'size': 10, | ||
'alignment': 'left' | ||
}), | ||
(0, 0, { | ||
'sequence': 3, | ||
'name': 'Integer Value', | ||
'fixed_value': 1, | ||
'export_type': 'integer', | ||
'size': 3, | ||
'alignment': 'right' | ||
}), | ||
(0, 0, { | ||
'sequence': 4, | ||
'name': 'Float Value', | ||
'fixed_value': 15.0, | ||
'export_type': 'float', | ||
'size': 6, | ||
'decimal_size': 2, | ||
'alignment': 'right' | ||
}), | ||
(0, 0, { | ||
'sequence': 5, | ||
'name': 'Boolean True Value', | ||
'expression': True, | ||
'export_type': 'boolean', | ||
'size': 2, | ||
'alignment': 'left' | ||
}), | ||
(0, 0, { | ||
'sequence': 6, | ||
'name': 'Boolean False Value', | ||
'expression': False, | ||
'export_type': 'boolean', | ||
'size': 2, | ||
'alignment': 'left' | ||
}), | ||
(0, 0, { | ||
'sequence': 7, | ||
'name': '>', | ||
'fixed_value': '>', | ||
'size': 1, | ||
'alignment': 'left' | ||
}) | ||
] | ||
}) | ||
new_report = self.env['l10n.es.aeat.report'].new({ | ||
'name': 'Test Report' | ||
}) | ||
export_to_boe = self.env['l10n.es.aeat.report.export_to_boe'].create({ | ||
'name': 'test_export_to_boe.txt' | ||
}) | ||
export_file = export_to_boe._export_config( | ||
new_report, export_config) | ||
self.assertEqual(b'<T 001001500X >', export_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters