File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,8 +30,10 @@ def _format_endpoints(eps=None):
3030 for index , ep in enumerate (eps ):
3131 region = eps [index ].get ('region' , '<none>' )
3232 ret += region + '\n '
33- for url in ['publicURL' , 'internalURL' , 'adminURL' ]:
34- ret += " %s: %s\n " % (url , eps [index ][url ])
33+ for endpoint_type in ['publicURL' , 'internalURL' , 'adminURL' ]:
34+ url = eps [index ].get (endpoint_type )
35+ if url :
36+ ret += " %s: %s\n " % (endpoint_type , url )
3537 return ret
3638
3739
Original file line number Diff line number Diff line change @@ -84,6 +84,46 @@ def test_catalog_list(self):
8484 ), )
8585 self .assertEqual (datalist , tuple (data ))
8686
87+ def test_catalog_list_with_endpoint_url (self ):
88+ fake_service = {
89+ 'id' : 'qwertyuiop' ,
90+ 'type' : 'compute' ,
91+ 'name' : 'supernova' ,
92+ 'endpoints' : [
93+ {
94+ 'region' : 'one' ,
95+ 'publicURL' : 'https://public.one.example.com' ,
96+ },
97+ {
98+ 'region' : 'two' ,
99+ 'publicURL' : 'https://public.two.example.com' ,
100+ 'internalURL' : 'https://internal.two.example.com' ,
101+ },
102+ ],
103+ }
104+ self .sc_mock .service_catalog .get_data .return_value = [
105+ fake_service ,
106+ ]
107+
108+ arglist = []
109+ verifylist = []
110+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
111+
112+ # DisplayCommandBase.take_action() returns two tuples
113+ columns , data = self .cmd .take_action (parsed_args )
114+ self .sc_mock .service_catalog .get_data .assert_called_with ()
115+
116+ collist = ('Name' , 'Type' , 'Endpoints' )
117+ self .assertEqual (collist , columns )
118+ datalist = ((
119+ 'supernova' ,
120+ 'compute' ,
121+ 'one\n publicURL: https://public.one.example.com\n '
122+ 'two\n publicURL: https://public.two.example.com\n '
123+ 'internalURL: https://internal.two.example.com\n '
124+ ), )
125+ self .assertEqual (datalist , tuple (data ))
126+
87127
88128class TestCatalogShow (TestCatalog ):
89129
You can’t perform that action at this time.
0 commit comments