| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
import re |
| 14 |
|
| 15 |
from tempest.lib import exceptions |
| 16 |
|
| 17 |
from glanceclient.tests.functional import base |
| 18 |
|
| 19 |
|
| 20 |
class SimpleReadOnlyGlanceClientTest(base.ClientTestBase): |
| 21 |
|
| 22 |
"""Read only functional python-glanceclient tests. |
| 23 |
|
| 24 |
This only exercises client commands that are read only. |
| 25 |
""" |
| 26 |
|
| 27 |
def test_list_v1(self): |
| 28 |
out = self.glance('--os-image-api-version 1 image-list') |
| 29 |
endpoints = self.parser.listing(out) |
| 30 |
self.assertTableStruct(endpoints, [ |
| 31 |
'ID', 'Name', 'Disk Format', 'Container Format', |
| 32 |
'Size', 'Status']) |
| 33 |
|
| 34 |
def test_fake_action(self): |
| 35 |
self.assertRaises(exceptions.CommandFailed, |
| 36 |
self.glance, |
| 37 |
'this-does-not-exist') |
| 38 |
|
| 39 |
def test_member_list_v1(self): |
| 40 |
tenant_name = '--tenant-id %s' % self.creds['project_name'] |
| 41 |
out = self.glance('--os-image-api-version 1 member-list', |
| 42 |
params=tenant_name) |
| 43 |
endpoints = self.parser.listing(out) |
| 44 |
self.assertTableStruct(endpoints, |
| 45 |
['Image ID', 'Member ID', 'Can Share']) |
| 46 |
|
| 47 |
def test_help(self): |
| 48 |
help_text = self.glance('--os-image-api-version 1 help') |
| 49 |
lines = help_text.split('\n') |
| 50 |
self.assertFirstLineStartsWith(lines, 'usage: glance') |
| 51 |
|
| 52 |
commands = [] |
| 53 |
cmds_start = lines.index('Positional arguments:') |
| 54 |
try: |
| 55 |
|
| 56 |
|
| 57 |
cmds_end = lines.index('Options:') |
| 58 |
except ValueError: |
| 59 |
|
| 60 |
|
| 61 |
cmds_end = lines.index('Optional arguments:') |
| 62 |
command_pattern = re.compile(r'^ {4}([a-z0-9\-\_]+)') |
| 63 |
for line in lines[cmds_start:cmds_end]: |
| 64 |
match = command_pattern.match(line) |
| 65 |
if match: |
| 66 |
commands.append(match.group(1)) |
| 67 |
commands = set(commands) |
| 68 |
wanted_commands = {'bash-completion', 'help', |
| 69 |
'image-create', 'image-delete', |
| 70 |
'image-download', 'image-list', |
| 71 |
'image-show', 'image-update', |
| 72 |
'member-create', 'member-delete', |
| 73 |
'member-list'} |
| 74 |
self.assertEqual(commands, wanted_commands) |
| 75 |
|
| 76 |
def test_version(self): |
| 77 |
self.glance('', flags='--version') |
| 78 |
|
| 79 |
def test_debug_list(self): |
| 80 |
self.glance('--os-image-api-version 1 image-list', flags='--debug') |