diff --git a/website_canonical_url/__openerp__.py b/website_canonical_url/__openerp__.py index 044992901d..e1dd41e5d4 100644 --- a/website_canonical_url/__openerp__.py +++ b/website_canonical_url/__openerp__.py @@ -16,4 +16,7 @@ 'data': [ 'templates/layout.xml', ], + 'demo': [ + 'demo/pages.xml', + ], } diff --git a/website_canonical_url/demo/pages.xml b/website_canonical_url/demo/pages.xml new file mode 100644 index 0000000000..a7324df9c5 --- /dev/null +++ b/website_canonical_url/demo/pages.xml @@ -0,0 +1,15 @@ + + + + + + + diff --git a/website_canonical_url/tests/__init__.py b/website_canonical_url/tests/__init__.py new file mode 100644 index 0000000000..1382db57d7 --- /dev/null +++ b/website_canonical_url/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_tags diff --git a/website_canonical_url/tests/test_tags.py b/website_canonical_url/tests/test_tags.py new file mode 100644 index 0000000000..5a638ab5ba --- /dev/null +++ b/website_canonical_url/tests/test_tags.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp.tests.common import HttpCase +from lxml.html import document_fromstring + + +class UICase(HttpCase): + def setUp(self): + super(UICase, self).setUp() + self.url = "/page/website_canonical_url.canonical_demo" + with self.url_open("%s?ultimate_answer=42" % self.url) as data: + self.doc = document_fromstring(data.read()) + + def test_canonical(self): + """Canonical URL is built OK.""" + node = self.doc.xpath("/html/head/link[@rel='canonical']")[0] + self.assertEqual(node.attrib["href"], self.url) + + def test_pager_next(self): + """Next pager link is OK.""" + node = self.doc.xpath("/html/head/link[@rel='next']")[0] + self.assertEqual(node.attrib["href"], "%s/page/3" & self.url) + + def test_pager_prev(self): + """Prev pager link is OK.""" + node = self.doc.xpath("/html/head/link[@rel='prev']")[0] + self.assertEqual(node.attrib["href"], self.url)