diff options
| author | Xavier Morel <xmo@openerp.com> | 2014-02-17 16:15:35 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2014-02-17 16:15:35 +0100 |
| commit | aa0eac1257b97c1be693e8a804fec6ecbf2bb22f (patch) | |
| tree | dd6a31e306acfe5b797dd5b5b00a003eb344392b /addons/website/tests/cases.py | |
| parent | 665e2629e272426293b90a7b554289231c8b4e10 (diff) | |
[FIX] re-enable crawler tests
Move URLCase back out of the test module, otherwise loadTestFromModule
attempts to load it in the usual manner (~URLCase('runTest')). Which does not
work at all, because that's not what URLCase is for.
URLCase extends TestCase to benefit from the TestCase.run infrastructure
(running tests, filling result object, etc...)
bzr revid: xmo@openerp.com-20140217151535-alq7pq6qapski73x
Diffstat (limited to 'addons/website/tests/cases.py')
| -rw-r--r-- | addons/website/tests/cases.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/addons/website/tests/cases.py b/addons/website/tests/cases.py new file mode 100644 index 00000000000..3e777293ff9 --- /dev/null +++ b/addons/website/tests/cases.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +import unittest2 + +class URLCase(unittest2.TestCase): + """ + URLCase moved out of test_requests, otherwise discovery attempts to + instantiate and run it + """ + def __init__(self, user, url, source, result): + super(URLCase, self).__init__() + self.user = user + self.url = url + self.source = source + self.result = result + + @property + def username(self): + return self.user or "Anonymous Coward" + + def __str__(self): + if self.source: + return "%s (from %s, as %s)" % (self.url, self.source, self.username) + return "%s (as %s)" % (self.url, self.username) + + __repr__ = __str__ + + def shortDescription(self): + return "" + + def runTest(self): + code = self.result.getcode() + self.assertIn( + code, xrange(200, 300), + "Fetching %s as %s returned an error response (%d)" % ( + self.url, self.username, code)) |
