1010# License for the specific language governing permissions and limitations
1111# under the License.
1212
13- import json
1413import uuid
1514
1615import fixtures
@@ -22,41 +21,37 @@ class ImageTests(base.BaseImageTests):
2221 """Functional tests for Image commands"""
2322
2423 def setUp (self ):
25- super (ImageTests , self ).setUp ()
24+ super ().setUp ()
25+
2626 if not self .haz_v1_api :
2727 self .skipTest ('No Image v1 API present' )
2828
29- self .name = uuid .uuid4 ().hex
30- json_output = json .loads (self .openstack (
31- '--os-image-api-version 1 '
32- 'image create -f json ' +
33- self .name
34- ))
35- self .image_id = json_output ["id" ]
36- self .assertOutput (self .name , json_output ['name' ])
37-
3829 ver_fixture = fixtures .EnvironmentVariable (
3930 'OS_IMAGE_API_VERSION' , '1'
4031 )
4132 self .useFixture (ver_fixture )
4233
34+ self .name = uuid .uuid4 ().hex
35+ output = self .openstack (
36+ 'image create ' + self .name ,
37+ parse_output = True ,
38+ )
39+ self .image_id = output ["id" ]
40+ self .assertOutput (self .name , output ['name' ])
41+
4342 def tearDown (self ):
4443 try :
45- self .openstack (
46- '--os-image-api-version 1 '
47- 'image delete ' +
48- self .image_id
49- )
44+ self .openstack ('image delete ' + self .image_id )
5045 finally :
51- super (ImageTests , self ).tearDown ()
46+ super ().tearDown ()
5247
5348 def test_image_list (self ):
54- json_output = json . loads ( self .openstack (
55- 'image list -f json '
56- ))
49+ output = self .openstack (
50+ 'image list'
51+ )
5752 self .assertIn (
5853 self .name ,
59- [img ['Name' ] for img in json_output ]
54+ [img ['Name' ] for img in output ]
6055 )
6156
6257 def test_image_attributes (self ):
@@ -71,24 +66,24 @@ def test_image_attributes(self):
7166 '--public ' +
7267 self .name
7368 )
74- json_output = json . loads ( self .openstack (
75- 'image show -f json ' +
76- self . name
77- ))
69+ output = self .openstack (
70+ 'image show ' + self . name ,
71+ parse_output = True ,
72+ )
7873 self .assertEqual (
7974 4 ,
80- json_output ["min_disk" ],
75+ output ["min_disk" ],
8176 )
8277 self .assertEqual (
8378 5 ,
84- json_output ["min_ram" ],
79+ output ["min_ram" ],
8580 )
8681 self .assertEqual (
8782 'qcow2' ,
88- json_output ['disk_format' ],
83+ output ['disk_format' ],
8984 )
9085 self .assertTrue (
91- json_output ["is_public" ],
86+ output ["is_public" ],
9287 )
9388
9489 # Test properties
@@ -99,11 +94,11 @@ def test_image_attributes(self):
9994 '--public ' +
10095 self .name
10196 )
102- json_output = json . loads ( self .openstack (
103- 'image show -f json ' +
104- self . name
105- ))
97+ output = self .openstack (
98+ 'image show ' + self . name ,
99+ parse_output = True ,
100+ )
106101 self .assertEqual (
107102 {'a' : 'b' , 'c' : 'd' },
108- json_output ["properties" ],
103+ output ["properties" ],
109104 )
0 commit comments