Browse Source

[12.0][MIG] base_jsonify: py3

pull/1472/head
Simone Orsi 5 years ago
parent
commit
cc255086ef
  1. 1
      base_jsonify/__init__.py
  2. 1
      base_jsonify/__manifest__.py
  3. 1
      base_jsonify/models/__init__.py
  4. 3
      base_jsonify/models/ir_export.py
  5. 1
      base_jsonify/models/ir_exports_line.py
  6. 1
      base_jsonify/models/models.py
  7. 1
      base_jsonify/tests/__init__.py
  8. 95
      base_jsonify/tests/test_get_parser.py
  9. 1
      base_jsonify/tests/test_ir_exports_line.py

1
base_jsonify/__init__.py

@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import models

1
base_jsonify/__manifest__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2018 Akretion (http://www.akretion.com)
# Sébastien BEAU <sebastien.beau@akretion.com>
# Raphaël Reverdy <raphael.reverdy@akretion.com>

1
base_jsonify/models/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from . import models
from . import ir_export
from . import ir_exports_line

3
base_jsonify/models/ir_export.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (http://www.akretion.com)
# Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -34,7 +33,7 @@ def convert_dict(dict_parser):
tuples.
"""
parser = []
for field, value in dict_parser.iteritems():
for field, value in dict_parser.items():
if value is True:
parser.append(field)
else:

1
base_jsonify/models/ir_exports_line.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

1
base_jsonify/models/models.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (http://www.akretion.com)
# Sébastien BEAU <sebastien.beau@akretion.com>
# Raphaël Reverdy <raphael.reverdy@akretion.com>

1
base_jsonify/tests/__init__.py

@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-
from . import test_get_parser
from . import test_ir_exports_line

95
base_jsonify/tests/test_get_parser.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © <YEAR(S)> <AUTHOR(S)>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@ -9,20 +8,20 @@ class TestParser(TransactionCase):
def test_getting_parser(self):
expected_parser = [
u'active',
(u'category_id', [u'name']),
(u'child_ids', [(
u'child_ids', [u'name']),
(u'country_id', [u'code', u'name']),
u'email', u'id',
u'name'
'active',
('category_id', ['name']),
('child_ids', [(
'child_ids', ['name']),
('country_id', ['code', 'name']),
'email', 'id',
'name'
]),
u'color',
u'comment',
(u'country_id', [u'code', u'name']),
u'credit_limit',
u'lang',
u'name']
'color',
'comment',
('country_id', ['code', 'name']),
'credit_limit',
'lang',
'name']
exporter = self.env.ref('base_jsonify.ir_exp_partner')
parser = exporter.get_json_parser()
@ -32,27 +31,27 @@ class TestParser(TransactionCase):
self.env.ref('base_jsonify.category_id_name').write({
'alias': 'category_id:category/name'
})
expected_parser[1] = (u'category_id:category', [u'name'])
expected_parser[1] = ('category_id:category', ['name'])
parser = exporter.get_json_parser()
self.assertEqual(parser, expected_parser)
def test_json_export(self):
parser = [
u'lang',
u'comment',
u'credit_limit',
u'name',
u'color',
(u'child_ids:children', [
(u'child_ids:children', [u'name']),
u'email',
(u'country_id:country', [u'code', u'name']),
u'name',
u'id',
'lang',
'comment',
'credit_limit',
'name',
'color',
('child_ids:children', [
('child_ids:children', ['name']),
'email',
('country_id:country', ['code', 'name']),
'name',
'id',
]),
(u'country_id:country', [u'code', u'name']),
u'active',
(u'category_id', [u'name'])
('country_id:country', ['code', 'name']),
'active',
('category_id', ['name'])
]
partner = self.env['res.partner'].create({
'name': 'Akretion',
@ -67,28 +66,28 @@ class TestParser(TransactionCase):
],
})
expected_json = {
u'lang': u'en_US',
u'comment': None,
u'credit_limit': 0.0,
u'name': u'Akretion',
u'color': 0,
u'country': {
u'code': u'FR',
u'name': u'France'
'lang': 'en_US',
'comment': None,
'credit_limit': 0.0,
'name': 'Akretion',
'color': 0,
'country': {
'code': 'FR',
'name': 'France'
},
u'active': True,
u'category_id': [
{u'name': u'Inovator'}
'active': True,
'category_id': [
{'name': 'Inovator'}
],
u'children': [{
u'id': partner.child_ids.id,
u'country': {
u'code': u'FR',
u'name': u'France'
'children': [{
'id': partner.child_ids.id,
'country': {
'code': 'FR',
'name': 'France'
},
u'children': [],
u'name': u'Sebatien Beau',
u'email': None
'children': [],
'name': 'Sebatien Beau',
'email': None
}]
}
json_partner = partner.jsonify(parser)

1
base_jsonify/tests/test_ir_exports_line.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Loading…
Cancel
Save