~heckj/nova/lp798876

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/test_common.py

  • Committer: Joe Heck
  • Date: 2011-07-19 18:30:40 UTC
  • mfrom: (1250.1.33 nova)
  • Revision ID: heckj@mac.com-20110719183040-8uf09a0bqkebthyh
merging in changes from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
190
190
        req = Request.blank('/?limit=20&marker=40')
191
191
        self.assertEqual(common.get_pagination_params(req),
192
192
                         {'marker': 40, 'limit': 20})
 
193
 
 
194
 
 
195
class MiscFunctionsTest(test.TestCase):
 
196
 
 
197
    def test_remove_version_from_href(self):
 
198
        fixture = 'http://www.testsite.com/v1.1/images'
 
199
        expected = 'http://www.testsite.com/images'
 
200
        actual = common.remove_version_from_href(fixture)
 
201
        self.assertEqual(actual, expected)
 
202
 
 
203
    def test_remove_version_from_href_2(self):
 
204
        fixture = 'http://www.testsite.com/v1.1/'
 
205
        expected = 'http://www.testsite.com/'
 
206
        actual = common.remove_version_from_href(fixture)
 
207
        self.assertEqual(actual, expected)
 
208
 
 
209
    def test_remove_version_from_href_3(self):
 
210
        fixture = 'http://www.testsite.com/v10.10'
 
211
        expected = 'http://www.testsite.com'
 
212
        actual = common.remove_version_from_href(fixture)
 
213
        self.assertEqual(actual, expected)
 
214
 
 
215
    def test_remove_version_from_href_4(self):
 
216
        fixture = 'http://www.testsite.com/v1.1/images/v10.5'
 
217
        expected = 'http://www.testsite.com/images/v10.5'
 
218
        actual = common.remove_version_from_href(fixture)
 
219
        self.assertEqual(actual, expected)
 
220
 
 
221
    def test_remove_version_from_href_bad_request(self):
 
222
        fixture = 'http://www.testsite.com/1.1/images'
 
223
        self.assertRaises(ValueError,
 
224
                          common.remove_version_from_href,
 
225
                          fixture)
 
226
 
 
227
    def test_remove_version_from_href_bad_request_2(self):
 
228
        fixture = 'http://www.testsite.com/v/images'
 
229
        self.assertRaises(ValueError,
 
230
                          common.remove_version_from_href,
 
231
                          fixture)
 
232
 
 
233
    def test_remove_version_from_href_bad_request_3(self):
 
234
        fixture = 'http://www.testsite.com/v1.1images'
 
235
        self.assertRaises(ValueError,
 
236
                          common.remove_version_from_href,
 
237
                          fixture)
 
238
 
 
239
    def test_get_id_from_href(self):
 
240
        fixture = 'http://www.testsite.com/dir/45'
 
241
        actual = common.get_id_from_href(fixture)
 
242
        expected = 45
 
243
        self.assertEqual(actual, expected)
 
244
 
 
245
    def test_get_id_from_href_bad_request(self):
 
246
        fixture = 'http://45'
 
247
        self.assertRaises(ValueError,
 
248
                          common.get_id_from_href,
 
249
                          fixture)