[FIX] spreadsheet: move test to dedicated module
The test added in #120818 was relying on a model that does not depend on module `spreadsheet, rather the opposite. This information was probably lost during the forwardport process. Since the fix concerns `spreadsheet.mixin` and not just `spreadsheet.dashboard`, it makes sense to test it globally, in a dedicated test module. Fixes runbot build errors 20966 and 20968 closes odoo/odoo#123947 X-original-commit: 7205e3b26eb3de3f53d6984cd07ec3e4b3fbcfdd Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com> Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit is contained in:
@@ -218,14 +218,3 @@ class ValidateSpreadsheetData(TransactionCase):
|
||||
raise AssertionError(
|
||||
f"xml id '{xml_id}' used in spreadsheet '{spreadsheet_name}' does not exist"
|
||||
)
|
||||
|
||||
def test_onchange_json_data(self):
|
||||
group = self.env["spreadsheet.dashboard.group"].create(
|
||||
{"name": "a group"}
|
||||
)
|
||||
spreadsheet_form = Form(self.env['spreadsheet.dashboard'])
|
||||
spreadsheet_form.name = 'Test spreadsheet'
|
||||
spreadsheet_form.dashboard_group_id = group
|
||||
spreadsheet_form.spreadsheet_binary_data = base64.b64encode(json.dumps({'key': 'value'}).encode('utf-8'))
|
||||
with self.assertRaises(ValidationError, msg='Invalid JSON Data'):
|
||||
spreadsheet_form.spreadsheet_binary_data = base64.b64encode('invalid json'.encode('utf-8'))
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
@@ -0,0 +1,18 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
{
|
||||
'name': 'Spreadsheet Test',
|
||||
'version': '1.0',
|
||||
'category': 'Hidden',
|
||||
'summary': 'Spreadsheet Test, mainly to test the mixin behavior',
|
||||
'description': """This module contains tests related to spreadsheet.
|
||||
The modules exposes some mixin that are only implemented in other functional modules.
|
||||
When trying to test a global behavior of the mixin, it makes no sense to test it in
|
||||
each module implementing the mixin but rather test a dummy implementation of the later,
|
||||
hence the need for this test module.
|
||||
""",
|
||||
'depends': ['spreadsheet'],
|
||||
'license': 'LGPL-3',
|
||||
'data': ['security/ir.model.access.csv'],
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
from . import spreadsheet_mixin_test
|
||||
@@ -0,0 +1,9 @@
|
||||
from odoo import models
|
||||
|
||||
|
||||
class SpreadsheetDummy(models.Model):
|
||||
""" A very simple model only inheriting from spreadsheet.mixin to test
|
||||
its model functioning."""
|
||||
_description = 'Dummy Spreadsheet'
|
||||
_name = 'spreadsheet.test'
|
||||
_inherit = ['spreadsheet.mixin']
|
||||
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_spreadsheet_test_all,access.spreadsheet.test.all,model_spreadsheet_test,,1,1,1,1
|
||||
|
@@ -0,0 +1 @@
|
||||
from . import test_spreadsheet
|
||||
@@ -0,0 +1,12 @@
|
||||
import base64
|
||||
import json
|
||||
from odoo.tests.common import TransactionCase, Form
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class ValidateSpreadsheetMixinData(TransactionCase):
|
||||
def test_onchange_json_data(self):
|
||||
spreadsheet_form = Form(self.env["spreadsheet.test"])
|
||||
|
||||
spreadsheet_form.spreadsheet_binary_data = base64.b64encode(json.dumps({'key': 'value'}).encode('utf-8'))
|
||||
with self.assertRaises(ValidationError, msg='Invalid JSON Data'):
|
||||
spreadsheet_form.spreadsheet_binary_data = base64.b64encode('invalid json'.encode('utf-8'))
|
||||
Reference in New Issue
Block a user