| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
import testtools |
| 17 |
|
| 18 |
from glanceclient import client |
| 19 |
from glanceclient import v1 |
| 20 |
from glanceclient import v2 |
| 21 |
|
| 22 |
|
| 23 |
class ClientTest(testtools.TestCase): |
| 24 |
|
| 25 |
def test_no_endpoint_error(self): |
| 26 |
self.assertRaises(ValueError, client.Client, None) |
| 27 |
|
| 28 |
def test_endpoint(self): |
| 29 |
gc = client.Client(1, "http://example.com") |
| 30 |
self.assertEqual("http://example.com", gc.http_client.endpoint) |
| 31 |
self.assertIsInstance(gc, v1.client.Client) |
| 32 |
|
| 33 |
def test_versioned_endpoint(self): |
| 34 |
gc = client.Client(1, "http://example.com/v2") |
| 35 |
self.assertEqual("http://example.com", gc.http_client.endpoint) |
| 36 |
self.assertIsInstance(gc, v1.client.Client) |
| 37 |
|
| 38 |
def test_versioned_endpoint_no_version(self): |
| 39 |
gc = client.Client(endpoint="http://example.com/v2") |
| 40 |
self.assertEqual("http://example.com", gc.http_client.endpoint) |
| 41 |
self.assertIsInstance(gc, v2.client.Client) |
| 42 |
|
| 43 |
def test_versioned_endpoint_with_minor_revision(self): |
| 44 |
gc = client.Client(2.2, "http://example.com/v2.1") |
| 45 |
self.assertEqual("http://example.com", gc.http_client.endpoint) |
| 46 |
self.assertIsInstance(gc, v2.client.Client) |
| 47 |
|
| 48 |
def test_endpoint_with_version_hostname(self): |
| 49 |
gc = client.Client(2, "http://v1.example.com") |
| 50 |
self.assertEqual("http://v1.example.com", gc.http_client.endpoint) |
| 51 |
self.assertIsInstance(gc, v2.client.Client) |
| 52 |
|
| 53 |
def test_versioned_endpoint_with_version_hostname_v2(self): |
| 54 |
gc = client.Client(endpoint="http://v1.example.com/v2") |
| 55 |
self.assertEqual("http://v1.example.com", gc.http_client.endpoint) |
| 56 |
self.assertIsInstance(gc, v2.client.Client) |
| 57 |
|
| 58 |
def test_versioned_endpoint_with_version_hostname_v1(self): |
| 59 |
gc = client.Client(endpoint="http://v2.example.com/v1") |
| 60 |
self.assertEqual("http://v2.example.com", gc.http_client.endpoint) |
| 61 |
self.assertIsInstance(gc, v1.client.Client) |
| 62 |
|
| 63 |
def test_versioned_endpoint_with_minor_revision_and_version_hostname(self): |
| 64 |
gc = client.Client(endpoint="http://v1.example.com/v2.1") |
| 65 |
self.assertEqual("http://v1.example.com", gc.http_client.endpoint) |
| 66 |
self.assertIsInstance(gc, v2.client.Client) |