cli: add messages to assertTrue
1) Unify assertion of 'usage: service-name' from
{cinder, glance, keystone, neutron} help tests
into assertFirstLineStartsWith method, which provides
more usefull failure message.
2) Add failure message to assertTrue in keystone-catalog
test.
Change-Id: I3abba1d9509bee649aa1675beee4153341b1e170
This commit is contained in:
@@ -134,6 +134,11 @@ class ClientTestBase(tempest.test.BaseTestCase):
|
||||
for field in field_names:
|
||||
self.assertIn(field, item)
|
||||
|
||||
def assertFirstLineStartsWith(self, lines, beginning):
|
||||
self.assertTrue(lines[0].startswith(beginning),
|
||||
msg=('Beginning of first line has invalid content: %s'
|
||||
% lines[:3]))
|
||||
|
||||
|
||||
class CommandFailed(subprocess.CalledProcessError):
|
||||
# adds output attribute for python2.6
|
||||
|
||||
@@ -87,7 +87,7 @@ class SimpleReadOnlyCinderClientTest(tempest.cli.ClientTestBase):
|
||||
def test_admin_help(self):
|
||||
help_text = self.cinder('help')
|
||||
lines = help_text.split('\n')
|
||||
self.assertTrue(lines[0].startswith('usage: cinder'))
|
||||
self.assertFirstLineStartsWith(lines, 'usage: cinder')
|
||||
|
||||
commands = []
|
||||
cmds_start = lines.index('Positional arguments:')
|
||||
|
||||
@@ -48,7 +48,7 @@ class SimpleReadOnlyGlanceClientTest(tempest.cli.ClientTestBase):
|
||||
def test_glance_help(self):
|
||||
help_text = self.glance('help')
|
||||
lines = help_text.split('\n')
|
||||
self.assertTrue(lines[0].startswith('usage: glance'))
|
||||
self.assertFirstLineStartsWith(lines, 'usage: glance')
|
||||
|
||||
commands = []
|
||||
cmds_start = lines.index('Positional arguments:')
|
||||
|
||||
@@ -46,7 +46,9 @@ class SimpleReadOnlyKeystoneClientTest(tempest.cli.ClientTestBase):
|
||||
out = self.keystone('catalog')
|
||||
catalog = self.parser.details_multiple(out, with_label=True)
|
||||
for svc in catalog:
|
||||
self.assertTrue(svc['__label'].startswith('Service:'))
|
||||
self.assertTrue(svc['__label'].startswith('Service:'),
|
||||
msg=('Invalid beginning of service block: %s' %
|
||||
svc['__label']))
|
||||
|
||||
def test_admin_endpoint_list(self):
|
||||
out = self.keystone('endpoint-list')
|
||||
@@ -94,7 +96,7 @@ class SimpleReadOnlyKeystoneClientTest(tempest.cli.ClientTestBase):
|
||||
def test_admin_help(self):
|
||||
help_text = self.keystone('help')
|
||||
lines = help_text.split('\n')
|
||||
self.assertTrue(lines[0].startswith('usage: keystone'))
|
||||
self.assertFirstLineStartsWith(lines, 'usage: keystone')
|
||||
|
||||
commands = []
|
||||
cmds_start = lines.index('Positional arguments:')
|
||||
|
||||
@@ -92,7 +92,7 @@ class SimpleReadOnlyNeutronClientTest(tempest.cli.ClientTestBase):
|
||||
def test_neutron_help(self):
|
||||
help_text = self.neutron('help')
|
||||
lines = help_text.split('\n')
|
||||
self.assertTrue(lines[0].startswith('usage: neutron'))
|
||||
self.assertFirstLineStartsWith(lines, 'usage: neutron')
|
||||
|
||||
commands = []
|
||||
cmds_start = lines.index('Commands for API v2.0:')
|
||||
|
||||
Reference in New Issue
Block a user