190
190
req = Request.blank('/?limit=20&marker=40')
191
191
self.assertEqual(common.get_pagination_params(req),
192
192
{'marker': 40, 'limit': 20})
195
class MiscFunctionsTest(test.TestCase):
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)
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)
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)
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)
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,
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,
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,
239
def test_get_id_from_href(self):
240
fixture = 'http://www.testsite.com/dir/45'
241
actual = common.get_id_from_href(fixture)
243
self.assertEqual(actual, expected)
245
def test_get_id_from_href_bad_request(self):
246
fixture = 'http://45'
247
self.assertRaises(ValueError,
248
common.get_id_from_href,