Merge "Use the admin client for the QoS tag tests"
diff --git a/neutron_tempest_plugin/api/admin/test_tag.py b/neutron_tempest_plugin/api/admin/test_tag.py
index eae7977..31b2b96 100644
--- a/neutron_tempest_plugin/api/admin/test_tag.py
+++ b/neutron_tempest_plugin/api/admin/test_tag.py
@@ -26,53 +26,55 @@
super(TagTestJSON, cls).resource_setup()
cls.res_id = cls._create_resource()
- def _get_and_compare_tags(self, tags):
- res_body = self.client.get_tags(self.resource, self.res_id)
+ def _get_and_compare_tags(self, tags, client):
+ res_body = client.get_tags(self.resource, self.res_id)
self.assertCountEqual(tags, res_body['tags'])
- def _test_tag_operations(self):
+ def _test_tag_operations(self, client=None):
+ client = client or self.client
# create and get tags
tags = ['red', 'blue']
- res_body = self.client.update_tags(self.resource, self.res_id, tags)
+ res_body = client.update_tags(self.resource, self.res_id, tags)
self.assertCountEqual(tags, res_body['tags'])
- self._get_and_compare_tags(tags)
+ self._get_and_compare_tags(tags, client)
# add a tag
- self.client.update_tag(self.resource, self.res_id, 'green')
- self._get_and_compare_tags(['red', 'blue', 'green'])
+ client.update_tag(self.resource, self.res_id, 'green')
+ self._get_and_compare_tags(['red', 'blue', 'green'], client)
# update tag exist
- self.client.update_tag(self.resource, self.res_id, 'red')
- self._get_and_compare_tags(['red', 'blue', 'green'])
+ client.update_tag(self.resource, self.res_id, 'red')
+ self._get_and_compare_tags(['red', 'blue', 'green'], client)
# add a tag with a dot
- self.client.update_tag(self.resource, self.res_id, 'black.or.white')
- self._get_and_compare_tags(['red', 'blue', 'green', 'black.or.white'])
+ client.update_tag(self.resource, self.res_id, 'black.or.white')
+ self._get_and_compare_tags(['red', 'blue', 'green', 'black.or.white'],
+ client)
# replace tags
tags = ['red', 'yellow', 'purple']
- res_body = self.client.update_tags(self.resource, self.res_id, tags)
+ res_body = client.update_tags(self.resource, self.res_id, tags)
self.assertCountEqual(tags, res_body['tags'])
- self._get_and_compare_tags(tags)
+ self._get_and_compare_tags(tags, client)
# get tag
- self.client.get_tag(self.resource, self.res_id, 'red')
+ client.get_tag(self.resource, self.res_id, 'red')
# get tag not exist
- self.assertRaises(lib_exc.NotFound, self.client.get_tag,
+ self.assertRaises(lib_exc.NotFound, client.get_tag,
self.resource, self.res_id, 'green')
# delete tag
- self.client.delete_tag(self.resource, self.res_id, 'red')
- self._get_and_compare_tags(['yellow', 'purple'])
+ client.delete_tag(self.resource, self.res_id, 'red')
+ self._get_and_compare_tags(['yellow', 'purple'], client)
# delete tag not exist
- self.assertRaises(lib_exc.NotFound, self.client.delete_tag,
+ self.assertRaises(lib_exc.NotFound, client.delete_tag,
self.resource, self.res_id, 'green')
# delete tags
- self.client.delete_tags(self.resource, self.res_id)
- self._get_and_compare_tags([])
+ client.delete_tags(self.resource, self.res_id)
+ self._get_and_compare_tags([], client)
class TagNetworkTestJSON(TagTestJSON):
@@ -198,7 +200,7 @@
@decorators.idempotent_id('e9bac15e-c8bc-4317-8295-4bf1d8d522b8')
@utils.requires_ext(extension="standard-attr-tag", service="network")
def test_qos_policy_tags(self):
- self._test_tag_operations()
+ self._test_tag_operations(client=self.admin_client)
class TagTrunkTestJSON(TagTestJSON):
@@ -225,16 +227,20 @@
@classmethod
def resource_setup(cls):
super(TagFilterTestJSON, cls).resource_setup()
+ try:
+ client = cls.tag_client
+ except AttributeError:
+ client = cls.client
cls.res_ids = []
for i in range(5):
cls.res_ids.append(cls._create_resource())
- cls.client.update_tags(cls.resource, cls.res_ids[0], ['red'])
- cls.client.update_tags(cls.resource, cls.res_ids[1], ['red', 'blue'])
- cls.client.update_tags(cls.resource, cls.res_ids[2],
- ['red', 'blue', 'green'])
- cls.client.update_tags(cls.resource, cls.res_ids[3], ['green'])
+ client.update_tags(cls.resource, cls.res_ids[0], ['red'])
+ client.update_tags(cls.resource, cls.res_ids[1], ['red', 'blue'])
+ client.update_tags(cls.resource, cls.res_ids[2],
+ ['red', 'blue', 'green'])
+ client.update_tags(cls.resource, cls.res_ids[3], ['green'])
# 5th resource: no tags
@classmethod
@@ -441,6 +447,11 @@
res = self.client.list_qos_policies(**filters)
return res[self.resource]
+ @classmethod
+ def resource_setup(cls):
+ cls.tag_client = cls.admin_client
+ super().resource_setup()
+
@decorators.attr(type='smoke')
@decorators.idempotent_id('c2f9a6ae-2529-4cb9-a44b-b16f8ba27832')
@utils.requires_ext(extension="standard-attr-tag", service="network")