Fixed audit creation bug in CLI
This changeset fixes the issue with the audit creation. Change-Id: Ic1fd34f1f1db0e45e205a2d19b5d3538efe89925 Closes-Bug: #1573686
This commit is contained in:
@@ -123,10 +123,30 @@ class AuditShellTest(utils.BaseTestCase):
|
|||||||
def test_do_audit_create(self):
|
def test_do_audit_create(self):
|
||||||
client_mock = mock.MagicMock()
|
client_mock = mock.MagicMock()
|
||||||
args = mock.MagicMock()
|
args = mock.MagicMock()
|
||||||
|
|
||||||
a_shell.do_audit_create(client_mock, args)
|
a_shell.do_audit_create(client_mock, args)
|
||||||
client_mock.audit.create.assert_called_once_with()
|
client_mock.audit.create.assert_called_once_with()
|
||||||
|
|
||||||
|
def test_do_audit_create_with_audit_template_uuid(self):
|
||||||
|
client_mock = mock.MagicMock()
|
||||||
|
args = mock.MagicMock()
|
||||||
|
args.audit_template_uuid = 'a5194d0e-1702-4663-9234-5ab2cf8dafea'
|
||||||
|
|
||||||
|
a_shell.do_audit_create(client_mock, args)
|
||||||
|
client_mock.audit.create.assert_called_once_with(
|
||||||
|
audit_template_uuid='a5194d0e-1702-4663-9234-5ab2cf8dafea')
|
||||||
|
|
||||||
|
def test_do_audit_create_with_audit_template_name(self):
|
||||||
|
client_mock = mock.MagicMock(
|
||||||
|
audit_template=mock.Mock(
|
||||||
|
get=mock.Mock(return_value=mock.Mock(
|
||||||
|
uuid='a5194d0e-1702-4663-9234-5ab2cf8dafea'))))
|
||||||
|
args = mock.MagicMock()
|
||||||
|
args.audit_template_uuid = 'Test AT name'
|
||||||
|
|
||||||
|
a_shell.do_audit_create(client_mock, args)
|
||||||
|
client_mock.audit.create.assert_called_once_with(
|
||||||
|
audit_template_uuid='a5194d0e-1702-4663-9234-5ab2cf8dafea')
|
||||||
|
|
||||||
def test_do_audit_create_with_deadline(self):
|
def test_do_audit_create_with_deadline(self):
|
||||||
client_mock = mock.MagicMock()
|
client_mock = mock.MagicMock()
|
||||||
args = mock.MagicMock()
|
args = mock.MagicMock()
|
||||||
|
@@ -118,7 +118,7 @@ def do_audit_create(cc, args):
|
|||||||
if fields.get('audit_template_uuid'):
|
if fields.get('audit_template_uuid'):
|
||||||
if not utils.is_uuid_like(fields['audit_template_uuid']):
|
if not utils.is_uuid_like(fields['audit_template_uuid']):
|
||||||
fields['audit_template_uuid'] = cc.audit_template.get(
|
fields['audit_template_uuid'] = cc.audit_template.get(
|
||||||
fields['audit_template'])
|
fields['audit_template_uuid']).uuid
|
||||||
audit = cc.audit.create(**fields)
|
audit = cc.audit.create(**fields)
|
||||||
field_list.append('uuid')
|
field_list.append('uuid')
|
||||||
data = dict([(f, getattr(audit, f, '')) for f in field_list])
|
data = dict([(f, getattr(audit, f, '')) for f in field_list])
|
||||||
|
Reference in New Issue
Block a user