# Path: ddsc/core/moveutil.py
# class MoveUtil(object):
#     def __init__(self, project, source_remote_path, target_remote_path):
#     def run(self):
#     def get_new_parent(self):
#     def get_new_name(self):
#     def is_folder_or_project(item):
# 
# Path: ddsc/exceptions.py
# class DDSUserException(Exception):
#     """
#     Exception with an error message to be displayed to the user on the command line.
#     """
#     pass


from unittest import TestCase
from ddsc.core.moveutil import MoveUtil, KindType
from ddsc.exceptions import DDSUserException
from mock import Mock
    def test_get_new_parent__parent_different(self):
        mock_project = Mock()
        mock_parent_folder = Mock(kind=KindType.folder_str)
        move_util = MoveUtil(mock_project, '/data/file1.txt', '/data2/file1.txt')
        mock_project.try_get_item_for_path.side_effect = [
            None,
            mock_parent_folder
        ]
        result = move_util.get_new_parent()
        self.assertEqual(result, mock_parent_folder)

    def test_get_new_parent__target_parent_file(self):
        mock_project = Mock()
        mock_parent_folder = Mock(kind=KindType.file_str)
        move_util = MoveUtil(mock_project, '/data/file1.txt', '/data2/file1.txt/file1.txt')
        mock_project.try_get_item_for_path.side_effect = [
            None,
            mock_parent_folder
        ]
        with self.assertRaises(DDSUserException) as raised_exception:
            move_util.get_new_parent()
        self.assertEqual(str(raised_exception.exception), 'Target parent /data2/file1.txt is a file.')

    def test_get_new_parent__target_parent_not_found(self):
        mock_project = Mock()
        move_util = MoveUtil(mock_project, '/data/file1.txt', '/data2/file1.txt')
        mock_project.try_get_item_for_path.side_effect = [
            None,
            None
        ]

# Path: ddsc/core/moveutil.py
# class MoveUtil(object):
#     def __init__(self, project, source_remote_path, target_remote_path):
#     def run(self):
#     def get_new_parent(self):
#     def get_new_name(self):
#     def is_folder_or_project(item):
# 
# Path: ddsc/exceptions.py
# class DDSUserException(Exception):
#     """
#     Exception with an error message to be displayed to the user on the command line.
#     """
#     pass


# Path: ddsc/core/tests/test_moveutil.py
from unittest import TestCase
from ddsc.core.moveutil import MoveUtil, KindType
from ddsc.exceptions import DDSUserException
from mock import Mock

    def test_get_new_parent__parent_different(self):
        mock_project = Mock()
        mock_parent_folder = Mock(kind=KindType.folder_str)
        move_util = MoveUtil(mock_project, '/data/file1.txt', '/data2/file1.txt')
        mock_project.try_get_item_for_path.side_effect = [
            None,
            mock_parent_folder
        ]
        result = move_util.get_new_parent()
        self.assertEqual(result, mock_parent_folder)

    def test_get_new_parent__target_parent_file(self):
        mock_project = Mock()
        mock_parent_folder = Mock(kind=KindType.file_str)
        move_util = MoveUtil(mock_project, '/data/file1.txt', '/data2/file1.txt/file1.txt')
        mock_project.try_get_item_for_path.side_effect = [
            None,
            mock_parent_folder
        ]
        with self.assertRaises(DDSUserException) as raised_exception:
            move_util.get_new_parent()
        self.assertEqual(str(raised_exception.exception), 'Target parent /data2/file1.txt is a file.')

    def test_get_new_parent__target_parent_not_found(self):
        mock_project = Mock()
        move_util = MoveUtil(mock_project, '/data/file1.txt', '/data2/file1.txt')
        mock_project.try_get_item_for_path.side_effect = [
            None,
            None
        ]

        with self.assertRaises(DDSUserException) as raised_exception: