#NEWLINE# def test_user_pass_all_arguments_and_database_is_created( self ) : #NEWLINE# #INDENT# NUM_INSTANCES = 3 #NEWLINE# databaseinfra_name = 'test_new_database_infra' #NEWLINE# databaseinfra_user = 'dbadmin' #NEWLINE# databaseinfra_pass = '123456' #NEWLINE# databaseinfra_endpoint = '' #NEWLINE# instance_port = 27017 #NEWLINE# instance_dns = 'my_instance_dns{}.com' #NEWLINE# params = { #NEWLINE# #INDENT# 'name' : databaseinfra_name , #NEWLINE# 'user' : databaseinfra_user , #NEWLINE# 'password' : databaseinfra_pass , #NEWLINE# 'engine' : self . engine . pk , #NEWLINE# 'plan' : self . plan . pk , #NEWLINE# 'environment' : self . environment . pk , #NEWLINE# 'capacity' : 1 , #NEWLINE# 'per_database_size_mbytes' : 10 , #NEWLINE# 'instances-TOTAL_FORMS' : NUM_INSTANCES , #NEWLINE# 'instances-INITIAL_FORMS' : 0 , #NEWLINE# 'instances-MAX_NUM_FORMS' : NUM_INSTANCES , #NEWLINE# 'cs_dbinfra_attributes-TOTAL_FORMS' : 2 , #NEWLINE# 'cs_dbinfra_attributes-INITIAL_FORMS' : 0 , #NEWLINE# 'cs_dbinfra_attributes-MAX_NUM_FORMS' : 2 , #NEWLINE# 'cs_dbinfra_offering-TOTAL_FORMS' : 1 , #NEWLINE# 'cs_dbinfra_offering-INITIAL_FORMS' : 0 , #NEWLINE# 'cs_dbinfra_offering-MAX_NUM_FORMS' : 1 , #NEWLINE# #UNINDENT# } #NEWLINE# hosts = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for i in xrange ( NUM_INSTANCES ) : #NEWLINE# #INDENT# host = factory . HostFactory ( ) #NEWLINE# hosts [ host . pk ] = host #NEWLINE# address = ( '10.10.1.%d' % host . pk ) #NEWLINE# instance_dns = instance_dns . format ( host . pk ) #NEWLINE# params [ ( 'instances-%d-id' % i ) ] = ( '' , ) #NEWLINE# params [ ( 'instances-%d-databaseinfra' % i ) ] = ( '' , ) #NEWLINE# params [ ( 'instances-%d-hostname' % i ) ] = ( host . pk , ) #NEWLINE# params [ ( 'instances-%d-dns' % i ) ] = ( instance_dns , ) #NEWLINE# params [ ( 'instances-%d-address' % i ) ] = ( address , ) #NEWLINE# params [ ( 'instances-%d-port' % i ) ] = ( instance_port , ) #NEWLINE# params [ ( 'instances-%d-is_active' % i ) ] = ( True , ) #NEWLINE# params [ ( 'instances-%d-is_arbiter' % i ) ] = ( False , ) #NEWLINE# params [ ( 'instances-%d-instance_type' % i ) ] = ( 2 , ) #NEWLINE# if ( i == ( NUM_INSTANCES - 1 ) ) : #NEWLINE# #INDENT# databaseinfra_endpoint += ( '%s:%s' % ( address , instance_port ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# databaseinfra_endpoint += ( '%s:%s,' % ( address , instance_port ) ) #NEWLINE# #UNINDENT# #UNINDENT# params [ 'endpoint' ] = databaseinfra_endpoint #NEWLINE# params [ 'endpoint_dns' ] = databaseinfra_endpoint #NEWLINE# response = self . client . post ( '/admin/physical/databaseinfra/add/' , params ) #NEWLINE# self . assertEqual ( response . status_code , 302 , response . content ) #NEWLINE# databaseinfra = DatabaseInfra . objects . get ( name = databaseinfra_name ) #NEWLINE# self . assertEqual ( databaseinfra_user , databaseinfra . user ) #NEWLINE# self . assertEqual ( databaseinfra_pass , databaseinfra . password ) #NEWLINE# self . assertEqual ( databaseinfra_endpoint , databaseinfra . endpoint ) #NEWLINE# self . assertEqual ( self . engine , databaseinfra . engine ) #NEWLINE# self . assertEqual ( self . plan , databaseinfra . plan ) #NEWLINE# self . assertEqual ( self . environment , databaseinfra . environment ) #NEWLINE# self . assertEqual ( NUM_INSTANCES , databaseinfra . instances . count ( ) ) #NEWLINE# for instance in databaseinfra . instances . all ( ) : #NEWLINE# #INDENT# host = hosts [ instance . hostname . pk ] #NEWLINE# self . assertEqual ( host , instance . hostname ) #NEWLINE# self . assertEqual ( ( '10.10.1.%d' % host . pk ) , instance . address ) #NEWLINE# self . assertEqual ( instance_port , instance . port )