@@ -28,10 +28,11 @@ class ImageTests(base.TestCase):
2828 @classmethod
2929 def setUpClass (cls ):
3030 super (ImageTests , cls ).setUpClass ()
31+ cls .image_tag = 'my_tag'
3132 json_output = json .loads (cls .openstack (
3233 '--os-image-api-version 2 '
33- 'image create -f json ' +
34- cls .NAME
34+ 'image create -f json --tag {tag} {name}' . format (
35+ tag = cls .image_tag , name = cls . NAME )
3536 ))
3637 cls .image_id = json_output ["id" ]
3738 cls .assertOutput (cls .NAME , json_output ['name' ])
@@ -81,6 +82,16 @@ def test_image_list_with_status_filter(self):
8182 [img ['Status' ] for img in json_output ]
8283 )
8384
85+ def test_image_list_with_tag_filter (self ):
86+ json_output = json .loads (self .openstack (
87+ 'image list --tag ' + self .image_tag + ' --long -f json'
88+ ))
89+ for taglist in [img ['Tags' ].split (', ' ) for img in json_output ]:
90+ self .assertIn (
91+ self .image_tag ,
92+ taglist
93+ )
94+
8495 def test_image_attributes (self ):
8596 """Test set, unset, show on attributes, tags and properties"""
8697
@@ -142,6 +153,10 @@ def test_image_attributes(self):
142153 )
143154
144155 # Test tags
156+ self .assertNotIn (
157+ '01' ,
158+ json_output ["tags" ].split (', ' )
159+ )
145160 self .openstack (
146161 'image set ' +
147162 '--tag 01 ' +
@@ -151,9 +166,9 @@ def test_image_attributes(self):
151166 'image show -f json ' +
152167 self .NAME
153168 ))
154- self .assertEqual (
169+ self .assertIn (
155170 '01' ,
156- json_output ["tags" ],
171+ json_output ["tags" ]. split ( ', ' )
157172 )
158173
159174 self .openstack (
@@ -165,9 +180,9 @@ def test_image_attributes(self):
165180 'image show -f json ' +
166181 self .NAME
167182 ))
168- self .assertEqual (
169- '' ,
170- json_output ["tags" ],
183+ self .assertNotIn (
184+ '01 ' ,
185+ json_output ["tags" ]. split ( ', ' )
171186 )
172187
173188 def test_image_set_rename (self ):
0 commit comments