1818
1919from openstackclient .network .v2 import floating_ip
2020from openstackclient .tests .unit .compute .v2 import fakes as compute_fakes
21+ from openstackclient .tests .unit .identity .v3 import fakes as identity_fakes_v3
2122from openstackclient .tests .unit .network .v2 import fakes as network_fakes
2223from openstackclient .tests .unit import utils as tests_utils
2324
@@ -31,6 +32,7 @@ def setUp(self):
3132
3233 # Get a shortcut to the network client
3334 self .network = self .app .client_manager .network
35+ self .projects_mock = self .app .client_manager .identity .projects
3436
3537
3638class TestCreateFloatingIPNetwork (TestFloatingIPNetwork ):
@@ -145,6 +147,54 @@ def test_create_all_options(self):
145147 self .assertEqual (self .columns , columns )
146148 self .assertEqual (self .data , data )
147149
150+ def test_floating_ip_create_project (self ):
151+ project = identity_fakes_v3 .FakeProject .create_one_project ()
152+ self .projects_mock .get .return_value = project
153+ arglist = [
154+ '--project' , project .id ,
155+ self .floating_ip .floating_network_id ,
156+ ]
157+ verifylist = [
158+ ('network' , self .floating_ip .floating_network_id ),
159+ ('project' , project .id ),
160+ ]
161+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
162+
163+ columns , data = self .cmd .take_action (parsed_args )
164+
165+ self .network .create_ip .assert_called_once_with (** {
166+ 'floating_network_id' : self .floating_ip .floating_network_id ,
167+ 'tenant_id' : project .id ,
168+ })
169+ self .assertEqual (self .columns , columns )
170+ self .assertEqual (self .data , data )
171+
172+ def test_floating_ip_create_project_domain (self ):
173+ project = identity_fakes_v3 .FakeProject .create_one_project ()
174+ domain = identity_fakes_v3 .FakeDomain .create_one_domain ()
175+ self .projects_mock .get .return_value = project
176+ arglist = [
177+ "--project" , project .name ,
178+ "--project-domain" , domain .name ,
179+ self .floating_ip .floating_network_id ,
180+ ]
181+ verifylist = [
182+ ('network' , self .floating_ip .floating_network_id ),
183+ ('project' , project .name ),
184+ ('project_domain' , domain .name ),
185+ ]
186+
187+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
188+
189+ columns , data = self .cmd .take_action (parsed_args )
190+
191+ self .network .create_ip .assert_called_once_with (** {
192+ 'floating_network_id' : self .floating_ip .floating_network_id ,
193+ 'tenant_id' : project .id ,
194+ })
195+ self .assertEqual (self .columns , columns )
196+ self .assertEqual (self .data , data )
197+
148198
149199class TestDeleteFloatingIPNetwork (TestFloatingIPNetwork ):
150200
0 commit comments