<s> import copy <EOL> from sahara . conductor import manager <EOL> from sahara import context <EOL> import sahara . tests . unit . conductor . base as test_base <EOL> from sahara . tests . unit . conductor . manager import test_clusters <EOL> from sahara . tests . unit . conductor . manager import test_templates <EOL> CORRECT_CONF = { <EOL> u'<STR_LIT>' : { u'<STR_LIT>' : u'<STR_LIT>' , u'<STR_LIT>' : u'<STR_LIT>' } , <EOL> u'<STR_LIT>' : { u'<STR_LIT>' : u'<STR_LIT>' } <EOL> } <EOL> class ObjectsFromTemplatesTest ( test_base . ConductorManagerTestCase ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( ObjectsFromTemplatesTest , self ) . __init__ ( <EOL> checks = [ <EOL> lambda : CORRECT_CONF , <EOL> lambda : test_clusters . SAMPLE_CLUSTER , <EOL> lambda : test_templates . SAMPLE_CLT , <EOL> lambda : test_templates . SAMPLE_NGT , <EOL> lambda : manager . CLUSTER_DEFAULTS , <EOL> lambda : manager . NODE_GROUP_DEFAULTS , <EOL> lambda : manager . INSTANCE_DEFAULTS , <EOL> ] , * args , ** kwargs ) <EOL> def test_cluster_create_from_templates ( self ) : <EOL> ctx = context . ctx ( ) <EOL> ng_tmpl = copy . deepcopy ( test_templates . SAMPLE_NGT ) <EOL> ng_tmpl [ '<STR_LIT>' ] = <NUM_LIT:10> <EOL> ng_tmpl [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> ng_tmpl = self . api . node_group_template_create ( ctx , ng_tmpl ) <EOL> cl_tmpl = self . api . cluster_template_create ( ctx , <EOL> test_templates . SAMPLE_CLT ) <EOL> cluster_val = copy . deepcopy ( test_clusters . SAMPLE_CLUSTER ) <EOL> cluster_val [ '<STR_LIT>' ] = cl_tmpl [ '<STR_LIT:id>' ] <EOL> cluster_val [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] = ng_tmpl [ '<STR_LIT:id>' ] <EOL> cluster = self . api . cluster_create ( ctx , cluster_val ) <EOL> self . assertEqual ( CORRECT_CONF , cluster [ '<STR_LIT>' ] ) <EOL> for node_group in cluster [ '<STR_LIT>' ] : <EOL> if node_group [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' ] , node_group [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:10> , node_group [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( CORRECT_CONF , node_group [ '<STR_LIT>' ] ) <EOL> def test_node_group_add_from_template ( self ) : <EOL> ctx = context . ctx ( ) <EOL> sample_copy = copy . deepcopy ( test_clusters . SAMPLE_CLUSTER ) <EOL> cluster = self . api . cluster_create ( ctx , sample_copy ) <EOL> ng_tmpl = copy . deepcopy ( test_templates . SAMPLE_NGT ) <EOL> ng_tmpl [ '<STR_LIT>' ] = <NUM_LIT:10> <EOL> ng_tmpl [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> ng_tmpl = self . api . node_group_template_create ( ctx , ng_tmpl ) <EOL> ng = copy . deepcopy ( test_clusters . SAMPLE_CLUSTER [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> ng [ '<STR_LIT>' ] = ng_tmpl [ '<STR_LIT:id>' ] <EOL> ng [ '<STR_LIT:count>' ] = <NUM_LIT:5> <EOL> ng [ '<STR_LIT:name>' ] = '<STR_LIT>' <EOL> self . api . node_group_add ( ctx , cluster [ '<STR_LIT:id>' ] , ng ) <EOL> cluster = self . api . cluster_get ( ctx , cluster [ '<STR_LIT:id>' ] ) <EOL> for node_group in cluster [ '<STR_LIT>' ] : <EOL> if node_group [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> self . assertEqual ( [ '<STR_LIT>' , '<STR_LIT>' ] , node_group [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:10> , node_group [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( CORRECT_CONF , node_group [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:5> , node_group [ '<STR_LIT:count>' ] ) </s>
