コード例 #1
0
 def test_parse_wrong_dir_name(self):
     image_uuid = '/test/image_1'
     self.yaml_mock.return_value = {'uuid': 'image_2'}
     error_msg = ("UUID from metadata file \[{0}] doesn't equal"
                  " directory name \[{1}]".format('image_2', image_uuid))
     with self.assertRaisesRegexp(errors.IncorrectImage, error_msg):
         bs_image.parse(image_uuid)
コード例 #2
0
 def test_parse_wrong_dir_name(self):
     image_uuid = '/test/image_1'
     self.yaml_mock.return_value = {'uuid': 'image_2'}
     error_msg = ("UUID from metadata file \[{0}] doesn't equal"
                  " directory name \[{1}]".format('image_2', image_uuid))
     with self.assertRaisesRegexp(errors.IncorrectImage, error_msg):
         bs_image.parse(image_uuid)
コード例 #3
0
 def test_parse_active_image(self, active_mock):
     active_mock.return_value = True
     image_uuid = '/test/image_1'
     self.yaml_mock.return_value = {'uuid': 'image_1'}
     expected_data = {
         'uuid': 'image_1',
         'label': '',
         'status': 'active',
     }
     data = bs_image.parse(image_uuid)
     self.assertEqual(expected_data, data)
コード例 #4
0
 def test_parse_active_image(self, active_mock):
     active_mock.return_value = True
     image_uuid = '/test/image_1'
     self.yaml_mock.return_value = {'uuid': 'image_1'}
     expected_data = {
         'uuid': 'image_1',
         'label': '',
         'status': 'active',
     }
     data = bs_image.parse(image_uuid)
     self.assertEqual(expected_data, data)
コード例 #5
0
 def test_parse_no_metadata(self):
     image_uuid = '/test/image_2'
     error_msg = (
         "Image \[{0}] doesn't contain metadata file.".format(image_uuid))
     with self.assertRaisesRegexp(errors.IncorrectImage, error_msg):
         bs_image.parse(image_uuid)
コード例 #6
0
 def test_parse_not_dir(self, isdir_mock):
     image_uuid = '/test/test_file'
     error_msg = "There are no such image \[{0}].".format(image_uuid)
     with self.assertRaisesRegexp(errors.IncorrectImage, error_msg):
         bs_image.parse(image_uuid)
コード例 #7
0
 def test_parse_link(self, islink_mock):
     image_uuid = '/test/link_active_bootstrap'
     error_msg = "There are no such image \[{0}].".format(image_uuid)
     with self.assertRaisesRegexp(errors.IncorrectImage, error_msg):
         bs_image.parse(image_uuid)
コード例 #8
0
 def test_parse_no_metadata(self):
     image_uuid = '/test/image_2'
     error_msg = ("Image \[{0}] doesn't contain metadata file."
                  .format(image_uuid))
     with self.assertRaisesRegexp(errors.IncorrectImage, error_msg):
         bs_image.parse(image_uuid)
コード例 #9
0
 def test_parse_not_dir(self, isdir_mock):
     image_uuid = '/test/test_file'
     error_msg = "There are no such image \[{0}].".format(image_uuid)
     with self.assertRaisesRegexp(errors.IncorrectImage, error_msg):
         bs_image.parse(image_uuid)
コード例 #10
0
 def test_parse_link(self, islink_mock):
     image_uuid = '/test/link_active_bootstrap'
     error_msg = "There are no such image \[{0}].".format(image_uuid)
     with self.assertRaisesRegexp(errors.IncorrectImage, error_msg):
         bs_image.parse(image_uuid)