Fixes bootstrap tests

The existing test_bootstrap test didn't actually test anything. The
called_anytime function would return a False, but nothing would turn
that into an error.

Change-Id: I32aab4dc80e6701abc70e34d8511c1008dadd2e0
This commit is contained in:
David Stanek
2015-01-15 18:29:47 +00:00
committed by ZhiQiang Fan
parent c5f207a89b
commit 1b9b9ed905

View File

@@ -14,6 +14,7 @@ import os
import sys import sys
import mock import mock
from oslo.serialization import jsonutils
import six import six
from testtools import matchers from testtools import matchers
@@ -381,22 +382,21 @@ class ShellTests(utils.TestCase):
' --tenant-name new-tenant') ' --tenant-name new-tenant')
def called_anytime(method, path, json=None): def called_anytime(method, path, json=None):
test_url = self.TEST_URL.strip('/')
for r in self.requests.request_history: for r in self.requests.request_history:
if not r.method == method: if not r.method == method:
continue continue
if not r.url == self.TEST_URL + path: if not r.url == test_url + path:
continue continue
if json: if json:
last_request_body = r.body.decode('utf-8') json_body = jsonutils.loads(r.body)
json_body = jsonutils.loads(last_request_body)
if not json_body == json: if not json_body == json:
continue continue
return True return True
return False raise AssertionError('URL never called')
called_anytime('POST', '/users', {'user': {'email': None, called_anytime('POST', '/users', {'user': {'email': None,
'password': '1', 'password': '1',
@@ -409,7 +409,7 @@ class ShellTests(utils.TestCase):
"description": None}}) "description": None}})
called_anytime('POST', '/OS-KSADM/roles', called_anytime('POST', '/OS-KSADM/roles',
{"role": {"name": "new-role"}}) {"role": {"name": "admin"}})
called_anytime('PUT', '/tenants/1/users/1/roles/OS-KSADM/1') called_anytime('PUT', '/tenants/1/users/1/roles/OS-KSADM/1')