Added describe_option_group_options.

This commit is contained in:
Mike Fuller 2015-01-20 07:18:52 +11:00
parent 503d46d36a
commit a43b002c3a
3 changed files with 99 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,7 @@ from __future__ import unicode_literals
from moto.core.responses import BaseResponse
from moto.ec2.models import ec2_backends
from .models import rds2_backends
import json
class RDS2Response(BaseResponse):
@ -178,6 +179,11 @@ class RDS2Response(BaseResponse):
template = self.response_template(DESCRIBE_OPTION_GROUP_TEMPLATE)
return template.render(option_groups=option_groups)
def describe_option_group_options(self):
engine_name = self._get_param('EngineName')
major_engine_version = self._get_param('MajorEngineVersion')
option_group_options = self.backend.describe_option_group_options(engine_name, major_engine_version)
return option_group_options
CREATE_DATABASE_TEMPLATE = """{
"CreateDBInstanceResponse": {
@ -319,3 +325,15 @@ DESCRIBE_OPTION_GROUP_TEMPLATE = \
"ResponseMetadata": {"RequestId": "4caf445d-9fbc-11e4-87ea-a31c60ed2e36"}
}}"""
DESCRIBE_OPTION_GROUP_OPTIONS_TEMPLATE = \
"""{"DescribeOptionGroupOptionsResponse": {
"DescribeOptionGroupOptionsResult": {
"Marker": null,
"OptionGroupOptions": [
{%- for option_group_option in option_group_options -%}
{%- if loop.index != 1 -%},{%- endif -%}
{{ option_group_option.to_json() }}
{%- endfor -%}
]},
"ResponseMetadata": {"RequestId": "457f7bb8-9fbf-11e4-9084-5754f80d5144"}
}}"""

View File

@ -67,37 +67,38 @@ def test_describe_non_existant_database():
@mock_rds2
def test_create_option_group():
conn = boto.rds2.connect_to_region("us-west-2")
option_group = conn.create_option_group('test', 'postgres', '9.3', 'test option group')
option_group = conn.create_option_group('test', 'mysql', '5.6', 'test option group')
option_group['CreateOptionGroupResponse']['CreateOptionGroupResult']['OptionGroup']['OptionGroupName'].should.equal('test')
option_group['CreateOptionGroupResponse']['CreateOptionGroupResult']['OptionGroup']['EngineName'].should.equal('postgres')
option_group['CreateOptionGroupResponse']['CreateOptionGroupResult']['OptionGroup']['EngineName'].should.equal('mysql')
option_group['CreateOptionGroupResponse']['CreateOptionGroupResult']['OptionGroup']['OptionGroupDescription'].should.equal('test option group')
option_group['CreateOptionGroupResponse']['CreateOptionGroupResult']['OptionGroup']['MajorEngineVersion'].should.equal('9.3')
option_group['CreateOptionGroupResponse']['CreateOptionGroupResult']['OptionGroup']['MajorEngineVersion'].should.equal('5.6')
@mock_rds2
def test_create_option_group_bad_engine_name():
conn = boto.rds2.connect_to_region("us-west-2")
conn.create_option_group.when.called_with('test', 'invalid_engine', '9.3', 'test invalid engine').should.throw(BotoServerError)
conn.create_option_group.when.called_with('test', 'invalid_engine', '5.6', 'test invalid engine').should.throw(BotoServerError)
@mock_rds2
def test_create_option_group_bad_engine_major_version():
conn = boto.rds2.connect_to_region("us-west-2")
conn.create_option_group.when.called_with('test', 'postgres', '9.3.a', 'test invalid engine version').should.throw(BotoServerError)
conn.create_option_group.when.called_with('test', 'mysql', '6.6.6', 'test invalid engine version').should.throw(BotoServerError)
@mock_rds2
def test_create_option_group_empty_description():
conn = boto.rds2.connect_to_region("us-west-2")
conn.create_option_group.when.called_with('test', 'postgres', '9.3', '').should.throw(BotoServerError)
conn.create_option_group.when.called_with('test', 'mysql', '5.6', '').should.throw(BotoServerError)
@mock_rds2
def test_describe_option_group():
conn = boto.rds2.connect_to_region("us-west-2")
conn.create_option_group('test', 'postgres', '9.3', 'test option group')
conn.create_option_group('test', 'mysql', '5.6', 'test option group')
option_groups = conn.describe_option_groups('test')
option_groups['DescribeOptionGroupsResponse']['DescribeOptionGroupsResult']['OptionGroupsList'][0]['OptionGroupName'].should.equal('test')
@mock_rds2
def test_describe_non_existant_option_group():
conn = boto.rds2.connect_to_region("us-west-2")
@ -107,7 +108,7 @@ def test_describe_non_existant_option_group():
@mock_rds2
def test_delete_option_group():
conn = boto.rds2.connect_to_region("us-west-2")
conn.create_option_group('test', 'postgres', '9.3', 'test option group')
conn.create_option_group('test', 'mysql', '5.6', 'test option group')
option_groups = conn.describe_option_groups('test')
option_groups['DescribeOptionGroupsResponse']['DescribeOptionGroupsResult']['OptionGroupsList'][0]['OptionGroupName'].should.equal('test')
conn.delete_option_group('test')
@ -120,6 +121,17 @@ def test_delete_non_existant_option_group():
conn.delete_option_group.when.called_with('non-existant').should.throw(BotoServerError)
@mock_rds2
def test_describe_option_group_options():
conn = boto.rds2.connect_to_region("us-west-2")
option_group_options = conn.describe_option_group_options('sqlserver-ee')
len(option_group_options['DescribeOptionGroupOptionsResponse']['DescribeOptionGroupOptionsResult']['OptionGroupOptions']).should.equal(4)
option_group_options = conn.describe_option_group_options('sqlserver-ee', '11.00')
len(option_group_options['DescribeOptionGroupOptionsResponse']['DescribeOptionGroupOptionsResult']['OptionGroupOptions']).should.equal(2)
option_group_options = conn.describe_option_group_options('mysql', '5.6')
len(option_group_options['DescribeOptionGroupOptionsResponse']['DescribeOptionGroupOptionsResult']['OptionGroupOptions']).should.equal(1)
conn.describe_option_group_options.when.called_with('non-existent').should.throw(BotoServerError)
conn.describe_option_group_options.when.called_with('mysql', 'non-existent').should.throw(BotoServerError)
#@disable_on_py3()
#@mock_rds2