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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)