From 225d93ed8427cb43fc79702f75ec45dcf0e4cb60 Mon Sep 17 00:00:00 2001
From: licanwei
Date: Tue, 9 Oct 2018 10:48:04 +0800
Subject: [PATCH] Fix test_show_audit
Only when audit state is ONGOING/SUCCESS/FAILED,
hostname has a valid value.
Change-Id: I08d34382fc8f9379bed0a970c0d88a5bff501ca5
---
watcher_tempest_plugin/tests/api/admin/test_audit.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/watcher_tempest_plugin/tests/api/admin/test_audit.py b/watcher_tempest_plugin/tests/api/admin/test_audit.py
index 106abf0..cbc6426 100644
--- a/watcher_tempest_plugin/tests/api/admin/test_audit.py
+++ b/watcher_tempest_plugin/tests/api/admin/test_audit.py
@@ -229,7 +229,10 @@ class TestShowListAudit(base.BaseInfraOptimTest):
actual_audit = audit.copy()
self.assertIn(audit_state, self.audit_states)
- self.assertIsNotNone(actual_audit['hostname'])
+ # hostname may be None if audit state is
+ # CANCELLED/DELETED/PENDING/SUSPENDED
+ if audit_state in ('ONGOING', 'SUCCEEDED', 'FAILED'):
+ self.assertIsNotNone(actual_audit['hostname'])
self.assert_expected(initial_audit, actual_audit)
@decorators.attr(type='smoke')