[MERGE] forward port branch 10.0 up to 808c0e5dde
This commit is contained in:
@@ -689,7 +689,7 @@ class TestAutoJoin(TransactionCase):
|
||||
self.assertIn('res_partner_bank', sql_query[0],
|
||||
"_auto_join off: ('bank_ids.sanitized_acc_number', 'like', '..') first query incorrect main table")
|
||||
|
||||
expected = "%s::text like %s" % (unaccent('"res_partner_bank"."sanitized_acc_number"'), unaccent('%s'))
|
||||
expected = "%s like %s" % (unaccent('"res_partner_bank"."sanitized_acc_number"::text'), unaccent('%s'))
|
||||
self.assertIn(expected, sql_query[1],
|
||||
"_auto_join off: ('bank_ids.sanitized_acc_number', 'like', '..') first query incorrect where condition")
|
||||
|
||||
@@ -729,7 +729,7 @@ class TestAutoJoin(TransactionCase):
|
||||
self.assertIn('"res_partner_bank" as "res_partner__bank_ids"', sql_query[0],
|
||||
"_auto_join on: ('bank_ids.sanitized_acc_number', 'like', '..') query incorrect join")
|
||||
|
||||
expected = "%s::text like %s" % (unaccent('"res_partner__bank_ids"."sanitized_acc_number"'), unaccent('%s'))
|
||||
expected = "%s like %s" % (unaccent('"res_partner__bank_ids"."sanitized_acc_number"::text'), unaccent('%s'))
|
||||
self.assertIn(expected, sql_query[1],
|
||||
"_auto_join on: ('bank_ids.sanitized_acc_number', 'like', '..') query incorrect where condition")
|
||||
|
||||
@@ -812,7 +812,7 @@ class TestAutoJoin(TransactionCase):
|
||||
self.assertIn('"res_country"', sql_query[0],
|
||||
"_auto_join on for state_id: ('state_id.country_id.code', 'like', '..') query 1 incorrect main table")
|
||||
|
||||
expected = "%s::text like %s" % (unaccent('"res_country"."code"'), unaccent('%s'))
|
||||
expected = "%s like %s" % (unaccent('"res_country"."code"::text'), unaccent('%s'))
|
||||
self.assertIn(expected, sql_query[1],
|
||||
"_auto_join on for state_id: ('state_id.country_id.code', 'like', '..') query 1 incorrect where condition")
|
||||
|
||||
@@ -846,7 +846,7 @@ class TestAutoJoin(TransactionCase):
|
||||
self.assertIn('"res_country" as "res_country_state__country_id"', sql_query[0],
|
||||
"_auto_join on for country_id: ('state_id.country_id.code', 'like', '..') query 1 incorrect join")
|
||||
|
||||
expected = "%s::text like %s" % (unaccent('"res_country_state__country_id"."code"'), unaccent('%s'))
|
||||
expected = "%s like %s" % (unaccent('"res_country_state__country_id"."code"::text'), unaccent('%s'))
|
||||
self.assertIn(expected, sql_query[1],
|
||||
"_auto_join on for country_id: ('state_id.country_id.code', 'like', '..') query 1 incorrect where condition")
|
||||
|
||||
@@ -880,7 +880,7 @@ class TestAutoJoin(TransactionCase):
|
||||
self.assertIn('"res_country" as "res_partner__state_id__country_id"', sql_query[0],
|
||||
"_auto_join on: ('state_id.country_id.code', 'like', '..') query incorrect join")
|
||||
|
||||
expected = "%s::text like %s" % (unaccent('"res_partner__state_id__country_id"."code"'), unaccent('%s'))
|
||||
expected = "%s like %s" % (unaccent('"res_partner__state_id__country_id"."code"::text'), unaccent('%s'))
|
||||
self.assertIn(expected, sql_query[1],
|
||||
"_auto_join on: ('state_id.country_id.code', 'like', '..') query incorrect where condition")
|
||||
|
||||
@@ -910,7 +910,7 @@ class TestAutoJoin(TransactionCase):
|
||||
# Test produced queries that domains effectively present
|
||||
sql_query = self.query_list[0].get_sql()
|
||||
|
||||
expected = "%s::text like %s" % (unaccent('"res_partner__child_ids__bank_ids"."sanitized_acc_number"'), unaccent('%s'))
|
||||
expected = "%s like %s" % (unaccent('"res_partner__child_ids__bank_ids"."sanitized_acc_number"::text'), unaccent('%s'))
|
||||
self.assertIn(expected, sql_query[1],
|
||||
"_auto_join on one2many with domains incorrect result")
|
||||
# TDE TODO: check first domain has a correct table name
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from collections import Counter
|
||||
import datetime
|
||||
import errno
|
||||
from os import utime
|
||||
import time
|
||||
|
||||
@@ -12,6 +14,21 @@ from odoo.tests import HttpCase
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
def _touch(filepath, asset, t=None):
|
||||
try:
|
||||
utime(filepath, (t, t) if t else None)
|
||||
except OSError as e:
|
||||
if e.errno in [errno.EPERM, errno.EACCES, errno.EROFS]:
|
||||
# Permission denied when touching the asset file, possibly read-only filesystem.
|
||||
# We alter the asset last modified time to simulate a change in the file
|
||||
now = datetime.datetime.now()
|
||||
asset.last_modified = now
|
||||
for sheet in asset.stylesheets:
|
||||
sheet.last_modified = now
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
class TestJavascriptAssetsBundle(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestJavascriptAssetsBundle, self).setUp()
|
||||
@@ -82,9 +99,9 @@ class TestJavascriptAssetsBundle(TransactionCase):
|
||||
version0 = bundle0.version
|
||||
|
||||
path = get_resource_path('test_assetsbundle', 'static', 'src', 'js', 'test_jsfile1.js')
|
||||
utime(path, None) # touch
|
||||
|
||||
bundle1 = self._get_asset(self.jsbundle_xmlid)
|
||||
_touch(path, bundle1)
|
||||
|
||||
bundle1.js()
|
||||
last_modified1 = bundle1.last_modified
|
||||
version1 = bundle1.version
|
||||
@@ -210,9 +227,9 @@ class TestJavascriptAssetsBundle(TransactionCase):
|
||||
version0 = bundle0.version
|
||||
|
||||
path = get_resource_path('test_assetsbundle', 'static', 'src', 'css', 'test_cssfile1.css')
|
||||
utime(path, None) # touch
|
||||
|
||||
bundle1 = self._get_asset(self.cssbundle_xmlid, env=self.env(context={'max_css_rules': 1}))
|
||||
_touch(path, bundle1)
|
||||
|
||||
bundle1.css()
|
||||
last_modified1 = bundle1.last_modified
|
||||
version1 = bundle1.version
|
||||
@@ -362,10 +379,12 @@ class TestAssetsBundleWithIRAMock(TransactionCase):
|
||||
self.env['ir.attachment']._patch_method('unlink', unlink)
|
||||
self.addCleanup(self.env['ir.attachment']._revert_method, 'unlink')
|
||||
|
||||
def _bundle(self, should_create, should_unlink):
|
||||
self.counter.clear()
|
||||
def _get_asset(self):
|
||||
files, remains = self.env['ir.qweb']._get_asset_content(self.lessbundle_xmlid, {})
|
||||
asset = AssetsBundle(self.lessbundle_xmlid, files, remains, env=self.env)
|
||||
return AssetsBundle(self.lessbundle_xmlid, files, remains, env=self.env)
|
||||
|
||||
def _bundle(self, asset, should_create, should_unlink):
|
||||
self.counter.clear()
|
||||
asset.to_html(debug='assets')
|
||||
self.assertEquals(self.counter['create'], int(should_create))
|
||||
self.assertEquals(self.counter['unlink'], int(should_unlink))
|
||||
@@ -375,16 +394,17 @@ class TestAssetsBundleWithIRAMock(TransactionCase):
|
||||
are correctly invalidated.
|
||||
"""
|
||||
# Compile for the first time
|
||||
self._bundle(True, False)
|
||||
self._bundle(self._get_asset(), True, False)
|
||||
|
||||
# Compile a second time, without changes
|
||||
self._bundle(False, False)
|
||||
self._bundle(self._get_asset(), False, False)
|
||||
|
||||
# Touch the file and compile a third time
|
||||
path = get_resource_path('test_assetsbundle', 'static', 'src', 'less', 'test_lessfile1.less')
|
||||
t = time.time() + 5
|
||||
utime(path, (t, t)) # touch
|
||||
self._bundle(True, True)
|
||||
asset = self._get_asset()
|
||||
_touch(path, asset, t=t)
|
||||
self._bundle(asset, True, True)
|
||||
|
||||
# Because we are in the same transaction since the beginning of the test, the first asset
|
||||
# created and the second one have the same write_date, but the file's last modified date
|
||||
@@ -394,4 +414,4 @@ class TestAssetsBundleWithIRAMock(TransactionCase):
|
||||
self.cr.execute("update ir_attachment set write_date=clock_timestamp() + interval '10 seconds' where id = (select max(id) from ir_attachment)")
|
||||
|
||||
# Compile a fourth time, without changes
|
||||
self._bundle(False, False)
|
||||
self._bundle(self._get_asset(), False, False)
|
||||
|
||||
Reference in New Issue
Block a user