Testing improvements.
Fixes bug 903349 -- sets socket timeout and overrides httplib2 connection method so that escaping external URI calls don't sit around forever. Fixes bug 894776 -- run_tests.sh properly respects the -N flag again. Change-Id: I979f49f065021cb91d8b9d01b6a36f78de1897df
This commit is contained in:
parent
17b02f9e6e
commit
c63d0973fa
@ -25,6 +25,7 @@ from django import shortcuts
|
||||
from django import test as django_test
|
||||
from django import template as django_template
|
||||
from django.conf import settings
|
||||
import httplib2
|
||||
import mox
|
||||
|
||||
from horizon import context_processors
|
||||
@ -114,6 +115,13 @@ class TestCase(django_test.TestCase):
|
||||
def setUp(self):
|
||||
self.mox = mox.Mox()
|
||||
|
||||
def fake_conn_request(*args, **kwargs):
|
||||
raise Exception("An external URI request tried to escape through "
|
||||
"an httplib2 client. Args: %s, kwargs: %s"
|
||||
% (args, kwargs))
|
||||
self._real_conn_request = httplib2.Http._conn_request
|
||||
httplib2.Http._conn_request = fake_conn_request
|
||||
|
||||
self._real_horizon_context_processor = context_processors.horizon
|
||||
context_processors.horizon = lambda request: self.TEST_CONTEXT
|
||||
|
||||
@ -127,6 +135,7 @@ class TestCase(django_test.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
self.mox.UnsetStubs()
|
||||
httplib2.Http._conn_request = self._real_conn_request
|
||||
context_processors.horizon = self._real_horizon_context_processor
|
||||
users.get_user_from_request = self._real_get_user_from_request
|
||||
self.mox.VerifyAll()
|
||||
|
@ -19,6 +19,9 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import socket
|
||||
|
||||
socket.setdefaulttimeout(1)
|
||||
|
||||
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
DEBUG = True
|
||||
|
@ -209,6 +209,8 @@ function environment_check {
|
||||
|
||||
function sanity_check {
|
||||
# Anything that should be determined prior to running the tests, server, etc.
|
||||
# Don't sanity-check anything environment-related in -N flag is set
|
||||
if [ $never_venv -eq 0 ]; then
|
||||
if [ ! -e ${venv} ]; then
|
||||
echo "Virtualenv not found at openstack-dashboard/.dashboard-venv. Did install_venv.py succeed?"
|
||||
exit 1
|
||||
@ -225,6 +227,7 @@ function sanity_check {
|
||||
echo "Error: Selenium script not found at horizon/bin/seleniumrc. Did buildout succeed?"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_environment {
|
||||
|
Loading…
x
Reference in New Issue
Block a user