Commit df675c34 authored by Arnaud Fontaine's avatar Arnaud Fontaine Committed by Jérome Perrin

Cosmetic changes and remove unused imports.

parent 5b024f12
......@@ -440,7 +440,7 @@ class BalanceTransaction(AccountingTransaction, Inventory):
return factory
def _immediateReindexObject(self, **kw):
def _immediateReindexObject(self, *args, **kw):
"""Reindexes the object.
This is different indexing that the default Inventory indexing, because
we want to take into account that lines in this balance transaction to
......
......@@ -26,7 +26,7 @@ section_region = section.getRegion()
ledger = request.get("ledger", None)
if ledger is not None:
portal_categories = context.getPortalObject().portal_categories
if isinstance(ledger, list) or isinstance(ledger, tuple):
if isinstance(ledger, (tuple, list)):
ledger_uid = [portal_categories.ledger.restrictedTraverse(item).getUid() for item in ledger]
else:
ledger_uid = portal_categories.ledger.restrictedTraverse(ledger).getUid()
......
......@@ -23,7 +23,7 @@ kw['where_expression'] = " section.portal_type = 'Organisation' "
ledger = kw.get('ledger', request.get("ledger", None))
if ledger is not None:
portal_categories = context.getPortalObject().portal_categories
if isinstance(ledger, list) or isinstance(ledger, tuple):
if isinstance(ledger, (tuple, list)):
kw['ledger_uid'] = [portal_categories.ledger.restrictedTraverse(item).getUid() for item in ledger]
else:
kw['ledger_uid'] = portal_categories.ledger.restrictedTraverse(ledger).getUid()
......
......@@ -22,7 +22,7 @@ kw['where_expression'] = " section.portal_type = 'Organisation' "
ledger = kwd.get('ledger', request.get("ledger", None))
if ledger is not None:
portal_categories = context.getPortalObject().portal_categories
if isinstance(ledger, list) or isinstance(ledger, tuple):
if isinstance(ledger, (tuple, list)):
kw['ledger_uid'] = [portal_categories.ledger.restrictedTraverse(item).getUid() for item in ledger]
else:
kw['ledger_uid'] = portal_categories.ledger.restrictedTraverse(ledger).getUid()
......
......@@ -27,7 +27,7 @@ kw['where_expression'] = " section.portal_type = 'Organisation' "
ledger = kwd.get('ledger', request.get("ledger", None))
if ledger is not None:
portal_categories = context.getPortalObject().portal_categories
if isinstance(ledger, list) or isinstance(ledger, tuple):
if isinstance(ledger, (tuple, list)):
kw['ledger_uid'] = [portal_categories.ledger.restrictedTraverse(item).getUid() for item in ledger]
else:
kw['ledger_uid'] = portal_categories.ledger.restrictedTraverse(ledger).getUid()
......@@ -47,7 +47,7 @@ accounts_to_expand_by_tp = rec_cat.getAccountTypeRelatedValueList(**params) + \
total_balance = 0.0
for account_gap_number in accounts:
# We get all acounts strict member of this GAP category
# We get all accounts strict member of this GAP category
gap = context.restrictedTraverse('portal_categories/' + getURL(account_gap_number))
for account in gap.getGapRelatedValueList(portal_type='Account'):
......
......@@ -207,7 +207,7 @@ class CategoryBudgetVariation(BudgetVariation):
security.declareProtected(Permissions.AccessContentsInformation,
'getBudgetVariationRangeCategoryList')
def getBudgetVariationRangeCategoryList(self, context):
def getBudgetVariationRangeCategoryList(self, _):
"""Returns the Variation Range Category List that can be applied to this
budget.
"""
......
......@@ -15,6 +15,6 @@ for inventory in stool.getInventoryList(
resource_list.append(
(inventory.resource_relative_url,
portal.portal_categories.restrictedTraverse(
inventory.resource_relative_url).getTitle()))
inventory.resource_relative_url).getTranslatedTitle()))
return resource_list
......@@ -103,7 +103,8 @@ class CertificateAuthorityTool(BaseTool):
Raises CertificateAuthorityBusy"""
if os.path.exists(self.lock):
raise CertificateAuthorityBusy
open(self.lock, 'w').write('locked')
with open(self.lock, 'w') as f:
f.write('locked')
def _unlockCertificateAuthority(self):
"""Checks lock and locks Certificate Authority tool"""
......@@ -192,7 +193,8 @@ class CertificateAuthorityTool(BaseTool):
self._checkCertificateAuthority()
self._lockCertificateAuthority()
index = open(self.index).read().splitlines()
with open(self.index) as f:
index = f.read().splitlines()
valid_line_list = [q for q in index if q.startswith('V') and
('CN=%s/' % common_name in q)]
if len(valid_line_list) >= 1:
......@@ -201,7 +203,8 @@ class CertificateAuthorityTool(BaseTool):
'please revoke it before request a new one..' % common_name)
try:
new_id = open(self.serial, 'r').read().strip().lower()
with open(self.serial, 'r') as f:
new_id = f.read().strip().lower()
key = os.path.join(self.certificate_authority_path, 'private',
new_id+'.key')
csr = os.path.join(self.certificate_authority_path, new_id + '.csr')
......@@ -216,9 +219,13 @@ class CertificateAuthorityTool(BaseTool):
'-batch', '-config', self.openssl_config, '-out', cert, '-infiles',
csr])
os.unlink(csr)
with open(key) as f:
key = f.read()
with open(cert) as f:
cert = f.read()
return dict(
key=open(key).read(),
certificate=open(cert).read(),
key=key,
certificate=cert,
id=new_id,
common_name=common_name)
except Exception:
......@@ -242,7 +249,8 @@ class CertificateAuthorityTool(BaseTool):
self._checkCertificateAuthority()
self._lockCertificateAuthority()
try:
new_id = open(self.crl, 'r').read().strip().lower()
with open(self.crl, 'r') as f:
new_id = f.read().strip().lower()
crl_path = os.path.join(self.certificate_authority_path, 'crl')
crl = os.path.join(crl_path, new_id + '.crl')
cert = os.path.join(self.certificate_authority_path, 'certs',
......@@ -260,7 +268,9 @@ class CertificateAuthorityTool(BaseTool):
alias += str(len(glob.glob(alias + '*')))
created.append(alias)
os.symlink(os.path.basename(crl), alias)
return dict(crl=open(crl).read())
with open(crl) as f:
crl = f.read()
return dict(crl=crl)
except Exception:
e = sys.exc_info()
try:
......@@ -278,7 +288,8 @@ class CertificateAuthorityTool(BaseTool):
self._unlockCertificateAuthority()
def _getValidSerial(self, common_name):
index = open(self.index).read().splitlines()
with open(self.index) as f:
index = f.read().splitlines()
valid_line_list = [q for q in index if q.startswith('V') and
('CN=%s/' % common_name in q)]
if len(valid_line_list) < 1:
......
......@@ -347,9 +347,9 @@ class BusinessConfiguration(Item):
## we have already created configuration save for this state
## so remove from it already existing configuration items
if configuration_save != self: # don't delete ourselves
existing_conf_items = configuration_save.objectIds()
existing_conf_items = map(None, existing_conf_items)
configuration_save.manage_delObjects(existing_conf_items)
existing_conf_items = list(configuration_save.objectIds())
if existing_conf_items:
configuration_save.manage_delObjects(existing_conf_items)
modified_form_kw = {}
for k in form_kw.keys():
......
##############################################################################
# coding: utf-8
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Rafael Monnerat <rafael@nexedi.com>
# Ivan Tyagov <ivan@nexedi.com>
......
password_confirm = request.get('field_your_password_confirm', None)
if editor.encode('ascii', 'ignore') != editor:
return False
return password_confirm == editor
......@@ -348,7 +348,7 @@ def test_suite():
suite.addTest(unittest.makeSuite(TestTimeZoneContext))
suite.addTest(unittest.makeSuite(TestDateTimePatch))
# also run original tests from DateTime module
# also run original tests from DateTime module BBB ZOPE2
# pylint:disable=no-name-in-module
try:
import DateTime.tests.testDateTime as test_datetime
......
......@@ -4074,7 +4074,8 @@ VALUES
def doSomething(self, message_list):
r = []
for m in message_list:
m.result = r.append(m.object.getPath())
r.append(m.object.getPath())
m.result = None
r.sort()
group_method_call_list.append(r)
self.portal.portal_activities.__class__.doSomething = doSomething
......
......@@ -386,7 +386,7 @@ class TestIdTool(ERP5TypeTestCase):
query = 'select last_id from portal_ids where id_group="foo_bar"'
self.assertRaises(ProgrammingError, sql_connection.manage_test, query)
generator.rebuildSqlTable()
result = sql_connection.manage_test(query)
result = sql_connection.manage_test(query)
self.assertEqual(result[0].last_id, 4)
def checkExportImportDict(self, id_generator):
......
......@@ -37,7 +37,7 @@ import email
from email.header import decode_header, make_header
from email.utils import parseaddr
# Copied from ERP5Type/patches/CMFMailIn.py
# Copied from bt5/erp5_egov/TestTemplateItem/testEGovMixin.py
def decode_email(file_):
# Prepare result
theMail = {
......@@ -77,7 +77,7 @@ def decode_email(file_):
elif content_type == 'message/rfc822':
continue
elif content_type in ("text/plain", "text/html"):
charset = part.get_content_charset()
charset = part.get_content_charset() or 'utf-8'
payload = part.get_payload(decode=True)
#LOG('CMFMailIn -> ',0,'charset: %s, payload: %s' % (charset,payload))
if charset:
......
......@@ -15,7 +15,7 @@ import re
from Products.PythonScripts.standard import html_quote
blank = ""
header_current = 1
header_current = '0'
header_initial = None
table_of_content = blank
index = 0
......
......@@ -1097,15 +1097,14 @@ class TestERP5Credential(ERP5TypeTestCase):
default_follow_up_uid=credential_request.getUid())
last_message = self.portal.MailHost._last_message
self.assertNotEqual((), last_message)
mfrom, mto, message_text = last_message
mfrom, mto, _ = last_message
self.assertEqual(mfrom, 'Portal Administrator <postmaster@localhost>')
self.assertEqual(['Vifib Test <barney@duff.com>'], mto)
self.assertNotEqual(re.search(r"Subject\:.*Welcome", message_text), None)
self.assertNotEqual(re.search(r"Hello\ Vifib\ Test\,", message_text), None)
decoded_message = self.decode_email(last_message[2])
self.assertEqual(decoded_message["headers"]["subject"], "Welcome")
body_message = decoded_message['body']
self.assertNotEqual(re.search("key=%s" % mail_message.getReference(),
body_message), None)
self.assertRegex(body_message, r"Hello\ Vifib\ Test\,")
self.assertRegex(body_message, "key=%s" % mail_message.getReference())
def testAssignmentCreationUsingSystemPreferenceProperty(self):
"""
......
text = context.asText()
LENGTH = 25
#TODO: Think about the display length of multibyte characters.
# TODO: Think about the display length of multibyte characters.
try:
return unicode(text, 'utf-8')[:LENGTH].encode('utf-8')
except UnicodeDecodeError:
......
......@@ -1603,7 +1603,7 @@ class TestCRMMailSend(BaseTestCRM):
def test_testValidatorForAttachmentField(self):
"""
If an Event Type doesn't allow Emebedded Files in its sub portal types,
If an Event Type doesn't allow Embedded Files in its sub portal types,
then the dialog should tell the user that attachment can't be uploaded
"""
# Add a document which will be attached.
......@@ -1792,7 +1792,7 @@ class TestCRMMailSend(BaseTestCRM):
def test_cloneEvent(self):
"""
All events uses after script and interaciton
All events uses after script and interaction
workflow add a test for clone
"""
# XXX in the case of title, getTitle ignores the title attribute,
......@@ -1825,7 +1825,7 @@ class TestCRMMailSend(BaseTestCRM):
def test_cloneTicketAndEventList(self):
"""
All events uses after script and interaciton
All events uses after script and interaction
workflow add a test for clone
"""
portal = self.portal
......
......@@ -150,12 +150,10 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
if html_text.find(match_string1) == -1:
print(html_text)
print(match_string1)
import pdb; pdb.set_trace()
return False
if html_text.find(match_string2) == -1:
print(html_text)
print(match_string2)
import pdb; pdb.set_trace()
return False
return True
......
......@@ -767,7 +767,7 @@ class Environment(object):
class ImportFixer(ast.NodeTransformer):
"""
The ImportFixer class is responsivle for fixing "normal" imports that users
The ImportFixer class is responsible for fixing "normal" imports that users
might try to execute.
It will automatically replace them with the proper usage of the environment
......@@ -780,7 +780,7 @@ class ImportFixer(ast.NodeTransformer):
def visit_FunctionDef(self, node):
"""
Processes funcion definition nodes. We want to store a list of all the
Processes function definition nodes. We want to store a list of all the
import that are inside functions, because they do not affect the outter
user context, thus do not imply in any un-pickleable variable being added
there.
......@@ -876,7 +876,7 @@ class ImportFixer(ast.NodeTransformer):
else:
# case when "import <module_name>"
module_names = [(node.names[0].name), ]
test_import_string = "import %s" %node.names[0].name
test_import_string = "import %s" % node.names[0].name
result_name = node.names[0].name
root_module_name = node.names[0].name
......
......@@ -2064,6 +2064,7 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
web_page = module.newContent(portal_type=web_page_portal_type,
file=upload_file)
self.tic()
self.assertEqual(web_page.getContentType(), 'text/plain')
text_content = web_page.getTextContent()
my_utf_eight_token = 'ùééàçèîà'
text_content = text_content.replace('\n', '\n%s\n' % my_utf_eight_token)
......
......@@ -190,7 +190,7 @@ class TestWebDavSupport(ERP5TypeTestCase):
self.assertEqual(web_page_module[filename].getData(), iso_text_content)
# Convert to base format and run conversion into utf-8
self.tic()
# Content-Type header is replaced if sonversion encoding succeed
# Content-Type header is replaced if conversion encoding succeed
new_text_content = text_content.replace('charset=iso-8859-1', 'charset=utf-8')
self.assertEqual(web_page_module[filename].getTextContent(), new_text_content)
......@@ -214,7 +214,7 @@ class TestWebDavSupport(ERP5TypeTestCase):
# This is HTTPServer.zhttp_server not HTTPServer.zwebdav_server
# force usage of manage_FTPget like zwebdav_server does
response = self.publish(document.getPath()+'/manage_FTPget',
response = self.publish(document.getPath() + '/manage_FTPget',
request_method='GET',
stdin=StringIO(),
basic=self.authentication)
......
......@@ -865,7 +865,7 @@ class TestTemplateTool(ERP5TypeTestCase):
erp5_test = self.portal.portal_skins['erp5_test']
self.assertTrue(erp5_test.hasObject('test_file'))
def test_ownerhsip(self):
def test_ownership(self):
self.assertEqual(
self.portal.portal_skins.erp5_core.getOwnerTuple(),
([self.portal.getId(), 'acl_users'], 'System Processes'),
......
......@@ -1726,7 +1726,7 @@ return context.getPortalObject().foo_module.contentValues()
form_relative_url='portal_skins/erp5_ui_test/FooModule_viewFooList/listbox'
)
result_dict = json.loads(result)
#editalble creation date is defined at proxy form
# editable creation date is defined at proxy form
# Test the listbox_uid parameter
self.assertEqual(result_dict['_embedded']['contents'][0]['listbox_uid:list']['key'], 'listbox_uid:list')
self.assertEqual(result_dict['_embedded']['contents'][0]['id']['field_gadget_param']['type'], 'StringField')
......@@ -3259,11 +3259,11 @@ class TestERP5ODS(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'), 'text/csv')
else:
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'), 'text/csv; charset=utf-8')
self.assertTrue('foook1' in result, result)
self.assertTrue('foook2' in result, result)
self.assertTrue('foonotok' not in result, result)
self.assertIn('foook1', result)
self.assertIn('foook2', result)
self.assertNotIn('foonotok', result)
# Check one of the field name
self.assertTrue('Read-Only Quantity' in result, result)
self.assertIn('Read-Only Quantity', result)
# Ensure it is not the list mode rendering
self.assertTrue(len(result.split('\n')) > 50, result)
......
......@@ -603,11 +603,11 @@ class TestKM(TestKMMixIn):
# add some documents to this web section
presentation = portal.document_module.newContent(
title='My presentation',
portal_type = 'Presentation',
reference = 'Presentation-12456_',
portal_type='Presentation',
reference='Presentation-12456_',
version='001',
language='en',
publication_section_list = publication_section_category_id_list[:1])
publication_section_list=publication_section_category_id_list[:1])
presentation.publish()
self.tic()
self.changeSkin('KM')
......@@ -742,7 +742,7 @@ class TestKM(TestKMMixIn):
portal = self.getPortal()
portal_gadgets = portal.portal_gadgets
url = '%s/ERP5Site_viewHomeAreaRenderer?gadget_mode=web_front' %self.web_site_url
url = '%s/ERP5Site_viewHomeAreaRenderer?gadget_mode=web_front' % self.web_site_url
response = self.publish(url, self.auth)
self.assertIn(self.web_front_knowledge_pad.getTitle(), response.getBody())
......
......@@ -416,8 +416,8 @@ class testMailevaSOAPConnector(ERP5TypeTestCase):
def test_maileva_request_validation(self):
xml = self.maileva_connector.generateRequestXML(self.recipient, self.sender, self.document, 'test_track_id', 'maileva_connection_for_test')
# lxml doesn't support https in schemaLocation, download locally
src = open(os.path.join(os.path.dirname(Products.ERP5.tests.__file__), 'test_data', "MailevaPJSSchema.xsd"))
xsd = etree.parse(src)
with open(os.path.join(os.path.dirname(Products.ERP5.tests.__file__), 'test_data', "MailevaPJSSchema.xsd")) as f:
xsd = etree.parse(f)
schema_validator = etree.XMLSchema(xsd)
schema_validator.assertValid(etree.fromstring(xml.encode("UTF-8")))
......
......@@ -69,13 +69,16 @@ class PALOETLConnection(XMLObject):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
_ignore_ssl_certificate_check = True
_fix_service_location = True
def _getSudsClient(self):
# maybe client can be cached as a _v_ attribute. For now, we do not care about performance.
if "ignore ssl certificate check":
if self._ignore_ssl_certificate_check:
client = suds.client.Client(self.getUrlString(), transport=HTTPAuthenticatedUnverifiedSSL())
else:
client = suds.client.Client(self.getUrlString())
if "fix service location":
if self._fix_service_location:
# XXX The axis2 generated webservice only supports http on port 8080.
# It seems to be using an old and buggy version of axis2.
# Easiest workaround is to force the port (in WSDL terminology) location.
......
......@@ -29,6 +29,7 @@
import zope
from urllib import urlencode
from urllib2 import urlopen, Request
import contextlib
from zLOG import LOG, DEBUG
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
......@@ -100,8 +101,8 @@ class PaypalService(XMLObject):
paypal_url = self.getLinkUrlString()
request = Request(paypal_url, param_list)
request.add_header("Content-type", "application/x-www-form-urlencoded")
response = urlopen(request)
status = response.read()
with contextlib.closing(urlopen(request)) as response:
status = response.read()
LOG("PaypalService status", DEBUG, status)
method_id = self._getTypeBasedMethod("reportPaymentStatus").id
getattr(self.activate(), method_id)(response_dict=REQUEST.form)
......
......@@ -38,10 +38,10 @@ inventory_param_dict = {
}
employee_param_dict = inventory_param_dict.copy()
employee_param_dict['contribution_share_uid'] = context.portal_categories.contribution_share.employee.getUid()
employee_param_dict['contribution_share_uid'] = portal.portal_categories.contribution_share.employee.getUid()
employer_param_dict = inventory_param_dict.copy()
employer_param_dict['contribution_share_uid'] = context.portal_categories.contribution_share.employer.getUid()
employer_param_dict['contribution_share_uid'] = portal.portal_categories.contribution_share.employer.getUid()
if request.get('mirror_section'):
mirror_section = request['mirror_section']
......
......@@ -16,7 +16,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from __future__ import print_function
import os, sys, shutil, tempfile
from cStringIO import StringIO
from zLOG import LOG,ERROR,INFO,WARNING
......@@ -28,7 +27,6 @@ try:
except ImportError: # BBB Zope2
from Globals import package_home
import PIL.Image as PIL_Image
import thread
import random
import base64
from OFS.Folder import Folder
......@@ -176,15 +174,12 @@ class ZoomifyBase:
lr_y = ul_y + self.tileSize
else:
lr_y = self.originalHeight
print("Going to open image")
imageRow = image.crop([0, ul_y, self.originalWidth, lr_y])
saveFilename = root + str(tier) + '-' + str(row) + ext
if imageRow.mode != 'RGB':
imageRow = imageRow.convert('RGB')
imageRow.save(os.path.join(tempfile.gettempdir(), saveFilename),
'JPEG', quality=100)
print("os path exist : %r" % os.path.exists(os.path.join(
tempfile.gettempdir(), saveFilename)))
if os.path.exists(os.path.join(tempfile.gettempdir(), saveFilename)):
self.processRowImage(tier=tier, row=row)
row += 1
......@@ -192,7 +187,6 @@ class ZoomifyBase:
def processRowImage(self, tier=0, row=0):
""" for an image, create and save tiles """
print('*** processing tier: ' + str(tier) + ' row: ' + str(row))
tierWidth, tierHeight = self._v_scaleInfo[tier]
rowsForTier = tierHeight/self.tileSize
if tierHeight % self.tileSize > 0:
......@@ -335,7 +329,7 @@ class ZoomifyZopeProcessor(ZoomifyBase):
def openImage(self):
""" load the image data """
return PIL_Image.open(self._v_imageObject.name)
return PIL_Image.open(self._v_imageObject)
def createDefaultViewer(self):
""" add the default Zoomify viewer to the Zoomify metadata """
......
#from Products.ERP5.Document.TileImageTransformed import TileImageTransformed
#from cStringIO import StringIO
portal = context.getPortalObject()
data = portal.restrictedTraverse("portal_skins/erp5_safeimage/img/image_test.jpg")
print(data.data)
return printed
......@@ -415,6 +415,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
expected_result_dict = self[delivery.getPath()]
for line in delivery.getMovementList():
currency_precision = line.getPricePrecision()
simulation_movement_list_list = self.getTradeModelSimulationMovementList(line)
self.assertEqual(len(simulation_movement_list_list), 1)
simulation_movement_list = simulation_movement_list_list[0]
......@@ -426,7 +427,8 @@ class TestTradeModelLine(TestTradeModelLineMixin):
total_price = expected_result_dict[use].get(line.getId()) or 0.0
if True:
sm = result_dict.pop(use)
self.assertEqual(str(sm.getTotalPrice() or 0.0), str(total_price))
self.assertEqual(round(sm.getTotalPrice() or 0.0, currency_precision),
round(total_price, currency_precision))
self.assertEqual(3, len(sm.getCausalityValueList()))
self.assertEqual(1, len(sm.getCausalityValueList(
portal_type=self.business_link_portal_type)))
......@@ -466,12 +468,12 @@ class TestTradeModelLine(TestTradeModelLineMixin):
rounded_total_price = round(line_dict['normal'], currency_precision)
rounded_tax_price = round(line_dict['tax'], currency_precision)
rounded_discount_price = round(line_dict['discount'], currency_precision)
self.assertEqual(str(abs(line_dict['payable_receivable'])),
str(rounded_total_price + rounded_tax_price + rounded_discount_price))
self.assertEqual(str(abs(line_dict['vat'])),
str(rounded_tax_price))
self.assertEqual(str(abs(line_dict['income_expense'])),
str(rounded_total_price + rounded_discount_price))
self.assertEqual(round(abs(line_dict['payable_receivable']), currency_precision),
round(rounded_total_price + rounded_tax_price + rounded_discount_price, currency_precision))
self.assertEqual(round(abs(line_dict['vat']), currency_precision),
rounded_tax_price)
self.assertEqual(round(abs(line_dict['income_expense']), currency_precision),
round(rounded_total_price + rounded_discount_price, currency_precision))
def buildPackingLists(self):
self.portal.portal_alarms.packing_list_builder_alarm.activeSense()
......
......@@ -70,7 +70,6 @@ with ImmediateReindexContextManager() as immediate_reindex_context_manager:
line_variation_base_category_list = line_variation_base_category_dict.keys()
# construct new content (container_line)
resource_url = resource_url
new_container_line_id = str(container.generateNewId())
container_line = container.newContent(
immediate_reindex=immediate_reindex_context_manager,
......
......@@ -2838,11 +2838,11 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
portal_type='Organisation', title='Client',
default_image_file=image)
from OFS.Image import Pdata
self.assertTrue(isinstance(client.getDefaultImageValue().data, Pdata))
self.assertIsInstance(client.getDefaultImageValue().data, Pdata)
vendor = self.portal.organisation_module.newContent(
portal_type='Organisation', title='Vendor',
default_image_file=image)
self.assertTrue(isinstance(vendor.getDefaultImageValue().data, Pdata))
self.assertIsInstance(vendor.getDefaultImageValue().data, Pdata)
order = self.portal.getDefaultModule(self.order_portal_type).newContent(
portal_type=self.order_portal_type,
specialise=self.business_process,
......
......@@ -1799,7 +1799,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
sale_packing_list2.getUid()))]
self.assertEqual({self.default_quantity-4, self.default_quantity-3},
set([x.getQuantity() for x in sale_packing_list1.getMovementList()]))
self.assertEqual({1, 1}, set([x.getQuantity() for x in sale_packing_list3.getMovementList()]))
self.assertEqual({1}, set([x.getQuantity() for x in sale_packing_list3.getMovementList()]))
self.assertEqual("solved", sale_packing_list3.getCausalityState())
self.assertEqual("solved", sale_packing_list1.getCausalityState())
def getSolverProcessStateList(delivery):
......@@ -1811,7 +1811,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
self.assertEqual({self.default_quantity-4, self.default_quantity-3},
set([x.getQuantity() for x in sale_packing_list1.getMovementList()]))
self.assertEqual({1, 2}, set([x.getQuantity() for x in sale_packing_list2.getMovementList()]))
self.assertEqual({2, 2}, set([x.getQuantity() for x in sale_packing_list3.getMovementList()]))
self.assertEqual({2}, set([x.getQuantity() for x in sale_packing_list3.getMovementList()]))
self.assertEqual("solved", sale_packing_list1.getCausalityState())
self.assertEqual("solved", sale_packing_list2.getCausalityState())
self.assertEqual("solved", sale_packing_list3.getCausalityState())
......@@ -1822,7 +1822,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
self.assertEqual({self.default_quantity-5, self.default_quantity-4},
set([x.getQuantity() for x in sale_packing_list1.getMovementList()]))
self.assertEqual({2, 3}, set([x.getQuantity() for x in sale_packing_list2.getMovementList()]))
self.assertEqual({2, 2}, set([x.getQuantity() for x in sale_packing_list3.getMovementList()]))
self.assertEqual({2}, set([x.getQuantity() for x in sale_packing_list3.getMovementList()]))
self.assertEqual("solved", sale_packing_list1.getCausalityState())
self.assertEqual("solved", sale_packing_list2.getCausalityState())
self.assertEqual("solved", sale_packing_list3.getCausalityState())
......@@ -1837,7 +1837,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
self.assertEqual({self.default_quantity-6, self.default_quantity-5},
set([x.getQuantity() for x in sale_packing_list1.getMovementList()]))
self.assertEqual({2, 3}, set([x.getQuantity() for x in sale_packing_list2.getMovementList()]))
self.assertEqual({3, 3}, set([x.getQuantity() for x in sale_packing_list3.getMovementList()]))
self.assertEqual({3}, set([x.getQuantity() for x in sale_packing_list3.getMovementList()]))
self.assertEqual("solved", sale_packing_list1.getCausalityState())
self.assertEqual("solved", sale_packing_list2.getCausalityState())
self.assertEqual("solved", sale_packing_list3.getCausalityState())
......
......@@ -1412,6 +1412,7 @@ class TestResource(ERP5TypeTestCase):
self.assertEqual(resource.getInternalSupplyLineDestinationReference(),
'test_destination_reference_on_internal_supply_line')
@expectedFailure
def testQuantityUnitOnMovement(self):
"""Make sure that changing default quantity unit on resource does not
affect to movement.
......@@ -1464,7 +1465,8 @@ class TestResource(ERP5TypeTestCase):
# Check existing movement again and make sure that quantity
# unit is not changed.
expectedFailure(self.assertEqual)(
# XXX This is the expectedFailure
self.assertEqual(
sale_order_line.getQuantityUnitValue(),
self.quantity_unit_gram)
......
......@@ -25,7 +25,7 @@
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1;portal_type=Bar</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1&amp;portal_type=Bar</td>
<td></td>
</tr>
<tr>
......
......@@ -25,7 +25,7 @@
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1;portal_type=Bar</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1&amp;portal_type=Bar</td>
<td></td>
</tr>
<tr>
......
......@@ -25,7 +25,7 @@
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1;portal_type=Bar</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1&amp;portal_type=Bar</td>
<td></td>
</tr>
<tr>
......
......@@ -25,7 +25,7 @@
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1;portal_type=Bar</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1&amp;portal_type=Bar</td>
<td></td>
</tr>
<tr>
......
......@@ -25,7 +25,7 @@
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1;portal_type=Bar</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1&amp;portal_type=Bar</td>
<td></td>
</tr>
<tr>
......
......@@ -25,7 +25,7 @@
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1;portal_type=Bar</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1&amp;portal_type=Bar</td>
<td></td>
</tr>
<tr>
......
......@@ -25,7 +25,7 @@
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1;portal_type=Bar</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1&amp;portal_type=Bar</td>
<td></td>
</tr>
<tr>
......
......@@ -58,7 +58,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?start:int=3;num:int=7;portal_type=Bar</td>
<td>${base_url}/bar_module/FooModule_createObjects?start:int=3&amp;num:int=7&amp;portal_type=Bar</td>
<td></td>
</tr>
<tr>
......
......@@ -36,7 +36,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked;field_domain_root_list=foo_category/foo_big_category%7CFoo%20and%20Big%20Category</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked&amp;field_domain_root_list=foo_category/foo_big_category%7CFoo%20and%20Big%20Category</td>
<td></td>
</tr>
<tr>
......
......@@ -33,7 +33,7 @@
<!-- XXX bug compatibility; all columns must be set explicitly -->
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_all_columns=id%7CID%0Atitle%7CTitle%0Adelivery.quantity%7CQuantity;field_stat_method=portal_catalog</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_all_columns=id%7CID%0Atitle%7CTitle%0Adelivery.quantity%7CQuantity&amp;field_stat_method=portal_catalog</td>
<td></td>
</tr>
<tr>
......
......@@ -33,7 +33,7 @@
<!-- XXX bug compatibility; all_columns are used for sortable columns. -->
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_sort_columns=id%0Atitle;field_all_columns=id%0Atitle</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_sort_columns=id%0Atitle&amp;field_all_columns=id%0Atitle</td>
<td></td>
</tr>
<tr>
......
......@@ -36,7 +36,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked;field_domain_root_list=foo_category%7CFoo%20Category</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked&amp;field_domain_root_list=foo_category%7CFoo%20Category</td>
<td></td>
</tr>
<tr>
......@@ -153,7 +153,7 @@
<!-- Click on report tree -->
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_report_tree=checked;field_report_root_list=foo_category%7CFoo%20Category%0Afoo_empty_category%7CFoo%20Empty%20Category</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_report_tree=checked&amp;field_report_root_list=foo_category%7CFoo%20Category%0Afoo_empty_category%7CFoo%20Empty%20Category</td>
<td></td>
</tr>
<tr>
......
......@@ -36,7 +36,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked;field_domain_root_list=foo_category%7CFoo%20Category</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked&amp;field_domain_root_list=foo_category%7CFoo%20Category</td>
<td></td>
</tr>
<tr>
......
......@@ -36,7 +36,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked;field_domain_root_list=parent_domain%7CParent</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked&amp;field_domain_root_list=parent_domain%7CParent</td>
<td></td>
</tr>
<tr>
......
......@@ -36,7 +36,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked;field_domain_root_list=foo_domain%7CFoo%20Domain</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked&amp;field_domain_root_list=foo_domain%7CFoo%20Domain</td>
<td></td>
</tr>
<tr>
......
......@@ -36,7 +36,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_report_tree=checked;field_report_root_list=foo_domain%7CFoo%20Domain</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_report_tree=checked&amp;field_report_root_list=foo_domain%7CFoo%20Domain</td>
<td></td>
</tr>
<tr>
......
......@@ -12,7 +12,7 @@
<tal:block metal:use-macro="here/ListBoxZuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_meta_types=ERP5%20Delivery;field_portal_types=</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_meta_types=ERP5%20Delivery&amp;field_portal_types=</td>
<td></td>
</tr>
<tr>
......@@ -157,7 +157,7 @@
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_meta_types=ERP5%20Toto;field_portal_types=</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_meta_types=ERP5%20Toto&amp;field_portal_types=</td>
<td></td>
</tr>
<tr>
......
......@@ -12,7 +12,7 @@
<tal:block metal:use-macro="here/ListBoxZuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_meta_types=;field_portal_types=Foo</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_meta_types=&amp;field_portal_types=Foo</td>
<td></td>
</tr>
<tr>
......@@ -154,7 +154,7 @@
</tal:block>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_meta_types=;field_portal_types=Toto</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_meta_types=&amp;field_portal_types=Toto</td>
<td></td>
</tr>
<tr>
......
......@@ -322,7 +322,7 @@
Don't forget to update the code below if listbox_zuite/testDomainTree change. -->
<tr>
<td>open</td>
<td>${base_url}/foo_module/0/Foo_viewRelationField/listbox/ListBox_setPropertyList?field_domain_tree=checked;field_domain_root_list=foo_category%7CFoo%20Category</td>
<td>${base_url}/foo_module/0/Foo_viewRelationField/listbox/ListBox_setPropertyList?field_domain_tree=checked&amp;field_domain_root_list=foo_category%7CFoo%20Category</td>
<td></td>
</tr>
<tr>
......
......@@ -35,7 +35,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_report_tree=checked;field_report_root_list=foo_category%7CFoo%20Category%0Afoo_empty_category%7CFoo%20Empty%20Category</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_report_tree=checked&amp;field_report_root_list=foo_category%7CFoo%20Category%0Afoo_empty_category%7CFoo%20Empty%20Category</td>
<td></td>
</tr>
<tr>
......
......@@ -35,7 +35,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_stat_method=portal_catalog;field_report_tree=checked;field_report_root_list=foo_domain%7CFoo%20Domain</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_stat_method=portal_catalog&amp;field_report_tree=checked&amp;field_report_root_list=foo_domain%7CFoo%20Domain</td>
<td></td>
</tr>
<tr>
......
......@@ -32,7 +32,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_stat_columns=id%7CFooModule_statId%0Atitle%7CFooModule_statTitle;field_stat_method=portal_catalog</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_stat_columns=id%7CFooModule_statId%0Atitle%7CFooModule_statTitle&amp;field_stat_method=portal_catalog</td>
<td></td>
</tr>
<tr>
......
......@@ -32,7 +32,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked;field_domain_root_list=foo_category%7CFoo%20Category</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_domain_tree=checked&amp;field_domain_root_list=foo_category%7CFoo%20Category</td>
<td></td>
</tr>
<tr>
......
......@@ -187,7 +187,7 @@
</tr>
<tr>
<td>clickAndWait</td>
<td tal:content="python: '//div[@id=\'group_lane_%s\']//a' % (str((DateTime().day()/3)+1)) " ></td>
<td tal:content="python: '//div[@id=\'group_lane_%s\']//a' % (str((DateTime().day() // 3) + 1)) " ></td>
<td></td>
</tr>
<tr>
......@@ -202,7 +202,7 @@
</tr>
<tr>
<td>clickAndWait</td>
<td tal:content="python: '//div[@id=\'group_lane_%s\']//a' % (str(DateTime().dow()+1)) " ></td>
<td tal:content="python: '//div[@id=\'group_lane_%s\']//a' % (str(DateTime().dow() + 1)) " ></td>
<td></td>
</tr>
<tr>
......
......@@ -211,7 +211,7 @@
</tr>
<tr>
<td>clickAndWait</td>
<td tal:content="python: '//div[@id=\'group_lane_%s\']//a' % (str(DateTime().dow()+1)) " ></td>
<td tal:content="python: '//div[@id=\'group_lane_%s\']//a' % (str(DateTime().dow() + 1))"></td>
<td></td>
</tr>
<tr>
......
......@@ -12,7 +12,7 @@
<tal:block metal:use-macro="here/ListBoxZuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1;portal_type=Bar</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=1&amp;portal_type=Bar</td>
<td></td>
</tr>
<tr>
......
......@@ -35,7 +35,7 @@
</tr>
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=3;portal_type=Bar</td>
<td>${base_url}/bar_module/FooModule_createObjects?num:int=3&amp;portal_type=Bar</td>
<td></td>
</tr>
<tr>
......
......@@ -9,7 +9,7 @@ wtool = getToolByName(context, 'portal_workflow')
result = 'OK'
error_list = []
def assertEquals(a, b, msg=''):
def assertEqual(a, b, msg=''):
if a != b:
if msg:
error_list.append(msg)
......@@ -17,25 +17,25 @@ def assertEquals(a, b, msg=''):
error_list.append('%r != %r' % (a, b))
foo_2 = foo_module['2']
assertEquals(foo_2.getSimulationState(), 'validated',
assertEqual(foo_2.getSimulationState(), 'validated',
'Foo 2 state is %s' % foo_2.getSimulationState())
if not error_list:
assertEquals(
assertEqual(
wtool.getInfoFor(foo_2, 'history', wf_id='foo_workflow')[-2]['comment'],
'Comment !')
assertEquals(
assertEqual(
wtool.getInfoFor(foo_2, 'history', wf_id='foo_workflow')[-2]['custom_workflow_variable'],
'Custom Workflow Variable')
foo_3 = foo_module['3']
assertEquals(foo_3.getSimulationState(), 'validated',
assertEqual(foo_3.getSimulationState(), 'validated',
'Foo 3 state is %s' % foo_3.getSimulationState())
if not error_list:
assertEquals(
assertEqual(
wtool.getInfoFor(foo_3, 'history', wf_id='foo_workflow')[-2]['comment'],
'Comment !')
assertEquals(
assertEqual(
wtool.getInfoFor(foo_2, 'history', wf_id='foo_workflow')[-2]['custom_workflow_variable'],
'Custom Workflow Variable')
......
......@@ -9,7 +9,7 @@ wtool = getToolByName(context, 'portal_workflow')
result = 'OK'
error_list = []
def assertEquals(a, b, msg=''):
def assertEqual(a, b, msg=''):
if a != b:
if msg:
error_list.append(msg)
......@@ -17,18 +17,18 @@ def assertEquals(a, b, msg=''):
error_list.append('%r != %r' % (a, b))
foo_2 = foo_module['2']
assertEquals(foo_2.getSimulationState(), 'validated',
assertEqual(foo_2.getSimulationState(), 'validated',
'Foo 2 state is %s' % foo_2.getSimulationState())
if not error_list:
assertEquals(
assertEqual(
wtool.getInfoFor(foo_2, 'history', wf_id='foo_workflow')[-2]['comment'],
'Comment !')
foo_3 = foo_module['3']
assertEquals(foo_3.getSimulationState(), 'validated',
assertEqual(foo_3.getSimulationState(), 'validated',
'Foo 3 state is %s' % foo_3.getSimulationState())
if not error_list:
assertEquals(
assertEqual(
wtool.getInfoFor(foo_3, 'history', wf_id='foo_workflow')[-2]['comment'],
'Comment !')
......
......@@ -10,7 +10,7 @@ wtool = getToolByName(context, 'portal_workflow')
result = 'OK'
error_list = []
def assertEquals(a, b, msg=''):
def assertEqual(a, b, msg=''):
if a != b:
if msg:
error_list.append(msg)
......@@ -18,15 +18,15 @@ def assertEquals(a, b, msg=''):
error_list.append('%r != %r' % (a, b))
foo_2 = foo_module['2']
assertEquals(foo_2.getSimulationState(), 'draft',
assertEqual(foo_2.getSimulationState(), 'draft',
'Foo 2 state is %s' % foo_2.getSimulationState())
foo_3 = foo_module['3']
assertEquals(foo_3.getSimulationState(), 'validated',
assertEqual(foo_3.getSimulationState(), 'validated',
'Foo 3 state is %s' % foo_3.getSimulationState())
if not error_list:
assertEquals(
assertEqual(
wtool.getInfoFor(foo_3, 'history', wf_id='foo_workflow')[-2]['comment'],
'Comment !')
......
......@@ -259,6 +259,7 @@ class TestERP5Web(ERP5TypeTestCase):
page.edit(text_content='<p>Hé Hé Hé!</p>', content_type='text/html')
self.tic()
self.assertEqual('Hé Hé Hé!', page.asText().strip())
self.assertIn('Hé Hé Hé!', page.getSearchableText())
def test_WebPageAsTextHTMLEntities(self):
"""Check if Web Page's asText() converts html entities properly
......
......@@ -15,7 +15,7 @@ portal = context.getPortalObject()
default_language = web_section.getLayoutProperty("default_available_language", default='en')
website_url_set = {}
#simplify code of Base_doLanguage, can't ues Base_doLanguage directly
# simplify code of Base_doLanguage, can't use Base_doLanguage directly
root_website_url = web_section.getOriginalDocument().absolute_url()
website_url_pattern = r'^%s(?:%s)*(/|$)' % (
re.escape(root_website_url),
......
......@@ -48,7 +48,7 @@
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_columns=modification_date%7CModification%20Date;field_editable=checked</td>
<td>${base_url}/foo_module/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_columns=modification_date%7CModification%20Date&amp;field_editable=checked</td>
<td></td>
</tr>
......
......@@ -45,7 +45,6 @@ class ShaDirMixin(object):
Initialize the ERP5 site.
"""
self.login()
self.portal = self.getPortal()
self.key = 'mykey' + str(random.random())
self.file_content = 'This is the content.'
......
......@@ -366,8 +366,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
security.declareProtected(Permissions.AccessContentsInformation, 'getTextContent')
def getTextContent(self, default=_MARKER):
"""Overriden method to check
permission to access content in raw format
"""Overridden method to check permission to access content in raw format
"""
self._checkConversionFormatPermission(None)
if default is _MARKER:
......
......@@ -111,9 +111,6 @@ class MailMessageMixin:
"""
Returns the content information from the header information.
This is used by the metadata discovery system.
Header information is converted in UTF-8 since this is the standard
way of representing strings in ERP5.
"""
result = {}
for (name, value) in self._getMessage().items():
......
......@@ -46,8 +46,8 @@ class TextConvertableMixin:
"""
Converts the current document to plain text
"""
kw.pop('format', None)
_, data = self.convert(format='txt', **kw)
kw['format'] = 'txt'
_, data = self.convert(**kw)
return str(data)
security.declareProtected(Permissions.AccessContentsInformation,
......@@ -56,9 +56,8 @@ class TextConvertableMixin:
"""
Converts the current document to plain text without substitution
"""
kw.pop('format', None)
_, data = self.convert(format='txt', substitute=False, **kw)
return str(data)
kw['substitute'] = False
return self.asText(**kw)
security.declareProtected(Permissions.AccessContentsInformation,
'asTextContent')
......
......@@ -186,4 +186,5 @@ class BusinessTemplateInfoDir(BusinessTemplateInfoBase):
return fileinfo
def readFileInfo(self, fileinfo):
return open(fileinfo).read()
with open(fileinfo) as f:
return f.read()
......@@ -32,7 +32,6 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from six import StringIO
class TestFormPrintoutMixin(ERP5TypeTestCase):
run_all_test = 1
......
......@@ -792,10 +792,10 @@ class TestIngestion(IngestionTestCase):
document.edit(file=f)
mime, text = document.convert('text')
self.assertIn('magic', text)
self.assertTrue(mime == 'text/plain')
self.assertEqual(mime, 'text/plain')
mime, html = document.convert('html')
self.assertIn('magic', html)
self.assertTrue(mime == 'text/html')
self.assertEqual(mime, 'text/html')
def stepExportImage(self, sequence=None, sequence_list=None, **kw):
"""
......
......@@ -62,24 +62,24 @@ if IS_ZOPE2: # BBB
def _setUserNameForAccessLog(username, REQUEST):
"""Make the current user look as `username` in Zope's Z2.log
Taken from Products.CMFCore.CookieCrumbler._setAuthHeader
"""
# Set the authorization header in the medusa http request
# so that the username can be logged to the Z2.log
# Put the full-arm latex glove on now...
Taken from Products.CMFCore.CookieCrumbler._setAuthHeader
"""
# Set the authorization header in the medusa http request
# so that the username can be logged to the Z2.log
# Put the full-arm latex glove on now...
try:
# Is this WSGI ?
REQUEST._orig_env['wsgi.input']
except KeyError:
# Not WSGI, maybe Medusa
try:
# Is this WSGI ?
REQUEST._orig_env['wsgi.input']
except KeyError:
# Not WSGI, maybe Medusa
try:
medusa_headers = REQUEST.RESPONSE.stdout._request._header_cache
except AttributeError:
pass
else:
medusa_headers['authorization'] = 'Basic %s' % encodestring('%s:' % username).rstrip()
medusa_headers = REQUEST.RESPONSE.stdout._request._header_cache
except AttributeError:
pass
else:
REQUEST._orig_env['REMOTE_USER'] = username
medusa_headers['authorization'] = 'Basic %s' % encodestring('%s:' % username).rstrip()
else:
REQUEST._orig_env['REMOTE_USER'] = username
else: # zope4
def _setUserNameForAccessLog(username, REQUEST):
"""
......
......@@ -37,7 +37,6 @@ from .BaseCache import BaseCache
from .BaseCache import CacheEntry
from Products.ERP5Type import interfaces
import zope.interface
from base64 import encodestring
try:
from Products.ERP5Type.Tool.MemcachedTool import MemcachedDict, SharedDict
......
......@@ -130,7 +130,7 @@ def patch_linecache():
properly without requiring to create a temporary file on the filesystem
The filename is is always '<portal_components/*>' for ZODB Components,
'(FILENAME)?Script \(Python\)' for Zope Python Scripts and 'Python
'(FILENAME)?Script \\(Python\\)' for Zope Python Scripts and 'Python
Expression "CODE"' for TALES expressions.
linecache.cache filled by linecache.updatecache() called by the original
......
......@@ -9,7 +9,6 @@ __version__ = '0.3.0'
import base64
import errno
import httplib
import os
import random
import re
......@@ -18,7 +17,6 @@ import string
import sys
import time
import traceback
import urllib
import ConfigParser
from contextlib import contextmanager
from io import BytesIO
......@@ -32,7 +30,6 @@ from DateTime import DateTime
import mock
import Products.ZMySQLDA.DA
from Products.ZMySQLDA.DA import Connection as ZMySQLDA_Connection
from zope.globalrequest import clearRequest
from zope.globalrequest import getRequest
from zope.globalrequest import setRequest
import six
......@@ -171,7 +168,8 @@ def _createTestPromiseConfigurationFile(promise_path, bt5_repository_path_list=N
promise_config.set('portal_certificate_authority', 'certificate_authority_path',
os.environ['TEST_CA_PATH'])
promise_config.write(open(promise_path, 'w'))
with open(promise_path, 'w') as f:
promise_config.write(f)
def profile_if_environ(environment_var_name):
if int(os.environ.get(environment_var_name, 0)):
......
......@@ -3651,6 +3651,8 @@ class TestZodbDocumentComponentReload(ERP5TypeTestCase):
component = self.portal.portal_components['document.erp5.BusinessProcess']
component.setTextContent(value)
self.tic()
self.assertEqual(component.checkConsistency(), [])
self.assertEqual(component.getValidationState(), 'validated')
def testAsComposedDocumentCacheIsCorrectlyFlushed(self):
component = self.portal.portal_components['document.erp5.BusinessProcess']
......
......@@ -34,7 +34,8 @@ class commandtransform:
os.mkdir(tmpdir)
filename = kwargs.get("filename", '')
fullname = join(tmpdir, basename(filename))
filedest = open(fullname , "wb").write(data)
with open(fullname , "wb") as f:
f.write(data)
return tmpdir, fullname
def subObjects(self, tmpdir):
......@@ -50,7 +51,8 @@ class commandtransform:
def fixImages(self, path, images, objects):
for image in images:
objects[image] = open(join(path, image), 'rb').read()
with open(join(path, image), 'rb') as f:
objects[image] = f.read()
def cleanDir(self, tmpdir):
shutil.rmtree(tmpdir)
......@@ -151,7 +153,7 @@ class subprocesstransform:
try:
if not self.useStdin:
stdin_file = tempfile.NamedTemporaryFile()
stdin_file.write( data)
stdin_file.write(data)
stdin_file.seek(0)
command = command % {'infile': stdin_file.name} # apply tmp name to command
data = None
......
......@@ -21,7 +21,6 @@ from __future__ import print_function
import BaseHTTPServer
import CGIHTTPServer
import time
import httplib
import sys
PORT = 8000
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment