Browse Source

[FLAKE8] fix falke 8 issues

pull/46/head
Cédric Pigeon 10 years ago
parent
commit
679e03c668
  1. 22
      help_online/models/export_help_wizard.py
  2. 26
      help_online/tests/test_export_help_wizard.py

22
help_online/models/export_help_wizard.py

@ -121,11 +121,11 @@ class ExportHelpWizard(models.TransientModel):
continue
page_url = '/page/%s' % page_prefix
template_url = '/page/%s' % template_prefix
if not page_url in href and not template_url in href:
if page_url not in href and template_url not in href:
continue
elif page_url in href and not template_url in href:
elif page_url in href and template_url not in href:
pass
elif not page_url in href and template_url in href:
elif page_url not in href and template_url in href:
page_url = template_url
else:
if page_prefix in template_prefix:
@ -157,17 +157,17 @@ class ExportHelpWizard(models.TransientModel):
thumbnail = ET.SubElement(main_div,
'div',
attrib={'class': 'oe_snippet_thumbnail'})
img = ET.SubElement(thumbnail,
'img',
attrib={'class': 'oe_snippet_thumbnail_img',
'src': HELP_ONLINE_SNIPPET_IMAGE_PATH})
ET.SubElement(thumbnail,
'img',
attrib={'class': 'oe_snippet_thumbnail_img',
'src': HELP_ONLINE_SNIPPET_IMAGE_PATH})
span = ET.SubElement(thumbnail,
'span',
attrib={'class': 'oe_snippet_thumbnail_title'})
span.text = page_node.attrib['name'].replace(template_prefix, '')
body = ET.SubElement(main_div,
'section',
attrib={'class': 'oe_snippet_body '\
attrib={'class': 'oe_snippet_body '
'mt_simple_snippet'})
template = page.find(".//div[@id='wrap']")
@ -272,6 +272,6 @@ class ExportHelpWizard(models.TransientModel):
backup_file.write(xml_data)
backup_file.close
except:
_logger.warning(_('Unable to write autobackup file '\
'in given directory: %s'
% autobackup_path))
_logger.warning(_('Unable to write autobackup file '
'in given directory: %s'
% autobackup_path))

26
help_online/tests/test_export_help_wizard.py

@ -58,7 +58,7 @@ class test_export_help_wizard(object):
attrib={'class': 'row'})
bodyDivNode = ET.SubElement(rowNode,
'div',
attrib={'class': 'col-md-12 '\
attrib={'class': 'col-md-12 '
'text-center mt16 mb32'})
style = "font-family: 'Helvetica Neue', Helvetica,"\
" Arial, sans-serif; color: rgb(51, 51, 51);"\
@ -73,18 +73,18 @@ class test_export_help_wizard(object):
attrib={'style': 'text-align: left;'})
src = "/website/image?field=datas&"\
"model=ir.attachment&id=%s" % str(imgId)
imgNode = ET.SubElement(imgDivNode,
'img',
attrib={'class': 'img-thumbnail',
'src': src})
ET.SubElement(imgDivNode,
'img',
attrib={'class': 'img-thumbnail',
'src': src})
imgDivNode = ET.SubElement(bodyDivNode,
'div',
attrib={'style': 'text-align: left;'})
src = "/website/image/ir.attachment/%s_ccc838d/datas" % str(imgId)
imgNode = ET.SubElement(imgDivNode,
'img',
attrib={'class': 'img-thumbnail',
'src': src})
ET.SubElement(imgDivNode,
'img',
attrib={'class': 'img-thumbnail',
'src': src})
arch = ET.tostring(rootNode, encoding='utf-8', xml_declaration=False)
vals = {
'name': pageName,
@ -128,7 +128,7 @@ class test_export_help_wizard(object):
for imgElem in templateNodeList[0].iter('img'):
imgSrc = imgElem.get('src')
if '/ir.attachment/' in imgSrc:
self.assertIn("/ir.attachment/%s_img_02|" \
self.assertIn("/ir.attachment/%s_img_02|"
% self.pageName, imgSrc)
else:
self.assertIn("id=%s_img_01" % self.pageName, imgSrc)
@ -151,11 +151,11 @@ class test_export_help_with_image(test_export_help_wizard,
class test_export_help_template(test_export_help_wizard,
SharedSetupTransactionCase):
SharedSetupTransactionCase):
def setUp(self):
super(test_export_help_template, self).setUp()
parameter_model = self.env['ir.config_parameter']
template_prefix = parameter_model.get_param(
'help_online_template_prefix')
param = 'help_online_template_prefix'
template_prefix = parameter_model.get_param(param)
self.pageName = '%stest-template' % template_prefix
self.pageTemplate = True
Loading…
Cancel
Save