File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,21 @@ def setUp(self):
6060 self .auth = fakes .FakeAuthenticator ()
6161 self .session = session .Session (self .transport , self .auth )
6262
63+ @httpretty .activate
64+ def test_empty_id (self ):
65+ self .stub_url (httpretty .GET , path = [fake_path ], json = fake_body )
66+ obj = FakeResource .new ()
67+ obj .get (self .session )
68+
69+ self .assertEqual (fake_id , obj .id )
70+ self .assertEqual (fake_name , obj ['name' ])
71+ self .assertEqual (fake_attr1 , obj ['attr1' ])
72+ self .assertEqual (fake_attr2 , obj ['attr2' ])
73+
74+ self .assertEqual (fake_name , obj .name )
75+ self .assertEqual (fake_attr1 , obj .first )
76+ self .assertEqual (fake_attr2 , obj .second )
77+
6378 @httpretty .activate
6479 def test_create (self ):
6580 self .stub_url (httpretty .POST , path = fake_path , json = fake_body )
Original file line number Diff line number Diff line change 1+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
2+ # not use this file except in compliance with the License. You may obtain
3+ # a copy of the License at
4+ #
5+ # http://www.apache.org/licenses/LICENSE-2.0
6+ #
7+ # Unless required by applicable law or agreed to in writing, software
8+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+ # License for the specific language governing permissions and limitations
11+ # under the License.
12+
13+ import unittest
14+
15+ from openstack import utils
16+
17+
18+ class Test_urljoin (unittest .TestCase ):
19+
20+ def test_strings (self ):
21+ root = "http://www.example.com"
22+ leaves = "foo" , "bar"
23+
24+ result = utils .urljoin (root , * leaves )
25+ self .assertEqual (result , "http://www.example.com/foo/bar" )
26+
27+ def test_with_none (self ):
28+ root = "http://www.example.com"
29+ leaves = "foo" , None
30+
31+ result = utils .urljoin (root , * leaves )
32+ self .assertEqual (result , "http://www.example.com/foo/" )
Original file line number Diff line number Diff line change @@ -18,4 +18,4 @@ def urljoin(*args):
1818 like /path this should be joined to http://host/path as it is an anchored
1919 link. We generally won't care about that in client.
2020 """
21- return '/' .join (str (a ).strip ('/' ) for a in args )
21+ return '/' .join (str (a or '' ).strip ('/' ) for a in args )
You can’t perform that action at this time.
0 commit comments