summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-06-29 02:47:41 +0000
committerGerrit Code Review <review@openstack.org>2018-06-29 02:47:41 +0000
commit7d7a429685ccca121304f1492da973a604a45788 (patch)
treec80fc62754442edcf010b6cbb51be617de638172 /openstackclient/tests/functional
parent3493948d13aadd1a329b37eb8fafb731b1f5c6a7 (diff)
parent9edbab8c90bb74ba12892d0c77c8e8a99d4868fe (diff)
downloadpython-openstackclient-7d7a429685ccca121304f1492da973a604a45788.tar.gz
Merge "Add ability to filter image list by tag"
Diffstat (limited to 'openstackclient/tests/functional')
-rw-r--r--openstackclient/tests/functional/image/v2/test_image.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/openstackclient/tests/functional/image/v2/test_image.py b/openstackclient/tests/functional/image/v2/test_image.py
index 278ba5b9..3037b903 100644
--- a/openstackclient/tests/functional/image/v2/test_image.py
+++ b/openstackclient/tests/functional/image/v2/test_image.py
@@ -28,10 +28,11 @@ class ImageTests(base.TestCase):
@classmethod
def setUpClass(cls):
super(ImageTests, cls).setUpClass()
+ cls.image_tag = 'my_tag'
json_output = json.loads(cls.openstack(
'--os-image-api-version 2 '
- 'image create -f json ' +
- cls.NAME
+ 'image create -f json --tag {tag} {name}'.format(
+ tag=cls.image_tag, name=cls.NAME)
))
cls.image_id = json_output["id"]
cls.assertOutput(cls.NAME, json_output['name'])
@@ -81,6 +82,16 @@ class ImageTests(base.TestCase):
[img['Status'] for img in json_output]
)
+ def test_image_list_with_tag_filter(self):
+ json_output = json.loads(self.openstack(
+ 'image list --tag ' + self.image_tag + ' --long -f json'
+ ))
+ for taglist in [img['Tags'].split(', ') for img in json_output]:
+ self.assertIn(
+ self.image_tag,
+ taglist
+ )
+
def test_image_attributes(self):
"""Test set, unset, show on attributes, tags and properties"""
@@ -142,6 +153,10 @@ class ImageTests(base.TestCase):
)
# Test tags
+ self.assertNotIn(
+ '01',
+ json_output["tags"].split(', ')
+ )
self.openstack(
'image set ' +
'--tag 01 ' +
@@ -151,9 +166,9 @@ class ImageTests(base.TestCase):
'image show -f json ' +
self.NAME
))
- self.assertEqual(
+ self.assertIn(
'01',
- json_output["tags"],
+ json_output["tags"].split(', ')
)
self.openstack(
@@ -165,9 +180,9 @@ class ImageTests(base.TestCase):
'image show -f json ' +
self.NAME
))
- self.assertEqual(
- '',
- json_output["tags"],
+ self.assertNotIn(
+ '01',
+ json_output["tags"].split(', ')
)
def test_image_set_rename(self):