diff options
Diffstat (limited to 'openstackclient/tests/functional/image/v1/test_image.py')
| -rw-r--r-- | openstackclient/tests/functional/image/v1/test_image.py | 96 |
1 files changed, 63 insertions, 33 deletions
diff --git a/openstackclient/tests/functional/image/v1/test_image.py b/openstackclient/tests/functional/image/v1/test_image.py index 7e12f2c7..901f4337 100644 --- a/openstackclient/tests/functional/image/v1/test_image.py +++ b/openstackclient/tests/functional/image/v1/test_image.py @@ -26,44 +26,74 @@ class ImageTests(base.TestCase): @classmethod def setUpClass(cls): os.environ['OS_IMAGE_API_VERSION'] = '1' - cmd_output = json.loads(cls.openstack( - 'image create -f json ' + cls.NAME)) - cls.assertOutput(cls.NAME, cmd_output['name']) + json_output = json.loads(cls.openstack( + 'image create -f json ' + + cls.NAME + )) + cls.image_id = json_output["id"] + cls.assertOutput(cls.NAME, json_output['name']) @classmethod def tearDownClass(cls): - # Rename test - raw_output = cls.openstack('image set --name ' + cls.OTHER_NAME + ' ' - + cls.NAME) - cls.assertOutput('', raw_output) - # Delete test - raw_output = cls.openstack('image delete ' + cls.OTHER_NAME) - cls.assertOutput('', raw_output) + cls.openstack( + 'image delete ' + + cls.image_id + ) def test_image_list(self): - cmd_output = json.loads(self.openstack('image list -f json')) - col_names = [img['Name'] for img in cmd_output] - self.assertIn(self.NAME, col_names) + json_output = json.loads(self.openstack( + 'image list -f json ' + )) + self.assertIn( + self.NAME, + [img['Name'] for img in json_output] + ) - def test_image_show(self): - cmd_output = json.loads(self.openstack( - 'image show -f json ' + self.NAME)) - self.assertEqual(self.NAME, cmd_output['name']) + def test_image_attributes(self): + """Test set, unset, show on attributes, tags and properties""" - def test_image_set(self): - self.openstack('image set --min-disk 4 --min-ram 5 ' + - '--disk-format qcow2 --public ' + self.NAME) - cmd_output = json.loads(self.openstack( - 'image show -f json ' + self.NAME)) - self.assertEqual(self.NAME, cmd_output['name']) - self.assertEqual(4, cmd_output['min_disk']) - self.assertEqual(5, cmd_output['min_ram']) - self.assertEqual('qcow2', cmd_output['disk_format']) - self.assertEqual(True, cmd_output['is_public']) + # Test explicit attributes + self.openstack( + 'image set ' + + '--min-disk 4 ' + + '--min-ram 5 ' + + '--disk-format qcow2 ' + + '--public ' + + self.NAME + ) + json_output = json.loads(self.openstack( + 'image show -f json ' + + self.NAME + )) + self.assertEqual( + 4, + json_output["min_disk"], + ) + self.assertEqual( + 5, + json_output["min_ram"], + ) + self.assertEqual( + 'qcow2', + json_output['disk_format'], + ) + self.assertTrue( + json_output["is_public"], + ) - def test_image_metadata(self): - self.openstack('image set --property a=b --property c=d ' + self.NAME) - cmd_output = json.loads(self.openstack( - 'image show -f json ' + self.NAME)) - self.assertEqual(self.NAME, cmd_output['name']) - self.assertEqual("a='b', c='d'", cmd_output['properties']) + # Test properties + self.openstack( + 'image set ' + + '--property a=b ' + + '--property c=d ' + + '--public ' + + self.NAME + ) + json_output = json.loads(self.openstack( + 'image show -f json ' + + self.NAME + )) + self.assertEqual( + "a='b', c='d'", + json_output["properties"], + ) |
