Test for (not) showing a DELETED template

Story: 2005091
Task: 30204

Change-Id: Ib20a24b97709d0d4fe9b35e0c21319407ed3aab1
This commit is contained in:
Naseem Srour 2019-03-27 14:15:02 +00:00 committed by Eyal
parent d92a75cc07
commit 9acd13f577
1 changed files with 33 additions and 16 deletions

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from testtools import matchers
import yaml
@ -26,6 +25,7 @@ from vitrage_tempest_plugin.tests.common import general_utils as g_utils
from vitrage_tempest_plugin.tests.common import vitrage_utils as v_utils
import vitrage_tempest_plugin.tests.utils as utils
from vitrageclient.exceptions import ClientException
LOG = logging.getLogger(__name__)
@ -144,23 +144,14 @@ class TemplatesDBTest(BaseTemplateTest):
'corrupted template template presented in list')
def test_template_delete(self):
self._add_delete_template()
# add standard template
v_utils.add_template(STANDARD_TEMPLATE,
template_type=TTypes.STANDARD)
db_row = v_utils.get_first_template(
name='host_high_memory_usage_scenarios',
type=TTypes.STANDARD,
status=TemplateStatus.ACTIVE)
self.assertIsNotNone(db_row,
'Template should appear in templates list')
def test_template_dont_show_deleted_template(self):
# delete template
uuid = db_row['uuid']
v_utils.delete_template(uuid)
db_row = v_utils.get_first_template(
name='host_high_memory_usage_scenarios', type=TTypes.STANDARD)
self.assertIsNone(db_row, 'Template should not appear in list')
uuid = self._add_delete_template()
self.assertRaises(ClientException,
self.vitrage_client.template.show,
uuid)
def test_compare_cli_to_api(self):
"""Compare between api template list
@ -219,3 +210,29 @@ class TemplatesDBTest(BaseTemplateTest):
'entity equivalence example',
'basic_def_template',
'corrupted_template']
def _add_delete_template(self):
"""A helper function:
Adds and deletes a template.
Returns its uuid.
"""
# add a template
v_utils.add_template(STANDARD_TEMPLATE, template_type=TTypes.STANDARD)
db_row = v_utils.get_first_template(
name='host_high_memory_usage_scenarios',
type=TTypes.STANDARD,
status=TemplateStatus.ACTIVE)
self.assertIsNotNone(db_row,
'Template should appear in templates list')
# delete it
uuid = db_row['uuid']
v_utils.delete_template(uuid)
db_row = v_utils.get_first_template(
name='host_high_memory_usage_scenarios',
type=TTypes.STANDARD)
self.assertIsNone(db_row, 'Template should not appear in list')
return uuid