@@ -100,6 +100,64 @@ def test_floating_ip_list(self):
100100 self .assertEqual (self .data , list (data ))
101101
102102
103+ class TestShowFloatingIPNetwork (TestFloatingIPNetwork ):
104+
105+ # The floating ip to display.
106+ floating_ip = network_fakes .FakeFloatingIP .create_one_floating_ip ()
107+
108+ columns = (
109+ 'dns_domain' ,
110+ 'dns_name' ,
111+ 'fixed_ip_address' ,
112+ 'floating_ip_address' ,
113+ 'floating_network_id' ,
114+ 'id' ,
115+ 'port_id' ,
116+ 'project_id' ,
117+ 'router_id' ,
118+ 'status' ,
119+ )
120+
121+ data = (
122+ floating_ip .dns_domain ,
123+ floating_ip .dns_name ,
124+ floating_ip .fixed_ip_address ,
125+ floating_ip .floating_ip_address ,
126+ floating_ip .floating_network_id ,
127+ floating_ip .id ,
128+ floating_ip .port_id ,
129+ floating_ip .tenant_id ,
130+ floating_ip .router_id ,
131+ floating_ip .status ,
132+ )
133+
134+ def setUp (self ):
135+ super (TestShowFloatingIPNetwork , self ).setUp ()
136+
137+ self .network .find_ip = mock .Mock (return_value = self .floating_ip )
138+
139+ # Get the command object to test
140+ self .cmd = floating_ip .ShowFloatingIP (self .app , self .namespace )
141+
142+ def test_floating_ip_show (self ):
143+ arglist = [
144+ self .floating_ip .id ,
145+ ]
146+ verifylist = [
147+ ('floating_ip' , self .floating_ip .id ),
148+ ]
149+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
150+
151+ columns , data = self .cmd .take_action (parsed_args )
152+
153+ self .network .find_ip .assert_called_with (
154+ self .floating_ip .id ,
155+ ignore_missing = False
156+ )
157+ self .assertEqual (self .columns , columns )
158+ self .assertEqual (self .data , data )
159+
160+
103161# Tests for Nova network
104162#
105163class TestFloatingIPCompute (compute_fakes .TestComputev2 ):
@@ -189,3 +247,50 @@ def test_floating_ip_list(self):
189247 self .compute .floating_ips .list .assert_called_with ()
190248 self .assertEqual (self .columns , columns )
191249 self .assertEqual (self .data , list (data ))
250+
251+
252+ class TestShowFloatingIPCompute (TestFloatingIPCompute ):
253+
254+ # The floating ip to display.
255+ floating_ip = compute_fakes .FakeFloatingIP .create_one_floating_ip ()
256+
257+ columns = (
258+ 'fixed_ip' ,
259+ 'id' ,
260+ 'instance_id' ,
261+ 'ip' ,
262+ 'pool' ,
263+ )
264+
265+ data = (
266+ floating_ip .fixed_ip ,
267+ floating_ip .id ,
268+ floating_ip .instance_id ,
269+ floating_ip .ip ,
270+ floating_ip .pool ,
271+ )
272+
273+ def setUp (self ):
274+ super (TestShowFloatingIPCompute , self ).setUp ()
275+
276+ self .app .client_manager .network_endpoint_enabled = False
277+
278+ # Return value of utils.find_resource()
279+ self .compute .floating_ips .get .return_value = self .floating_ip
280+
281+ # Get the command object to test
282+ self .cmd = floating_ip .ShowFloatingIP (self .app , None )
283+
284+ def test_floating_ip_show (self ):
285+ arglist = [
286+ self .floating_ip .id ,
287+ ]
288+ verifylist = [
289+ ('floating_ip' , self .floating_ip .id ),
290+ ]
291+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
292+
293+ columns , data = self .cmd .take_action (parsed_args )
294+
295+ self .assertEqual (self .columns , columns )
296+ self .assertEqual (self .data , data )
0 commit comments