rds2 modify_db_instance, small code tidy ups
This commit is contained in:
		
							parent
							
								
									4b838f6114
								
							
						
					
					
						commit
						242e29a7c1
					
				@ -88,12 +88,14 @@ class Database(object):
 | 
				
			|||||||
    def address(self):
 | 
					    def address(self):
 | 
				
			||||||
        return "{0}.aaaaaaaaaa.{1}.rds.amazonaws.com".format(self.db_instance_identifier, self.region)
 | 
					        return "{0}.aaaaaaaaaa.{1}.rds.amazonaws.com".format(self.db_instance_identifier, self.region)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # TODO: confirm how this should represent in the RESULT JSON
 | 
				
			||||||
    def add_replica(self, replica):
 | 
					    def add_replica(self, replica):
 | 
				
			||||||
        self.replicas.append(replica.db_instance_identifier)
 | 
					        self.replicas.append(replica.db_instance_identifier)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def remove_replica(self, replica):
 | 
					    def remove_replica(self, replica):
 | 
				
			||||||
        self.replicas.remove(replica.db_instance_identifier)
 | 
					        self.replicas.remove(replica.db_instance_identifier)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # TODO: confirm how this should represent in the RESULT JSON
 | 
				
			||||||
    def set_as_replica(self):
 | 
					    def set_as_replica(self):
 | 
				
			||||||
        self.is_replica = True
 | 
					        self.is_replica = True
 | 
				
			||||||
        self.replicas = []
 | 
					        self.replicas = []
 | 
				
			||||||
@ -223,7 +225,11 @@ class Database(object):
 | 
				
			|||||||
        "Endpoint": null,
 | 
					        "Endpoint": null,
 | 
				
			||||||
        "InstanceCreateTime": null,
 | 
					        "InstanceCreateTime": null,
 | 
				
			||||||
        "Iops": null,
 | 
					        "Iops": null,
 | 
				
			||||||
        "ReadReplicaDBInstanceIdentifiers": [],
 | 
					        "ReadReplicaDBInstanceIdentifiers": [{%- for replica in database.replicas -%}
 | 
				
			||||||
 | 
					            {%- if not loop.first -%},{%- endif -%}
 | 
				
			||||||
 | 
					            "{{ replica }}"
 | 
				
			||||||
 | 
					        {%- endfor -%}
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
        "ReadReplicaSourceDBInstanceIdentifier": null,
 | 
					        "ReadReplicaSourceDBInstanceIdentifier": null,
 | 
				
			||||||
        "SecondaryAvailabilityZone": null,
 | 
					        "SecondaryAvailabilityZone": null,
 | 
				
			||||||
        "StatusInfos": null,
 | 
					        "StatusInfos": null,
 | 
				
			||||||
 | 
				
			|||||||
@ -90,16 +90,20 @@ class RDS2Response(BaseResponse):
 | 
				
			|||||||
        template = self.response_template(DESCRIBE_DATABASES_TEMPLATE)
 | 
					        template = self.response_template(DESCRIBE_DATABASES_TEMPLATE)
 | 
				
			||||||
        return template.render(databases=databases)
 | 
					        return template.render(databases=databases)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # TODO: Update function to new method
 | 
					 | 
				
			||||||
    def modify_dbinstance(self):
 | 
					    def modify_dbinstance(self):
 | 
				
			||||||
 | 
					        return self.modify_db_instance()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def modify_db_instance(self):
 | 
				
			||||||
        db_instance_identifier = self._get_param('DBInstanceIdentifier')
 | 
					        db_instance_identifier = self._get_param('DBInstanceIdentifier')
 | 
				
			||||||
        db_kwargs = self._get_db_kwargs()
 | 
					        db_kwargs = self._get_db_kwargs()
 | 
				
			||||||
        database = self.backend.modify_database(db_instance_identifier, db_kwargs)
 | 
					        database = self.backend.modify_database(db_instance_identifier, db_kwargs)
 | 
				
			||||||
        template = self.response_template(MODIFY_DATABASE_TEMPLATE)
 | 
					        template = self.response_template(MODIFY_DATABASE_TEMPLATE)
 | 
				
			||||||
        return template.render(database=database)
 | 
					        return template.render(database=database)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # TODO: Update function to new method
 | 
					 | 
				
			||||||
    def delete_dbinstance(self):
 | 
					    def delete_dbinstance(self):
 | 
				
			||||||
 | 
					        return self.delete_db_instance()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def delete_db_instance(self):
 | 
				
			||||||
        db_instance_identifier = self._get_param('DBInstanceIdentifier')
 | 
					        db_instance_identifier = self._get_param('DBInstanceIdentifier')
 | 
				
			||||||
        database = self.backend.delete_database(db_instance_identifier)
 | 
					        database = self.backend.delete_database(db_instance_identifier)
 | 
				
			||||||
        template = self.response_template(DELETE_DATABASE_TEMPLATE)
 | 
					        template = self.response_template(DELETE_DATABASE_TEMPLATE)
 | 
				
			||||||
@ -222,14 +226,14 @@ CREATE_DATABASE_TEMPLATE = """{
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}"""
 | 
					}"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CREATE_DATABASE_REPLICA_TEMPLATE = """<CreateDBInstanceReadReplicaResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
 | 
					CREATE_DATABASE_REPLICA_TEMPLATE = """{
 | 
				
			||||||
  <CreateDBInstanceReadReplicaResult>
 | 
					  "CreateDBInstanceResponse": {
 | 
				
			||||||
    {{ database.to_xml() }}
 | 
					    "CreateDBInstanceResult": {
 | 
				
			||||||
  </CreateDBInstanceReadReplicaResult>
 | 
					      {{ database.to_json() }}
 | 
				
			||||||
  <ResponseMetadata>
 | 
					    },
 | 
				
			||||||
    <RequestId>ba8dedf0-bb9a-11d3-855b-576787000e19</RequestId>
 | 
					    "ResponseMetadata": { "RequestId": "523e3218-afc7-11c3-90f5-f90431260ab4" }
 | 
				
			||||||
  </ResponseMetadata>
 | 
					  }
 | 
				
			||||||
</CreateDBInstanceReadReplicaResponse>"""
 | 
					}"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DESCRIBE_DATABASES_TEMPLATE = """{
 | 
					DESCRIBE_DATABASES_TEMPLATE = """{
 | 
				
			||||||
  "DescribeDBInstanceResponse": {
 | 
					  "DescribeDBInstanceResponse": {
 | 
				
			||||||
@ -243,23 +247,24 @@ DESCRIBE_DATABASES_TEMPLATE = """{
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}"""
 | 
					}"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MODIFY_DATABASE_TEMPLATE = """<ModifyDBInstanceResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
 | 
					MODIFY_DATABASE_TEMPLATE = """{"ModifyDBInstanceResponse": {
 | 
				
			||||||
  <ModifyDBInstanceResult>
 | 
					    "ModifyDBInstanceResult": {
 | 
				
			||||||
    {{ database.to_xml() }}
 | 
					      {{ database.to_json() }},
 | 
				
			||||||
  </ModifyDBInstanceResult>
 | 
					      "ResponseMetadata": {
 | 
				
			||||||
  <ResponseMetadata>
 | 
					        "RequestId": "bb58476c-a1a8-11e4-99cf-55e92d4bbada"
 | 
				
			||||||
    <RequestId>f643f1ac-bbfe-11d3-f4c6-37db295f7674</RequestId>
 | 
					      }
 | 
				
			||||||
  </ResponseMetadata>
 | 
					    }
 | 
				
			||||||
</ModifyDBInstanceResponse>"""
 | 
					  }
 | 
				
			||||||
 | 
					}"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DELETE_DATABASE_TEMPLATE = """<DeleteDBInstanceResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
 | 
					# TODO: update delete DB TEMPLATE
 | 
				
			||||||
  <DeleteDBInstanceResult>
 | 
					DELETE_DATABASE_TEMPLATE = """{
 | 
				
			||||||
    {{ database.to_xml() }}
 | 
					  "DeleteDBInstanceResponse": {
 | 
				
			||||||
  </DeleteDBInstanceResult>
 | 
					    "DeleteDBInstanceResult": {
 | 
				
			||||||
  <ResponseMetadata>
 | 
					    },
 | 
				
			||||||
    <RequestId>7369556f-b70d-11c3-faca-6ba18376ea1b</RequestId>
 | 
					    "ResponseMetadata": { "RequestId": "523e3218-afc7-11c3-90f5-f90431260ab4" }
 | 
				
			||||||
  </ResponseMetadata>
 | 
					  }
 | 
				
			||||||
</DeleteDBInstanceResponse>"""
 | 
					}"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CREATE_SECURITY_GROUP_TEMPLATE = """<CreateDBSecurityGroupResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
 | 
					CREATE_SECURITY_GROUP_TEMPLATE = """<CreateDBSecurityGroupResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
 | 
				
			||||||
  <CreateDBSecurityGroupResult>
 | 
					  <CreateDBSecurityGroupResult>
 | 
				
			||||||
 | 
				
			|||||||
@ -58,12 +58,53 @@ def test_get_databases():
 | 
				
			|||||||
    instances['DescribeDBInstanceResponse']['DescribeDBInstanceResult'][0]['DBInstance']['DBInstanceIdentifier'].should.equal("db-master-1")
 | 
					    instances['DescribeDBInstanceResponse']['DescribeDBInstanceResult'][0]['DBInstance']['DBInstanceIdentifier'].should.equal("db-master-1")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_describe_non_existant_database():
 | 
					def test_describe_non_existant_database():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
    conn.describe_db_instances.when.called_with("not-a-db").should.throw(BotoServerError)
 | 
					    conn.describe_db_instances.when.called_with("not-a-db").should.throw(BotoServerError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
 | 
					@mock_rds2
 | 
				
			||||||
 | 
					def test_modify_db_instance():
 | 
				
			||||||
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
 | 
					    database = conn.create_db_instance(db_instance_identifier='db-master-1',
 | 
				
			||||||
 | 
					                                       allocated_storage=10,
 | 
				
			||||||
 | 
					                                       engine='postgres',
 | 
				
			||||||
 | 
					                                       db_instance_class='db.m1.small',
 | 
				
			||||||
 | 
					                                       master_username='root',
 | 
				
			||||||
 | 
					                                       master_user_password='hunter2',
 | 
				
			||||||
 | 
					                                       db_security_groups=["my_sg"])
 | 
				
			||||||
 | 
					    instances = conn.describe_db_instances('db-master-1')
 | 
				
			||||||
 | 
					    instances['DescribeDBInstanceResponse']['DescribeDBInstanceResult'][0]['DBInstance']['AllocatedStorage'].should.equal('10')
 | 
				
			||||||
 | 
					    conn.modify_db_instance(db_instance_identifier='db-master-1', allocated_storage=20, apply_immediately=True)
 | 
				
			||||||
 | 
					    instances = conn.describe_db_instances('db-master-1')
 | 
				
			||||||
 | 
					    instances['DescribeDBInstanceResponse']['DescribeDBInstanceResult'][0]['DBInstance']['AllocatedStorage'].should.equal('20')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
 | 
					@mock_rds2
 | 
				
			||||||
 | 
					def test_delete_database():
 | 
				
			||||||
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
 | 
					    instances = conn.describe_db_instances()
 | 
				
			||||||
 | 
					    list(instances['DescribeDBInstanceResponse']['DescribeDBInstanceResult']).should.have.length_of(0)
 | 
				
			||||||
 | 
					    conn.create_db_instance(db_instance_identifier='db-master-1',
 | 
				
			||||||
 | 
					                            allocated_storage=10,
 | 
				
			||||||
 | 
					                            engine='postgres',
 | 
				
			||||||
 | 
					                            db_instance_class='db.m1.small',
 | 
				
			||||||
 | 
					                            master_username='root',
 | 
				
			||||||
 | 
					                            master_user_password='hunter2',
 | 
				
			||||||
 | 
					                            db_security_groups=["my_sg"])
 | 
				
			||||||
 | 
					    instances = conn.describe_db_instances()
 | 
				
			||||||
 | 
					    list(instances['DescribeDBInstanceResponse']['DescribeDBInstanceResult']).should.have.length_of(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    conn.delete_db_instance("db-master-1")
 | 
				
			||||||
 | 
					    instances = conn.describe_db_instances()
 | 
				
			||||||
 | 
					    list(instances['DescribeDBInstanceResponse']['DescribeDBInstanceResult']).should.have.length_of(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_create_option_group():
 | 
					def test_create_option_group():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
@ -74,24 +115,28 @@ def test_create_option_group():
 | 
				
			|||||||
    option_group['CreateOptionGroupResponse']['CreateOptionGroupResult']['OptionGroup']['MajorEngineVersion'].should.equal('5.6')
 | 
					    option_group['CreateOptionGroupResponse']['CreateOptionGroupResult']['OptionGroup']['MajorEngineVersion'].should.equal('5.6')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_create_option_group_bad_engine_name():
 | 
					def test_create_option_group_bad_engine_name():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
    conn.create_option_group.when.called_with('test', 'invalid_engine', '5.6', 'test invalid engine').should.throw(BotoServerError)
 | 
					    conn.create_option_group.when.called_with('test', 'invalid_engine', '5.6', 'test invalid engine').should.throw(BotoServerError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_create_option_group_bad_engine_major_version():
 | 
					def test_create_option_group_bad_engine_major_version():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
    conn.create_option_group.when.called_with('test', 'mysql', '6.6.6', '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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_create_option_group_empty_description():
 | 
					def test_create_option_group_empty_description():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
    conn.create_option_group.when.called_with('test', 'mysql', '5.6', '').should.throw(BotoServerError)
 | 
					    conn.create_option_group.when.called_with('test', 'mysql', '5.6', '').should.throw(BotoServerError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_create_option_group_duplicate():
 | 
					def test_create_option_group_duplicate():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
@ -99,6 +144,7 @@ def test_create_option_group_duplicate():
 | 
				
			|||||||
    conn.create_option_group.when.called_with('test', 'mysql', '5.6', 'foo').should.throw(BotoServerError)
 | 
					    conn.create_option_group.when.called_with('test', 'mysql', '5.6', 'foo').should.throw(BotoServerError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_describe_option_group():
 | 
					def test_describe_option_group():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
@ -107,12 +153,14 @@ def test_describe_option_group():
 | 
				
			|||||||
    option_groups['DescribeOptionGroupsResponse']['DescribeOptionGroupsResult']['OptionGroupsList'][0]['OptionGroupName'].should.equal('test')
 | 
					    option_groups['DescribeOptionGroupsResponse']['DescribeOptionGroupsResult']['OptionGroupsList'][0]['OptionGroupName'].should.equal('test')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_describe_non_existant_option_group():
 | 
					def test_describe_non_existant_option_group():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
    conn.describe_option_groups.when.called_with("not-a-option-group").should.throw(BotoServerError)
 | 
					    conn.describe_option_groups.when.called_with("not-a-option-group").should.throw(BotoServerError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_delete_option_group():
 | 
					def test_delete_option_group():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
@ -123,6 +171,7 @@ def test_delete_option_group():
 | 
				
			|||||||
    conn.describe_option_groups.when.called_with('test').should.throw(BotoServerError)
 | 
					    conn.describe_option_groups.when.called_with('test').should.throw(BotoServerError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_delete_non_existant_option_group():
 | 
					def test_delete_non_existant_option_group():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
@ -142,10 +191,12 @@ def test_describe_option_group_options():
 | 
				
			|||||||
    conn.describe_option_group_options.when.called_with('mysql', 'non-existent').should.throw(BotoServerError)
 | 
					    conn.describe_option_group_options.when.called_with('mysql', 'non-existent').should.throw(BotoServerError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_modify_option_group():
 | 
					def test_modify_option_group():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
    conn.create_option_group('test', 'mysql', '5.6', 'test option group')
 | 
					    conn.create_option_group('test', 'mysql', '5.6', 'test option group')
 | 
				
			||||||
 | 
					    # TODO: create option and validate before deleting.
 | 
				
			||||||
    # if Someone can tell me how the hell to use this function
 | 
					    # if Someone can tell me how the hell to use this function
 | 
				
			||||||
    # to add options to an option_group, I can finish coding this.
 | 
					    # to add options to an option_group, I can finish coding this.
 | 
				
			||||||
    result = conn.modify_option_group('test', [], ['MEMCACHED'], True)
 | 
					    result = conn.modify_option_group('test', [], ['MEMCACHED'], True)
 | 
				
			||||||
@ -154,7 +205,7 @@ def test_modify_option_group():
 | 
				
			|||||||
    result['ModifyOptionGroupResponse']['ModifyOptionGroupResult']['OptionGroupName'].should.equal('test')
 | 
					    result['ModifyOptionGroupResponse']['ModifyOptionGroupResult']['OptionGroupName'].should.equal('test')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_modify_option_group_no_options():
 | 
					def test_modify_option_group_no_options():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
@ -162,31 +213,21 @@ def test_modify_option_group_no_options():
 | 
				
			|||||||
    conn.modify_option_group.when.called_with('test').should.throw(BotoServerError)
 | 
					    conn.modify_option_group.when.called_with('test').should.throw(BotoServerError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
@mock_rds2
 | 
					@mock_rds2
 | 
				
			||||||
def test_modify_non_existant_option_group():
 | 
					def test_modify_non_existant_option_group():
 | 
				
			||||||
    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
    conn.modify_option_group.when.called_with('non-existant', [('OptionName', 'Port', 'DBSecurityGroupMemberships', 'VpcSecurityGroupMemberships', 'OptionSettings')]).should.throw(BotoServerError)
 | 
					    conn.modify_option_group.when.called_with('non-existant', [('OptionName', 'Port', 'DBSecurityGroupMemberships', 'VpcSecurityGroupMemberships', 'OptionSettings')]).should.throw(BotoServerError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@disable_on_py3()
 | 
				
			||||||
 | 
					@mock_rds2
 | 
				
			||||||
 | 
					def test_delete_non_existant_database():
 | 
				
			||||||
 | 
					    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
 | 
					    conn.delete_db_instance.when.called_with("not-a-db").should.throw(BotoServerError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#@disable_on_py3()
 | 
					#@disable_on_py3()
 | 
				
			||||||
#@mock_rds2
 | 
					 | 
				
			||||||
#def test_delete_database():
 | 
					 | 
				
			||||||
#    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					 | 
				
			||||||
#    list(conn.get_all_dbinstances()).should.have.length_of(0)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#    conn.create_dbinstance("db-master-1", 10, 'db.m1.small', 'root', 'hunter2')
 | 
					 | 
				
			||||||
#    list(conn.get_all_dbinstances()).should.have.length_of(1)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#    conn.delete_dbinstance("db-master-1")
 | 
					 | 
				
			||||||
#    list(conn.get_all_dbinstances()).should.have.length_of(0)
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#@mock_rds2
 | 
					 | 
				
			||||||
#def test_delete_non_existant_database():
 | 
					 | 
				
			||||||
#    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					 | 
				
			||||||
#    conn.delete_dbinstance.when.called_with("not-a-db").should.throw(BotoServerError)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#@mock_rds2
 | 
					#@mock_rds2
 | 
				
			||||||
#def test_create_database_security_group():
 | 
					#def test_create_database_security_group():
 | 
				
			||||||
#    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					#    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
@ -338,20 +379,30 @@ def test_modify_non_existant_option_group():
 | 
				
			|||||||
#def test_create_database_replica():
 | 
					#def test_create_database_replica():
 | 
				
			||||||
#    conn = boto.rds2.connect_to_region("us-west-2")
 | 
					#    conn = boto.rds2.connect_to_region("us-west-2")
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#    primary = conn.create_dbinstance("db-master-1", 10, 'db.m1.small', 'root', 'hunter2')
 | 
					#    conn.create_db_instance(db_instance_identifier='db-master-1',
 | 
				
			||||||
 | 
					#                            allocated_storage=10,
 | 
				
			||||||
 | 
					#                            engine='postgres',
 | 
				
			||||||
 | 
					#                            db_instance_class='db.m1.small',
 | 
				
			||||||
 | 
					#                            master_username='root',
 | 
				
			||||||
 | 
					#                            master_user_password='hunter2',
 | 
				
			||||||
 | 
					#                            db_security_groups=["my_sg"])
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#    replica = conn.create_dbinstance_read_replica("replica", "db-master-1", "db.m1.small")
 | 
					#    # TODO: confirm the RESULT JSON
 | 
				
			||||||
#    replica.id.should.equal("replica")
 | 
					#    replica = conn.create_db_instance_read_replica("replica", "db-master-1", "db.m1.small")
 | 
				
			||||||
#    replica.instance_class.should.equal("db.m1.small")
 | 
					#    print replica
 | 
				
			||||||
#    status_info = replica.status_infos[0]
 | 
					    #replica.id.should.equal("replica")
 | 
				
			||||||
#    status_info.normal.should.equal(True)
 | 
					    #replica.instance_class.should.equal("db.m1.small")
 | 
				
			||||||
#    status_info.status_type.should.equal('read replication')
 | 
					    #status_info = replica.status_infos[0]
 | 
				
			||||||
#    status_info.status.should.equal('replicating')
 | 
					    #status_info.normal.should.equal(True)
 | 
				
			||||||
#
 | 
					    #status_info.status_type.should.equal('read replication')
 | 
				
			||||||
#    primary = conn.get_all_dbinstances("db-master-1")[0]
 | 
					    #status_info.status.should.equal('replicating')
 | 
				
			||||||
#    primary.read_replica_dbinstance_identifiers[0].should.equal("replica")
 | 
					
 | 
				
			||||||
#
 | 
					    # TODO: formulate checks on read replica status
 | 
				
			||||||
#    conn.delete_dbinstance("replica")
 | 
					#    primary = conn.describe_db_instances("db-master-1")
 | 
				
			||||||
#
 | 
					#    print primary
 | 
				
			||||||
#    primary = conn.get_all_dbinstances("db-master-1")[0]
 | 
					    #primary.read_replica_dbinstance_identifiers[0].should.equal("replica")
 | 
				
			||||||
#    list(primary.read_replica_dbinstance_identifiers).should.have.length_of(0)
 | 
					
 | 
				
			||||||
 | 
					    #conn.delete_dbinstance("replica")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #primary = conn.get_all_dbinstances("db-master-1")[0]
 | 
				
			||||||
 | 
					    #list(primary.read_replica_dbinstance_identifiers).should.have.length_of(0)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user