1515
1616import fixtures
1717
18- from openstackclient .tests .functional import base
18+ from openstackclient .tests .functional . image import base
1919
2020
21- class ImageTests (base .TestCase ):
22- """Functional tests for image. """
21+ class ImageTests (base .BaseImageTests ):
22+ """Functional tests for Image commands """
2323
24- NAME = uuid .uuid4 ().hex
25- OTHER_NAME = uuid .uuid4 ().hex
24+ def setUp (self ):
25+ super (ImageTests , self ).setUp ()
26+ if not self .haz_v1_api :
27+ self .skipTest ('No Image v1 API present' )
2628
27- @classmethod
28- def setUpClass (cls ):
29- super (ImageTests , cls ).setUpClass ()
30- json_output = json .loads (cls .openstack (
29+ self .name = uuid .uuid4 ().hex
30+ json_output = json .loads (self .openstack (
3131 '--os-image-api-version 1 '
3232 'image create -f json ' +
33- cls . NAME
33+ self . name
3434 ))
35- cls .image_id = json_output ["id" ]
36- cls .assertOutput (cls .NAME , json_output ['name' ])
35+ self .image_id = json_output ["id" ]
36+ self .assertOutput (self .name , json_output ['name' ])
37+
38+ ver_fixture = fixtures .EnvironmentVariable (
39+ 'OS_IMAGE_API_VERSION' , '1'
40+ )
41+ self .useFixture (ver_fixture )
3742
38- @classmethod
39- def tearDownClass (cls ):
43+ def tearDown (self ):
4044 try :
41- cls .openstack (
45+ self .openstack (
4246 '--os-image-api-version 1 '
4347 'image delete ' +
44- cls .image_id
48+ self .image_id
4549 )
4650 finally :
47- super (ImageTests , cls ).tearDownClass ()
48-
49- def setUp (self ):
50- super (ImageTests , self ).setUp ()
51- ver_fixture = fixtures .EnvironmentVariable (
52- 'OS_IMAGE_API_VERSION' , '1'
53- )
54- self .useFixture (ver_fixture )
51+ super (ImageTests , self ).tearDown ()
5552
5653 def test_image_list (self ):
5754 json_output = json .loads (self .openstack (
5855 'image list -f json '
5956 ))
6057 self .assertIn (
61- self .NAME ,
58+ self .name ,
6259 [img ['Name' ] for img in json_output ]
6360 )
6461
@@ -72,11 +69,11 @@ def test_image_attributes(self):
7269 '--min-ram 5 ' +
7370 '--disk-format qcow2 ' +
7471 '--public ' +
75- self .NAME
72+ self .name
7673 )
7774 json_output = json .loads (self .openstack (
7875 'image show -f json ' +
79- self .NAME
76+ self .name
8077 ))
8178 self .assertEqual (
8279 4 ,
@@ -100,11 +97,11 @@ def test_image_attributes(self):
10097 '--property a=b ' +
10198 '--property c=d ' +
10299 '--public ' +
103- self .NAME
100+ self .name
104101 )
105102 json_output = json .loads (self .openstack (
106103 'image show -f json ' +
107- self .NAME
104+ self .name
108105 ))
109106 self .assertEqual (
110107 "a='b', c='d'" ,
0 commit comments