Added non existant parameter test + needed error responses

This commit is contained in:
Terry Cain 2017-09-18 21:27:56 +01:00
parent cf7e07b728
commit 783c287e51
No known key found for this signature in database
GPG Key ID: 14D90844E4E9B9F3
2 changed files with 20 additions and 1 deletions

View File

@ -49,7 +49,11 @@ class SimpleSystemManagerResponse(BaseResponse):
result = self.ssm_backend.get_parameter(name, with_decryption)
if result is None:
return '', dict(status=400)
error = {
'__type': 'ParameterNotFound',
'message': 'Parameter {0} not found.'.format(name)
}
return json.dumps(error), dict(status=400)
response = {
'Parameter': {

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
import boto3
import botocore.exceptions
import sure # noqa
from moto import mock_ssm
@ -85,6 +86,20 @@ def test_get_parameter():
response['Parameter']['Type'].should.equal('String')
@mock_ssm
def test_get_nonexistant_parameter():
client = boto3.client('ssm', region_name='us-east-1')
try:
client.get_parameter(
Name='test_noexist',
WithDecryption=False)
raise RuntimeError('Should of failed')
except botocore.exceptions.ClientError as err:
err.operation_name.should.equal('GetParameter')
err.response['Error']['Message'].should.equal('Parameter test_noexist not found.')
@mock_ssm
def test_describe_parameters():
client = boto3.client('ssm', region_name='us-east-1')