summaryrefslogtreecommitdiff
path: root/addons/website/tests/test_crawl.py
diff options
context:
space:
mode:
authorRavi Gadhia <rga@odoo.com>2016-07-15 10:30:04 +0200
committerJérome Maes <jem@openerp.com>2016-08-04 12:02:14 +0200
commitfd09ddb6f3c40e9ec5854cc58c7eb791d4498dc0 (patch)
tree58e598da9165b3f78a9d35efcc3c9a2167b82a9b /addons/website/tests/test_crawl.py
parent7c20b4785bef5bf2fd84b429d42a2f3425801410 (diff)
[MIG] website: migration to new api
Migration of website module to new API. The tricky phase is ir_http.py : we need to use `request.env` only when the authenfication phase is done. Normally by calling `super` of `_dispatch` method, but website module required it to be done before. This is important since `env`is a lazy property of `request` object. Some hack were kept since this commit is a migration ('RequestUID' in ir.http, ...) Some docstrings were added.
Diffstat (limited to 'addons/website/tests/test_crawl.py')
-rw-r--r--addons/website/tests/test_crawl.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/addons/website/tests/test_crawl.py b/addons/website/tests/test_crawl.py
index 52865e23a2a..189e6531e3f 100644
--- a/addons/website/tests/test_crawl.py
+++ b/addons/website/tests/test_crawl.py
@@ -5,13 +5,13 @@ import time
import lxml.html
-import openerp
+import odoo
import re
_logger = logging.getLogger(__name__)
-class Crawler(openerp.tests.HttpCase):
- """ Test suite crawling an openerp CMS instance and checking that all
+class Crawler(odoo.tests.HttpCase):
+ """ Test suite crawling an Odoo CMS instance and checking that all
internal links lead to a 200 response.
If a username and a password are provided, authenticates the user before
@@ -22,7 +22,7 @@ class Crawler(openerp.tests.HttpCase):
post_install = True
def crawl(self, url, seen=None, msg=''):
- if seen == None:
+ if seen is None:
seen = set()
url_slug = re.sub(r"[/](([^/=?&]+-)?[0-9]+)([/]|$)", '/<slug>/', url)
@@ -35,7 +35,7 @@ class Crawler(openerp.tests.HttpCase):
_logger.info("%s %s", msg, url)
r = self.url_open(url)
code = r.getcode()
- self.assertIn( code, xrange(200, 300), "%s Fetching %s returned error response (%d)" % (msg, url, code))
+ self.assertIn(code, xrange(200, 300), "%s Fetching %s returned error response (%d)" % (msg, url, code))
if r.info().gettype() == 'text/html':
doc = lxml.html.fromstring(r.read())
@@ -64,7 +64,6 @@ class Crawler(openerp.tests.HttpCase):
self.crawl(href, seen, msg)
return seen
-
def test_10_crawl_public(self):
t0 = time.time()
t0_sql = self.registry.test_cr.sql_log_count
@@ -72,7 +71,7 @@ class Crawler(openerp.tests.HttpCase):
count = len(seen)
duration = time.time() - t0
sql = self.registry.test_cr.sql_log_count - t0_sql
- _logger.log(25, "public crawled %s urls in %.2fs %s queries, %.3fs %.2fq per request, ", count, duration, sql, duration/count, float(sql)/count)
+ _logger.log(25, "public crawled %s urls in %.2fs %s queries, %.3fs %.2fq per request, ", count, duration, sql, duration / count, float(sql) / count)
def test_20_crawl_demo(self):
t0 = time.time()
@@ -82,7 +81,7 @@ class Crawler(openerp.tests.HttpCase):
count = len(seen)
duration = time.time() - t0
sql = self.registry.test_cr.sql_log_count - t0_sql
- _logger.log(25, "demo crawled %s urls in %.2fs %s queries, %.3fs %.2fq per request", count, duration, sql, duration/count, float(sql)/count)
+ _logger.log(25, "demo crawled %s urls in %.2fs %s queries, %.3fs %.2fq per request", count, duration, sql, duration / count, float(sql) / count)
def test_30_crawl_admin(self):
t0 = time.time()
@@ -92,4 +91,4 @@ class Crawler(openerp.tests.HttpCase):
count = len(seen)
duration = time.time() - t0
sql = self.registry.test_cr.sql_log_count - t0_sql
- _logger.log(25, "admin crawled %s urls in %.2fs %s queries, %.3fs %.2fq per request", count, duration, sql, duration/count, float(sql)/count)
+ _logger.log(25, "admin crawled %s urls in %.2fs %s queries, %.3fs %.2fq per request", count, duration, sql, duration / count, float(sql) / count)