@@ -231,6 +231,12 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork):
231231
232232 # The floating ips to list up
233233 floating_ips = network_fakes .FakeFloatingIP .create_floating_ips (count = 3 )
234+ fake_network = network_fakes .FakeNetwork .create_one_network ({
235+ 'id' : 'fake_network_id' ,
236+ })
237+ fake_port = network_fakes .FakePort .create_one_port ({
238+ 'id' : 'fake_port_id' ,
239+ })
234240
235241 columns = (
236242 'ID' ,
@@ -256,6 +262,8 @@ def setUp(self):
256262 super (TestListFloatingIPNetwork , self ).setUp ()
257263
258264 self .network .ips = mock .Mock (return_value = self .floating_ips )
265+ self .network .find_network = mock .Mock (return_value = self .fake_network )
266+ self .network .find_port = mock .Mock (return_value = self .fake_port )
259267
260268 # Get the command object to test
261269 self .cmd = floating_ip .ListFloatingIP (self .app , self .namespace )
@@ -267,7 +275,58 @@ def test_floating_ip_list(self):
267275
268276 columns , data = self .cmd .take_action (parsed_args )
269277
270- self .network .ips .assert_called_once_with (** {})
278+ self .network .ips .assert_called_once_with ()
279+ self .assertEqual (self .columns , columns )
280+ self .assertEqual (self .data , list (data ))
281+
282+ def test_floating_ip_list_network (self ):
283+ arglist = [
284+ '--network' , 'fake_network_id' ,
285+ ]
286+ verifylist = [
287+ ('network' , 'fake_network_id' ),
288+ ]
289+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
290+
291+ columns , data = self .cmd .take_action (parsed_args )
292+
293+ self .network .ips .assert_called_once_with (** {
294+ 'floating_network_id' : 'fake_network_id' ,
295+ })
296+ self .assertEqual (self .columns , columns )
297+ self .assertEqual (self .data , list (data ))
298+
299+ def test_floating_ip_list_port (self ):
300+ arglist = [
301+ '--port' , 'fake_port_id' ,
302+ ]
303+ verifylist = [
304+ ('port' , 'fake_port_id' ),
305+ ]
306+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
307+
308+ columns , data = self .cmd .take_action (parsed_args )
309+
310+ self .network .ips .assert_called_once_with (** {
311+ 'port_id' : 'fake_port_id' ,
312+ })
313+ self .assertEqual (self .columns , columns )
314+ self .assertEqual (self .data , list (data ))
315+
316+ def test_floating_ip_list_fixed_ip_address (self ):
317+ arglist = [
318+ '--fixed-ip-address' , self .floating_ips [0 ].fixed_ip_address ,
319+ ]
320+ verifylist = [
321+ ('fixed_ip_address' , self .floating_ips [0 ].fixed_ip_address ),
322+ ]
323+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
324+
325+ columns , data = self .cmd .take_action (parsed_args )
326+
327+ self .network .ips .assert_called_once_with (** {
328+ 'fixed_ip_address' : self .floating_ips [0 ].fixed_ip_address ,
329+ })
271330 self .assertEqual (self .columns , columns )
272331 self .assertEqual (self .data , list (data ))
273332
0 commit comments