Browse Source

[10.0][MIG][html_image_url_extractor] Migration

pull/1155/head
Jairo Llopis 8 years ago
committed by tarteo
parent
commit
05a0a20e8c
  1. 2
      html_image_url_extractor/README.rst
  2. 2
      html_image_url_extractor/__init__.py
  3. 6
      html_image_url_extractor/__manifest__.py
  4. 2
      html_image_url_extractor/models/__init__.py
  5. 6
      html_image_url_extractor/models/ir_fields_converter.py
  6. 1
      html_image_url_extractor/tests/__init__.py
  7. 13
      html_image_url_extractor/tests/test_extractor.py

2
html_image_url_extractor/README.rst

@ -38,7 +38,7 @@ QWeb example::
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/149/9.0
:target: https://runbot.odoo-community.org/runbot/149/10.0
Known issues / Roadmap Known issues / Roadmap
====================== ======================

2
html_image_url_extractor/__init__.py

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models

6
html_image_url_extractor/__openerp__.py → html_image_url_extractor/__manifest__.py

@ -1,13 +1,13 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright 2016 Tecnativa - Vicent Cubells # Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
"name": "Image URLs from HTML field", "name": "Image URLs from HTML field",
"summary": "Extract images found in any HTML field", "summary": "Extract images found in any HTML field",
"version": "9.0.1.0.0",
"version": "10.0.1.0.0",
"category": "Tools", "category": "Tools",
"website": "https://tecnativa.com",
"website": "https://www.tecnativa.com",
"author": "Tecnativa, " "author": "Tecnativa, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",

2
html_image_url_extractor/models/__init__.py

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import ir_fields_converter from . import ir_fields_converter

6
html_image_url_extractor/models/ir_fields_converter.py

@ -1,17 +1,17 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright 2016 Tecnativa - Vicent Cubells # Copyright 2016 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import re import re
import logging import logging
from lxml import etree, html from lxml import etree, html
from openerp import api, models
from odoo import api, models
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class IrFieldsConverter(models.Model):
class IrFieldsConverter(models.AbstractModel):
_inherit = "ir.fields.converter" _inherit = "ir.fields.converter"
@api.model @api.model

1
html_image_url_extractor/tests/__init__.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_extractor from . import test_extractor

13
html_image_url_extractor/tests/test_extractor.py

@ -1,15 +1,16 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# Copyright 2016-2017 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from lxml import etree from lxml import etree
from openerp.tests.common import TransactionCase
from odoo.tools import mute_logger
from odoo.tests.common import TransactionCase
from ..models import ir_fields_converter
class ExtractorCase(TransactionCase): class ExtractorCase(TransactionCase):
def setUp(self): def setUp(self):
super(ExtractorCase, self).setUp() super(ExtractorCase, self).setUp()
# Shortcut # Shortcut
self.imgs_from_html = self.env["ir.fields.converter"].imgs_from_html self.imgs_from_html = self.env["ir.fields.converter"].imgs_from_html
@ -44,26 +45,26 @@ class ExtractorCase(TransactionCase):
self.assertEqual("/path/%d" % n, url) self.assertEqual("/path/%d" % n, url)
self.assertEqual(n, 0) self.assertEqual(n, 0)
@mute_logger(ir_fields_converter.__name__)
def test_empty_html(self): def test_empty_html(self):
"""Empty HTML handled correctly.""" """Empty HTML handled correctly."""
for laps, text in self.imgs_from_html(""): for laps, text in self.imgs_from_html(""):
self.assertTrue(False) # You should never get here self.assertTrue(False) # You should never get here
with self.assertRaises(etree.XMLSyntaxError): with self.assertRaises(etree.XMLSyntaxError):
list(self.imgs_from_html("", fail=True)) list(self.imgs_from_html("", fail=True))
@mute_logger(ir_fields_converter.__name__)
def test_false_html(self): def test_false_html(self):
"""``False`` HTML handled correctly.""" """``False`` HTML handled correctly."""
for laps, text in self.imgs_from_html(False): for laps, text in self.imgs_from_html(False):
self.assertTrue(False) # You should never get here self.assertTrue(False) # You should never get here
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
list(self.imgs_from_html(False, fail=True)) list(self.imgs_from_html(False, fail=True))
@mute_logger(ir_fields_converter.__name__)
def test_bad_html(self): def test_bad_html(self):
"""Bad HTML handled correctly.""" """Bad HTML handled correctly."""
for laps, text in self.imgs_from_html("<<bad>"): for laps, text in self.imgs_from_html("<<bad>"):
self.assertTrue(False) # You should never get here self.assertTrue(False) # You should never get here
with self.assertRaises(etree.ParserError): with self.assertRaises(etree.ParserError):
list(self.imgs_from_html("<<bad>", fail=True)) list(self.imgs_from_html("<<bad>", fail=True))
Loading…
Cancel
Save