def test_create_image_target(self): self.mock_object(iscsi, 'create_iscsi_target', mock.Mock(return_value='1')) self.mock_object(os.path, 'exists', mock.Mock(return_value=False)) self.mock_object(blockservice, 'is_looped', mock.Mock(return_value=False)) expected_result = '2:Virtman: Image Service: Warning!image file_path' \ ' = /blocks/image1 not exists! Please use another ' \ 'image file' result = imageservice.create_image_target('image1', '/blocks/image1', '/dev/loop2', test_iqn_prefix) self.assertEqual(expected_result, result) expected_result = '0:1:/dev/loop2' self.mock_object(os.path, 'exists', mock.Mock(return_value=True)) result = imageservice.create_image_target('image1', '/blocks/image1', '/dev/loop2', test_iqn_prefix) self.assertEqual(expected_result, result) expected_result = '1:Virtman: Image Service: Warning! image_name = ' \ 'volume-image1 exists! Please use another name' result = imageservice.create_image_target('image1', '/blocks/image1', '/dev/loop2', test_iqn_prefix) self.assertEqual(expected_result, result)
def create_image_target(image_name, file_path, loop_dev, iqn_prefix): return imageservice.create_image_target(image_name, file_path, loop_dev, iqn_prefix)