1818from openstack import exceptions
1919from openstack import profile
2020from openstack import session
21+ from openstack import utils
2122
2223
2324class TestSession (testtools .TestCase ):
@@ -166,7 +167,8 @@ def test__get_version_match_none(self):
166167 sot ._get_version_match , [], None , "service" , "root" , False )
167168
168169 def test__get_version_match_fuzzy (self ):
169- match = "http://devstack/v2.1/"
170+ match = "http://devstack/v2.1"
171+ root_endpoint = "http://devstack"
170172 versions = [{"id" : "v2.0" ,
171173 "links" : [{"href" : "http://devstack/v2/" ,
172174 "rel" : "self" }]},
@@ -178,11 +180,12 @@ def test__get_version_match_fuzzy(self):
178180 # Look for a v2 match, which we internally denote as a minor
179181 # version of -1 so we can find the highest matching minor.
180182 rv = sot ._get_version_match (versions , session .Version (2 , - 1 ),
181- "service" , "root" , False )
183+ "service" , root_endpoint , False )
182184 self .assertEqual (rv , match )
183185
184186 def test__get_version_match_exact (self ):
185- match = "http://devstack/v2/"
187+ match = "http://devstack/v2"
188+ root_endpoint = "http://devstack"
186189 versions = [{"id" : "v2.0" ,
187190 "links" : [{"href" : match ,
188191 "rel" : "self" }]},
@@ -192,12 +195,12 @@ def test__get_version_match_exact(self):
192195
193196 sot = session .Session (None )
194197 rv = sot ._get_version_match (versions , session .Version (2 , 0 ),
195- "service" , "root" , False )
198+ "service" , root_endpoint , False )
196199 self .assertEqual (rv , match )
197200
198201 def test__get_version_match_fragment (self ):
199202 root = "http://cloud.net"
200- match = "/v2/ "
203+ match = "/v2"
201204 versions = [{"id" : "v2.0" , "links" : [{"href" : match , "rel" : "self" }]}]
202205
203206 sot = session .Session (None )
@@ -206,15 +209,17 @@ def test__get_version_match_fragment(self):
206209 self .assertEqual (rv , root + match )
207210
208211 def test__get_version_match_project_id (self ):
209- match = "http://devstack/v2/"
212+ match = "http://devstack/v2"
213+ root_endpoint = "http://devstack"
210214 project_id = "asdf123"
211215 versions = [{"id" : "v2.0" , "links" : [{"href" : match , "rel" : "self" }]}]
212216
213217 sot = session .Session (None )
214218 sot .get_project_id = mock .Mock (return_value = project_id )
215219 rv = sot ._get_version_match (versions , session .Version (2 , 0 ),
216- "service" , "root" , True )
217- self .assertEqual (rv , match + project_id )
220+ "service" , root_endpoint , True )
221+ match_endpoint = utils .urljoin (match , project_id )
222+ self .assertEqual (rv , match_endpoint )
218223
219224 def test_get_endpoint_cached (self ):
220225 sot = session .Session (None )
0 commit comments