@@ -59,6 +59,43 @@ def test_floating_ip_delete(self):
5959 self .assertIsNone (result )
6060
6161
62+ class TestListFloatingIPNetwork (TestFloatingIPNetwork ):
63+
64+ # The floating ips to list up
65+ floating_ips = network_fakes .FakeFloatingIP .create_floating_ips (count = 3 )
66+
67+ columns = ('ID' , 'Floating IP' , 'Fixed IP' , 'Server ID' , 'Pool' )
68+
69+ data = []
70+ for ip in floating_ips :
71+ data .append ((
72+ ip .id ,
73+ ip .ip ,
74+ ip .fixed_ip ,
75+ ip .instance_id ,
76+ ip .pool ,
77+ ))
78+
79+ def setUp (self ):
80+ super (TestListFloatingIPNetwork , self ).setUp ()
81+
82+ self .network .ips = mock .Mock (return_value = self .floating_ips )
83+
84+ # Get the command object to test
85+ self .cmd = floating_ip .ListFloatingIP (self .app , self .namespace )
86+
87+ def test_floating_ip_list (self ):
88+ arglist = []
89+ verifylist = []
90+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
91+
92+ columns , data = self .cmd .take_action (parsed_args )
93+
94+ self .network .ips .assert_called_with (** {})
95+ self .assertEqual (self .columns , columns )
96+ self .assertEqual (self .data , list (data ))
97+
98+
6299# Tests for Nova network
63100#
64101class TestFloatingIPCompute (compute_fakes .TestComputev2 ):
@@ -103,3 +140,42 @@ def test_floating_ip_delete(self):
103140 self .floating_ip .id
104141 )
105142 self .assertIsNone (result )
143+
144+
145+ class TestListFloatingIPCompute (TestFloatingIPCompute ):
146+
147+ # The floating ips to be list up
148+ floating_ips = network_fakes .FakeFloatingIP .create_floating_ips (count = 3 )
149+
150+ columns = ('ID' , 'Floating IP' , 'Fixed IP' , 'Server ID' , 'Pool' )
151+
152+ data = []
153+ for ip in floating_ips :
154+ data .append ((
155+ ip .id ,
156+ ip .ip ,
157+ ip .fixed_ip ,
158+ ip .instance_id ,
159+ ip .pool ,
160+ ))
161+
162+ def setUp (self ):
163+ super (TestListFloatingIPCompute , self ).setUp ()
164+
165+ self .app .client_manager .network_endpoint_enabled = False
166+
167+ self .compute .floating_ips .list .return_value = self .floating_ips
168+
169+ # Get the command object to test
170+ self .cmd = floating_ip .ListFloatingIP (self .app , None )
171+
172+ def test_floating_ip_list (self ):
173+ arglist = []
174+ verifylist = []
175+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
176+
177+ columns , data = self .cmd .take_action (parsed_args )
178+
179+ self .compute .floating_ips .list .assert_called_with ()
180+ self .assertEqual (self .columns , columns )
181+ self .assertEqual (self .data , list (data ))
0 commit comments