@@ -73,6 +73,67 @@ def test_create(self, mock_connection):
7373 self ._ctx .instance .runtime_properties [OPENSTACK_TYPE_PROPERTY ],
7474 FLAVOR_OPENSTACK_TYPE )
7575
76+ mock_connection ().compute .create_flavor_extra_specs .assert_not_called ()
77+
78+ mock_connection ().compute .flavor_add_tenant_access .assert_not_called ()
79+
80+ def test_create_extra_specs_access (self , mock_connection ):
81+ # Prepare the context for create operation
82+ self ._prepare_context_for_operation (
83+ test_name = 'FlavorTestCaseExtraSpecsAcess' ,
84+ test_properties = {
85+ 'client_config' : self .client_config ,
86+ 'resource_config' : {
87+ 'name' : 'test_flavor' ,
88+ 'ram' : 2048 ,
89+ 'disk' : 8 ,
90+ 'vcpus' : 2 ,
91+ 'is_public' : False
92+ },
93+ 'extra_specs' : {
94+ 'hw:cpu_policy' : 'dedicated' ,
95+ 'hw:cpu_threads_policy' : 'isolate'
96+ },
97+ 'tenants' : ['cfy_test_project' ]
98+ },
99+ ctx_operation_name = 'cloudify.interfaces.lifecycle.create' )
100+
101+ flavor_instance = openstack .compute .v2 .flavor .Flavor (** {
102+ 'id' : 'a95b5509-c122-4c2f-823e-884bb559afe8' ,
103+ 'name' : 'test_flavor' ,
104+ 'links' : '2' ,
105+ 'os-flavor-access:is_public' : False ,
106+ 'ram' : 2048 ,
107+ 'vcpus' : 2 ,
108+ 'disk' : 8
109+ })
110+
111+ mock_connection ().compute .create_flavor = \
112+ mock .MagicMock (return_value = flavor_instance )
113+
114+ mock_connection ().compute .create_flavor_extra_specs = \
115+ mock .Mock ()
116+
117+ mock_connection ().identity .find_project = \
118+ mock .Mock ()
119+
120+ mock_connection ().compute .flavor_add_tenant_access = \
121+ mock .Mock ()
122+
123+ # Call create flavor
124+ flavor .create (openstack_resource = None )
125+
126+ self .assertEqual (self ._ctx .instance .runtime_properties [RESOURCE_ID ],
127+ 'a95b5509-c122-4c2f-823e-884bb559afe8' )
128+
129+ self .assertEqual (
130+ self ._ctx .instance .runtime_properties [OPENSTACK_NAME_PROPERTY ],
131+ 'test_flavor' )
132+
133+ mock_connection ().compute .create_flavor_extra_specs .assert_called ()
134+
135+ mock_connection ().compute .flavor_add_tenant_access .assert_called ()
136+
76137 def test_delete (self , mock_connection ):
77138 # Prepare the context for delete operation
78139 self ._prepare_context_for_operation (
0 commit comments