Cleaned up code in anticipation of flake8.
Change-Id: Id710edb1a82110653e783fed13cd589cab75f38a
This commit is contained in:
@@ -18,7 +18,6 @@ import httplib
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import StringIO
|
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -164,7 +163,7 @@ class HTTPClient(object):
|
|||||||
elif resp.status in (301, 302, 305):
|
elif resp.status in (301, 302, 305):
|
||||||
# Redirected. Reissue the request to the new location.
|
# Redirected. Reissue the request to the new location.
|
||||||
location = resp.getheader('location', None)
|
location = resp.getheader('location', None)
|
||||||
if location == None:
|
if location is None:
|
||||||
message = "Location not returned with 302"
|
message = "Location not returned with 302"
|
||||||
raise exc.InvalidEndpoint(message=message)
|
raise exc.InvalidEndpoint(message=message)
|
||||||
elif location.startswith(self.endpoint):
|
elif location.startswith(self.endpoint):
|
||||||
|
@@ -13,8 +13,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import errno
|
|
||||||
import hashlib
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
@@ -13,4 +13,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
__all__ = ['Client']
|
||||||
|
|
||||||
from heatclient.v1.client import Client
|
from heatclient.v1.client import Client
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
from heatclient.common import base
|
from heatclient.common import base
|
||||||
from heatclient.v1 import stacks
|
from heatclient.v1 import stacks
|
||||||
import heatclient.exc as exc
|
|
||||||
|
|
||||||
DEFAULT_PAGE_SIZE = 20
|
DEFAULT_PAGE_SIZE = 20
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ class EventManager(stacks.StackChildManager):
|
|||||||
:param resource_name: Optional name of resources to filter events by
|
:param resource_name: Optional name of resources to filter events by
|
||||||
:rtype: list of :class:`Event`
|
:rtype: list of :class:`Event`
|
||||||
"""
|
"""
|
||||||
if resource_name == None:
|
if resource_name is None:
|
||||||
url = '/stacks/%s/events' % stack_id
|
url = '/stacks/%s/events' % stack_id
|
||||||
else:
|
else:
|
||||||
stack_id = self._resolve_stack_id(stack_id)
|
stack_id = self._resolve_stack_id(stack_id)
|
||||||
|
@@ -13,10 +13,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
from heatclient.common import base
|
from heatclient.common import base
|
||||||
from heatclient.v1 import stacks
|
from heatclient.v1 import stacks
|
||||||
import heatclient.exc as exc
|
|
||||||
|
|
||||||
DEFAULT_PAGE_SIZE = 20
|
DEFAULT_PAGE_SIZE = 20
|
||||||
|
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from heatclient.common import base
|
from heatclient.common import base
|
||||||
import heatclient.exc as exc
|
|
||||||
|
|
||||||
DEFAULT_PAGE_SIZE = 20
|
DEFAULT_PAGE_SIZE = 20
|
||||||
|
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
|
|
||||||
import httplib
|
|
||||||
import json
|
import json
|
||||||
import mox
|
|
||||||
|
|
||||||
from keystoneclient.v2_0 import client as ksclient
|
from keystoneclient.v2_0 import client as ksclient
|
||||||
from heatclient.v1 import client as v1client
|
from heatclient.v1 import client as v1client
|
||||||
|
@@ -1,16 +1,5 @@
|
|||||||
import StringIO
|
|
||||||
import os
|
|
||||||
import httplib2
|
|
||||||
import httplib
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import mox
|
import mox
|
||||||
import unittest
|
import unittest
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError:
|
|
||||||
import simplejson as json
|
|
||||||
from keystoneclient.v2_0 import client as ksclient
|
|
||||||
|
|
||||||
from heatclient import exc
|
from heatclient import exc
|
||||||
from heatclient.common import http
|
from heatclient.common import http
|
||||||
@@ -36,9 +25,11 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
mock_conn.request('GET', '/',
|
mock_conn.request('GET', '/',
|
||||||
headers={'Content-Type': 'application/octet-stream',
|
headers={'Content-Type': 'application/octet-stream',
|
||||||
'User-Agent': 'python-heatclient'})
|
'User-Agent': 'python-heatclient'})
|
||||||
mock_conn.getresponse().AndReturn(fakes.FakeHTTPResponse(200, 'OK',
|
mock_conn.getresponse().AndReturn(
|
||||||
{'content-type': 'application/octet-stream'},
|
fakes.FakeHTTPResponse(
|
||||||
''))
|
200, 'OK',
|
||||||
|
{'content-type': 'application/octet-stream'},
|
||||||
|
''))
|
||||||
# Replay, create client, assert
|
# Replay, create client, assert
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
client = http.HTTPClient('http://example.com:8004')
|
client = http.HTTPClient('http://example.com:8004')
|
||||||
@@ -55,9 +46,11 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
headers={'Content-Type': 'application/json',
|
headers={'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'User-Agent': 'python-heatclient'})
|
'User-Agent': 'python-heatclient'})
|
||||||
mock_conn.getresponse().AndReturn(fakes.FakeHTTPResponse(200, 'OK',
|
mock_conn.getresponse().AndReturn(
|
||||||
{'content-type': 'application/json'},
|
fakes.FakeHTTPResponse(
|
||||||
'{}'))
|
200, 'OK',
|
||||||
|
{'content-type': 'application/json'},
|
||||||
|
'{}'))
|
||||||
# Replay, create client, assert
|
# Replay, create client, assert
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
client = http.HTTPClient('http://example.com:8004')
|
client = http.HTTPClient('http://example.com:8004')
|
||||||
@@ -74,9 +67,11 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
headers={'Content-Type': 'application/json',
|
headers={'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'User-Agent': 'python-heatclient'})
|
'User-Agent': 'python-heatclient'})
|
||||||
mock_conn.getresponse().AndReturn(fakes.FakeHTTPResponse(200, 'OK',
|
mock_conn.getresponse().AndReturn(
|
||||||
{'content-type': 'application/json'},
|
fakes.FakeHTTPResponse(
|
||||||
'{}'))
|
200, 'OK',
|
||||||
|
{'content-type': 'application/json'},
|
||||||
|
'{}'))
|
||||||
# Replay, create client, assert
|
# Replay, create client, assert
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
client = http.HTTPClient('http://example.com:8004')
|
client = http.HTTPClient('http://example.com:8004')
|
||||||
@@ -93,9 +88,11 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
headers={'Content-Type': 'application/json',
|
headers={'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'User-Agent': 'python-heatclient'})
|
'User-Agent': 'python-heatclient'})
|
||||||
mock_conn.getresponse().AndReturn(fakes.FakeHTTPResponse(200, 'OK',
|
mock_conn.getresponse().AndReturn(
|
||||||
{'content-type': 'not/json'},
|
fakes.FakeHTTPResponse(
|
||||||
'{}'))
|
200, 'OK',
|
||||||
|
{'content-type': 'not/json'},
|
||||||
|
'{}'))
|
||||||
# Replay, create client, assert
|
# Replay, create client, assert
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
client = http.HTTPClient('http://example.com:8004')
|
client = http.HTTPClient('http://example.com:8004')
|
||||||
@@ -112,9 +109,11 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
headers={'Content-Type': 'application/json',
|
headers={'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'User-Agent': 'python-heatclient'})
|
'User-Agent': 'python-heatclient'})
|
||||||
mock_conn.getresponse().AndReturn(fakes.FakeHTTPResponse(200, 'OK',
|
mock_conn.getresponse().AndReturn(
|
||||||
{'content-type': 'application/json'},
|
fakes.FakeHTTPResponse(
|
||||||
'invalid-json'))
|
200, 'OK',
|
||||||
|
{'content-type': 'application/json'},
|
||||||
|
'invalid-json'))
|
||||||
# Replay, create client, assert
|
# Replay, create client, assert
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
client = http.HTTPClient('http://example.com:8004')
|
client = http.HTTPClient('http://example.com:8004')
|
||||||
@@ -131,9 +130,11 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
headers={'Content-Type': 'application/json',
|
headers={'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'User-Agent': 'python-heatclient'})
|
'User-Agent': 'python-heatclient'})
|
||||||
mock_conn.getresponse().AndReturn(fakes.FakeHTTPResponse(302, 'Found',
|
mock_conn.getresponse().AndReturn(
|
||||||
{'location': 'http://example.com:8004'
|
fakes.FakeHTTPResponse(
|
||||||
}, ''))
|
302, 'Found',
|
||||||
|
{'location': 'http://example.com:8004'},
|
||||||
|
''))
|
||||||
# Record the following 200
|
# Record the following 200
|
||||||
mock_conn = http.httplib.HTTPConnection('example.com', 8004,
|
mock_conn = http.httplib.HTTPConnection('example.com', 8004,
|
||||||
'', timeout=600.0)
|
'', timeout=600.0)
|
||||||
@@ -141,9 +142,11 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
headers={'Content-Type': 'application/json',
|
headers={'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'User-Agent': 'python-heatclient'})
|
'User-Agent': 'python-heatclient'})
|
||||||
mock_conn.getresponse().AndReturn(fakes.FakeHTTPResponse(200, 'OK',
|
mock_conn.getresponse().AndReturn(
|
||||||
{'content-type': 'application/json'},
|
fakes.FakeHTTPResponse(
|
||||||
'{}'))
|
200, 'OK',
|
||||||
|
{'content-type': 'application/json'},
|
||||||
|
'{}'))
|
||||||
# Replay, create client, assert
|
# Replay, create client, assert
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
client = http.HTTPClient('http://example.com:8004')
|
client = http.HTTPClient('http://example.com:8004')
|
||||||
@@ -160,9 +163,11 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
headers={'Content-Type': 'application/json',
|
headers={'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'User-Agent': 'python-heatclient'})
|
'User-Agent': 'python-heatclient'})
|
||||||
mock_conn.getresponse().AndReturn(fakes.FakeHTTPResponse(302, 'Found',
|
mock_conn.getresponse().AndReturn(
|
||||||
{'location': 'http://prohibited.example.com:8004'
|
fakes.FakeHTTPResponse(
|
||||||
}, ''))
|
302, 'Found',
|
||||||
|
{'location': 'http://prohibited.example.com:8004'},
|
||||||
|
''))
|
||||||
# Replay, create client, assert
|
# Replay, create client, assert
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
client = http.HTTPClient('http://example.com:8004')
|
client = http.HTTPClient('http://example.com:8004')
|
||||||
@@ -177,9 +182,10 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
headers={'Content-Type': 'application/json',
|
headers={'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'User-Agent': 'python-heatclient'})
|
'User-Agent': 'python-heatclient'})
|
||||||
mock_conn.getresponse().AndReturn(fakes.FakeHTTPResponse(404, 'OK',
|
mock_conn.getresponse().AndReturn(
|
||||||
{'content-type': 'application/json'},
|
fakes.FakeHTTPResponse(
|
||||||
'{}'))
|
404, 'OK', {'content-type': 'application/json'},
|
||||||
|
'{}'))
|
||||||
# Replay, create client, assert
|
# Replay, create client, assert
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
client = http.HTTPClient('http://example.com:8004')
|
client = http.HTTPClient('http://example.com:8004')
|
||||||
@@ -201,9 +207,10 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
headers={'Content-Type': 'application/json',
|
headers={'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'User-Agent': 'python-heatclient'})
|
'User-Agent': 'python-heatclient'})
|
||||||
mock_conn.getresponse().AndReturn(fakes.FakeHTTPResponse(300, 'OK',
|
mock_conn.getresponse().AndReturn(
|
||||||
{'content-type': 'application/json'},
|
fakes.FakeHTTPResponse(
|
||||||
'{}'))
|
300, 'OK', {'content-type': 'application/json'},
|
||||||
|
'{}'))
|
||||||
# Replay, create client, assert
|
# Replay, create client, assert
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
client = http.HTTPClient('http://example.com:8004')
|
client = http.HTTPClient('http://example.com:8004')
|
||||||
@@ -230,14 +237,15 @@ class HttpClientTest(unittest.TestCase):
|
|||||||
# '{}'))
|
# '{}'))
|
||||||
# # Replay, create client, assert
|
# # Replay, create client, assert
|
||||||
# self.m.ReplayAll()
|
# self.m.ReplayAll()
|
||||||
# client = http.HTTPClient('https://example.com:8004', ca_file='dummy',
|
# client = http.HTTPClient('https://example.com:8004',
|
||||||
# cert_file='dummy',
|
# ca_file='dummy',
|
||||||
# key_file='dummy')
|
# cert_file='dummy',
|
||||||
|
# key_file='dummy')
|
||||||
# resp, body = client.json_request('GET', '')
|
# resp, body = client.json_request('GET', '')
|
||||||
# self.assertEqual(resp.status, 200)
|
# self.assertEqual(resp.status, 200)
|
||||||
# self.assertEqual(body, {})
|
# self.assertEqual(body, {})
|
||||||
# self.m.VerifyAll()
|
# self.m.VerifyAll()
|
||||||
|
|
||||||
def test_fake_json_request(self):
|
def test_fake_json_request(self):
|
||||||
self.assertRaises(exc.InvalidEndpoint, http.HTTPClient, 'fake://example.com:8004')
|
self.assertRaises(exc.InvalidEndpoint, http.HTTPClient,
|
||||||
|
'fake://example.com:8004')
|
||||||
|
@@ -29,8 +29,8 @@ class TestCase(unittest.TestCase):
|
|||||||
expected_regexp = re.compile(expected_regexp)
|
expected_regexp = re.compile(expected_regexp)
|
||||||
if not expected_regexp.search(text):
|
if not expected_regexp.search(text):
|
||||||
msg = msg or "Regexp didn't match"
|
msg = msg or "Regexp didn't match"
|
||||||
msg = '%s: %r not found in %r' % (msg, expected_regexp.pattern,
|
msg = '%s: %r not found in %r' % (
|
||||||
text)
|
msg, expected_regexp.pattern, text)
|
||||||
raise self.failureException(msg)
|
raise self.failureException(msg)
|
||||||
|
|
||||||
|
|
||||||
@@ -78,8 +78,8 @@ class ShellValidationTest(TestCase):
|
|||||||
m.StubOutWithMock(ksclient, 'Client')
|
m.StubOutWithMock(ksclient, 'Client')
|
||||||
m.StubOutWithMock(v1client.Client, 'json_request')
|
m.StubOutWithMock(v1client.Client, 'json_request')
|
||||||
fakes.script_keystone_client()
|
fakes.script_keystone_client()
|
||||||
v1client.Client.json_request('GET',
|
v1client.Client.json_request(
|
||||||
'/stacks?limit=20').AndRaise(exc.Unauthorized)
|
'GET', '/stacks?limit=20').AndRaise(exc.Unauthorized)
|
||||||
|
|
||||||
m.ReplayAll()
|
m.ReplayAll()
|
||||||
_old_env, os.environ = os.environ, {
|
_old_env, os.environ = os.environ, {
|
||||||
@@ -108,7 +108,8 @@ class ShellValidationTest(TestCase):
|
|||||||
'OS_TENANT_NAME': 'tenant_name',
|
'OS_TENANT_NAME': 'tenant_name',
|
||||||
'OS_AUTH_URL': 'http://no.where',
|
'OS_AUTH_URL': 'http://no.where',
|
||||||
}
|
}
|
||||||
self.shell_error('create teststack '
|
self.shell_error(
|
||||||
|
'create teststack '
|
||||||
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
||||||
'DBPassword=verybadpassword;KeyName=heat_key;'
|
'DBPassword=verybadpassword;KeyName=heat_key;'
|
||||||
'LinuxDistribution=F17"',
|
'LinuxDistribution=F17"',
|
||||||
@@ -231,18 +232,18 @@ class ShellTest(TestCase):
|
|||||||
def test_describe(self):
|
def test_describe(self):
|
||||||
fakes.script_keystone_client()
|
fakes.script_keystone_client()
|
||||||
resp_dict = {"stack": {
|
resp_dict = {"stack": {
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"stack_name": "teststack",
|
"stack_name": "teststack",
|
||||||
"stack_status": 'CREATE_COMPLETE',
|
"stack_status": 'CREATE_COMPLETE',
|
||||||
"creation_time": "2012-10-25T01:58:47Z"
|
"creation_time": "2012-10-25T01:58:47Z"
|
||||||
}
|
}}
|
||||||
}
|
resp = fakes.FakeHTTPResponse(
|
||||||
resp = fakes.FakeHTTPResponse(200,
|
200,
|
||||||
'OK',
|
'OK',
|
||||||
{'content-type': 'application/json'},
|
{'content-type': 'application/json'},
|
||||||
json.dumps(resp_dict))
|
json.dumps(resp_dict))
|
||||||
v1client.Client.json_request('GET',
|
v1client.Client.json_request(
|
||||||
'/stacks/teststack/1').AndReturn((resp, resp_dict))
|
'GET', '/stacks/teststack/1').AndReturn((resp, resp_dict))
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
@@ -264,18 +265,20 @@ class ShellTest(TestCase):
|
|||||||
|
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
fakes.script_keystone_client()
|
fakes.script_keystone_client()
|
||||||
resp = fakes.FakeHTTPResponse(201,
|
resp = fakes.FakeHTTPResponse(
|
||||||
|
201,
|
||||||
'Created',
|
'Created',
|
||||||
{'location': 'http://no.where/v1/tenant_id/stacks/teststack2/2'},
|
{'location': 'http://no.where/v1/tenant_id/stacks/teststack2/2'},
|
||||||
None)
|
None)
|
||||||
v1client.Client.json_request('POST', '/stacks',
|
v1client.Client.json_request(
|
||||||
body=mox.IgnoreArg()).AndReturn((resp, None))
|
'POST', '/stacks', body=mox.IgnoreArg()).AndReturn((resp, None))
|
||||||
fakes.script_heat_list()
|
fakes.script_heat_list()
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
|
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
|
||||||
create_text = self.shell('create teststack '
|
create_text = self.shell(
|
||||||
|
'create teststack '
|
||||||
'--template-file=%s '
|
'--template-file=%s '
|
||||||
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
||||||
'DBPassword=verybadpassword;KeyName=heat_key;'
|
'DBPassword=verybadpassword;KeyName=heat_key;'
|
||||||
@@ -296,17 +299,19 @@ class ShellTest(TestCase):
|
|||||||
def test_create_url(self):
|
def test_create_url(self):
|
||||||
|
|
||||||
fakes.script_keystone_client()
|
fakes.script_keystone_client()
|
||||||
resp = fakes.FakeHTTPResponse(201,
|
resp = fakes.FakeHTTPResponse(
|
||||||
|
201,
|
||||||
'Created',
|
'Created',
|
||||||
{'location': 'http://no.where/v1/tenant_id/stacks/teststack2/2'},
|
{'location': 'http://no.where/v1/tenant_id/stacks/teststack2/2'},
|
||||||
None)
|
None)
|
||||||
v1client.Client.json_request('POST', '/stacks',
|
v1client.Client.json_request(
|
||||||
body=mox.IgnoreArg()).AndReturn((resp, None))
|
'POST', '/stacks', body=mox.IgnoreArg()).AndReturn((resp, None))
|
||||||
fakes.script_heat_list()
|
fakes.script_heat_list()
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
create_text = self.shell('create teststack '
|
create_text = self.shell(
|
||||||
|
'create teststack '
|
||||||
'--template-url=http://no.where/minimal.template '
|
'--template-url=http://no.where/minimal.template '
|
||||||
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
||||||
'DBPassword=verybadpassword;KeyName=heat_key;'
|
'DBPassword=verybadpassword;KeyName=heat_key;'
|
||||||
@@ -328,22 +333,25 @@ class ShellTest(TestCase):
|
|||||||
fakes.script_keystone_client()
|
fakes.script_keystone_client()
|
||||||
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
|
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
|
||||||
template_data = open(template_file).read()
|
template_data = open(template_file).read()
|
||||||
v1client.Client.raw_request('GET',
|
v1client.Client.raw_request(
|
||||||
'http://no.where/container/minimal.template',
|
'GET',
|
||||||
).AndReturn(template_data)
|
'http://no.where/container/minimal.template',
|
||||||
|
).AndReturn(template_data)
|
||||||
|
|
||||||
resp = fakes.FakeHTTPResponse(201,
|
resp = fakes.FakeHTTPResponse(
|
||||||
|
201,
|
||||||
'Created',
|
'Created',
|
||||||
{'location': 'http://no.where/v1/tenant_id/stacks/teststack2/2'},
|
{'location': 'http://no.where/v1/tenant_id/stacks/teststack2/2'},
|
||||||
None)
|
None)
|
||||||
v1client.Client.json_request('POST', '/stacks',
|
v1client.Client.json_request(
|
||||||
body=mox.IgnoreArg()).AndReturn((resp, None))
|
'POST', '/stacks', body=mox.IgnoreArg()).AndReturn((resp, None))
|
||||||
|
|
||||||
fakes.script_heat_list()
|
fakes.script_heat_list()
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
create_text = self.shell('create teststack2 '
|
create_text = self.shell(
|
||||||
|
'create teststack2 '
|
||||||
'--template-object=http://no.where/container/minimal.template '
|
'--template-object=http://no.where/container/minimal.template '
|
||||||
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
||||||
'DBPassword=verybadpassword;KeyName=heat_key;'
|
'DBPassword=verybadpassword;KeyName=heat_key;'
|
||||||
@@ -362,18 +370,21 @@ class ShellTest(TestCase):
|
|||||||
|
|
||||||
def test_update(self):
|
def test_update(self):
|
||||||
fakes.script_keystone_client()
|
fakes.script_keystone_client()
|
||||||
resp = fakes.FakeHTTPResponse(202,
|
resp = fakes.FakeHTTPResponse(
|
||||||
|
202,
|
||||||
'Accepted',
|
'Accepted',
|
||||||
{},
|
{},
|
||||||
'The request is accepted for processing.')
|
'The request is accepted for processing.')
|
||||||
v1client.Client.json_request('PUT', '/stacks/teststack2/2',
|
v1client.Client.json_request(
|
||||||
body=mox.IgnoreArg()).AndReturn((resp, None))
|
'PUT', '/stacks/teststack2/2',
|
||||||
|
body=mox.IgnoreArg()).AndReturn((resp, None))
|
||||||
fakes.script_heat_list()
|
fakes.script_heat_list()
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
|
template_file = os.path.join(TEST_VAR_DIR, 'minimal.template')
|
||||||
create_text = self.shell('update teststack2/2 '
|
create_text = self.shell(
|
||||||
|
'update teststack2/2 '
|
||||||
'--template-file=%s '
|
'--template-file=%s '
|
||||||
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
'--parameters="InstanceType=m1.large;DBUsername=wp;'
|
||||||
'DBPassword=verybadpassword;KeyName=heat_key;'
|
'DBPassword=verybadpassword;KeyName=heat_key;'
|
||||||
@@ -392,12 +403,14 @@ class ShellTest(TestCase):
|
|||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
fakes.script_keystone_client()
|
fakes.script_keystone_client()
|
||||||
resp = fakes.FakeHTTPResponse(204,
|
resp = fakes.FakeHTTPResponse(
|
||||||
|
204,
|
||||||
'No Content',
|
'No Content',
|
||||||
{},
|
{},
|
||||||
None)
|
None)
|
||||||
v1client.Client.raw_request('DELETE', '/stacks/teststack2/2',
|
v1client.Client.raw_request(
|
||||||
).AndReturn((resp, None))
|
'DELETE', '/stacks/teststack2/2',
|
||||||
|
).AndReturn((resp, None))
|
||||||
fakes.script_heat_list()
|
fakes.script_heat_list()
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
@@ -19,9 +19,10 @@ from heatclient.common import utils
|
|||||||
class shellTest(unittest.TestCase):
|
class shellTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_format_parameters(self):
|
def test_format_parameters(self):
|
||||||
p = utils.format_parameters('InstanceType=m1.large;DBUsername=wp;'
|
p = utils.format_parameters(
|
||||||
'DBPassword=verybadpassword;KeyName=heat_key;'
|
'InstanceType=m1.large;DBUsername=wp;'
|
||||||
'LinuxDistribution=F17')
|
'DBPassword=verybadpassword;KeyName=heat_key;'
|
||||||
|
'LinuxDistribution=F17')
|
||||||
self.assertEqual({'InstanceType': 'm1.large',
|
self.assertEqual({'InstanceType': 'm1.large',
|
||||||
'DBUsername': 'wp',
|
'DBUsername': 'wp',
|
||||||
'DBPassword': 'verybadpassword',
|
'DBPassword': 'verybadpassword',
|
||||||
|
Reference in New Issue
Block a user