# Path: vimswitch/test/BaseTestCase.py
# class BaseTestCase(unittest.TestCase):
#     def __init__(self, *args, **kwargs):
#         unittest.TestCase.__init__(self, *args, **kwargs)
# 
#         # Python < 3.2 does not have assertNotRegex
#         if not hasattr(self, 'assertNotRegex'):
#             self.assertNotRegex = self.assertNotRegexpMatches
# 
#     def assertMultilineRegexpMatches(self, string, regexp):
#         """
#         Asserts that the entirety of `string` matches `regexp`. `regexp` can be
#         a multiline string with indentation.
#         """
#         regexp = textwrap.dedent(regexp)
#         regexp = regexp.strip()
#         regexp = '^' + regexp + '$'
#         regexp = re.compile(regexp, re.DOTALL)
# 
#         self.assertRegexpMatches(string, regexp)
# 
#     def assertStdout(self, stdout, regexp):
#         "Asserts that the `stdout` io stream matches `regexp`"
#         stdoutText = stdout.getvalue().strip()
#         self.assertMultilineRegexpMatches(stdoutText, regexp)
# 
#     def resetStdout(self, stdout):
#         stdout.seek(0)
#         stdout.truncate(0)
# 
# Path: vimswitch/Profile.py
# class Profile:
#     def __init__(self, name):
#         self.name = name
# 
#     def getName(self):
#         return self.name
# 
#     def getDirName(self):
#         return self.name.replace('/', '.')
# 
#     def __eq__(self, other):
#         return isinstance(other, Profile) and self.name == other.name
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     def __repr__(self):
#         return "Profile('%s')" % self.name
# 
# Path: vimswitch/ProfileCache.py
# class ProfileCache:
#     def __init__(self, settings, diskIo):
#         self.settings = settings
#         self.diskIo = diskIo
# 
#     def contains(self, profile):
#         profileLocation = self.getProfileLocation(profile)
#         return self.diskIo.dirExists(profileLocation)
# 
#     def delete(self, profile):
#         profileDirPath = self.getProfileLocation(profile)
#         self.diskIo.deleteDir(profileDirPath)
# 
#     def getProfileLocation(self, profile):
#         """Returns the path where profile is located"""
#         fullPath = os.path.join(self.settings.cachePath, profile.getDirName())
#         return os.path.normpath(fullPath)
# 
#     def createEmptyProfile(self, profile):
#         location = self.getProfileLocation(profile)
#         self.diskIo.createDir(location)
# 
# Path: vimswitch/ProfileCopier.py
# class ProfileCopier:
#     def __init__(self, settings, profileCache, profileDataIo):
#         self.settings = settings
#         self.profileCache = profileCache
#         self.profileDataIo = profileDataIo
# 
#     def copyToHome(self, profile):
#         """
#         Copies the cached profile to home, thus making it active
#         """
#         # TODO: If profileDataIo.copy fails, then we are left with an empty
#         # profile at home. So we should use the 'operate on temp then rename'
#         # pattern
#         homePath = self.settings.homePath
#         profilePath = self.profileCache.getProfileLocation(profile)
#         self.profileDataIo.delete(homePath)
#         self.profileDataIo.copy(profilePath, homePath)
# 
#     def copyFromHome(self, profile):
#         """
#         Copies the active profile data at home to a specified profile in cache.
#         If the profile already exists in cache, it gets overwritten.
#         """
#         if not self.profileCache.contains(profile):
#             self.profileCache.createEmptyProfile(profile)
#         profilePath = self.profileCache.getProfileLocation(profile)
#         homePath = self.settings.homePath
#         self.profileDataIo.delete(profilePath)
#         self.profileDataIo.copy(homePath, profilePath)
# 
# Path: vimswitch/Settings.py
# class Settings:
# 
#     def __init__(self, homePath=''):
#         """
#         homePath is used as the prefix for all other paths. If homePath is not
#         specified it gets set to the user's home directory.
#         """
#         self.homePath = homePath or os.path.expanduser('~')
#         self.configPath = os.path.join(self.homePath, '.vimswitch')
#         self.configFilePath = os.path.join(self.configPath, 'vimswitchrc')
#         self.cachePath = os.path.join(self.configPath, 'profiles')
#         self.downloadsPath = os.path.join(self.configPath, 'downloads')
#         self.profileFiles = ['.vimrc', '_vimrc']
#         self.profileDirs = ['.vim', '_vim']
#         self.defaultProfile = Profile('default')
#         self.currentProfile = None
# 
#     def __eq__(self, other):
#         return self.__dict__ == other.__dict__


from . import Stubs
from .BaseTestCase import BaseTestCase
from mock import MagicMock
from vimswitch.Profile import Profile
from vimswitch.ProfileCache import ProfileCache
from vimswitch.ProfileCopier import ProfileCopier
from vimswitch.Settings import Settings
import os


class TestProfileCopier(BaseTestCase):
    def setUp(self):
        self.profile = Profile('test/vimrc')

# Path: vimswitch/test/BaseTestCase.py
# class BaseTestCase(unittest.TestCase):
#     def __init__(self, *args, **kwargs):
#         unittest.TestCase.__init__(self, *args, **kwargs)
# 
#         # Python < 3.2 does not have assertNotRegex
#         if not hasattr(self, 'assertNotRegex'):
#             self.assertNotRegex = self.assertNotRegexpMatches
# 
#     def assertMultilineRegexpMatches(self, string, regexp):
#         """
#         Asserts that the entirety of `string` matches `regexp`. `regexp` can be
#         a multiline string with indentation.
#         """
#         regexp = textwrap.dedent(regexp)
#         regexp = regexp.strip()
#         regexp = '^' + regexp + '$'
#         regexp = re.compile(regexp, re.DOTALL)
# 
#         self.assertRegexpMatches(string, regexp)
# 
#     def assertStdout(self, stdout, regexp):
#         "Asserts that the `stdout` io stream matches `regexp`"
#         stdoutText = stdout.getvalue().strip()
#         self.assertMultilineRegexpMatches(stdoutText, regexp)
# 
#     def resetStdout(self, stdout):
#         stdout.seek(0)
#         stdout.truncate(0)
# 
# Path: vimswitch/Profile.py
# class Profile:
#     def __init__(self, name):
#         self.name = name
# 
#     def getName(self):
#         return self.name
# 
#     def getDirName(self):
#         return self.name.replace('/', '.')
# 
#     def __eq__(self, other):
#         return isinstance(other, Profile) and self.name == other.name
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     def __repr__(self):
#         return "Profile('%s')" % self.name
# 
# Path: vimswitch/ProfileCache.py
# class ProfileCache:
#     def __init__(self, settings, diskIo):
#         self.settings = settings
#         self.diskIo = diskIo
# 
#     def contains(self, profile):
#         profileLocation = self.getProfileLocation(profile)
#         return self.diskIo.dirExists(profileLocation)
# 
#     def delete(self, profile):
#         profileDirPath = self.getProfileLocation(profile)
#         self.diskIo.deleteDir(profileDirPath)
# 
#     def getProfileLocation(self, profile):
#         """Returns the path where profile is located"""
#         fullPath = os.path.join(self.settings.cachePath, profile.getDirName())
#         return os.path.normpath(fullPath)
# 
#     def createEmptyProfile(self, profile):
#         location = self.getProfileLocation(profile)
#         self.diskIo.createDir(location)
# 
# Path: vimswitch/ProfileCopier.py
# class ProfileCopier:
#     def __init__(self, settings, profileCache, profileDataIo):
#         self.settings = settings
#         self.profileCache = profileCache
#         self.profileDataIo = profileDataIo
# 
#     def copyToHome(self, profile):
#         """
#         Copies the cached profile to home, thus making it active
#         """
#         # TODO: If profileDataIo.copy fails, then we are left with an empty
#         # profile at home. So we should use the 'operate on temp then rename'
#         # pattern
#         homePath = self.settings.homePath
#         profilePath = self.profileCache.getProfileLocation(profile)
#         self.profileDataIo.delete(homePath)
#         self.profileDataIo.copy(profilePath, homePath)
# 
#     def copyFromHome(self, profile):
#         """
#         Copies the active profile data at home to a specified profile in cache.
#         If the profile already exists in cache, it gets overwritten.
#         """
#         if not self.profileCache.contains(profile):
#             self.profileCache.createEmptyProfile(profile)
#         profilePath = self.profileCache.getProfileLocation(profile)
#         homePath = self.settings.homePath
#         self.profileDataIo.delete(profilePath)
#         self.profileDataIo.copy(homePath, profilePath)
# 
# Path: vimswitch/Settings.py
# class Settings:
# 
#     def __init__(self, homePath=''):
#         """
#         homePath is used as the prefix for all other paths. If homePath is not
#         specified it gets set to the user's home directory.
#         """
#         self.homePath = homePath or os.path.expanduser('~')
#         self.configPath = os.path.join(self.homePath, '.vimswitch')
#         self.configFilePath = os.path.join(self.configPath, 'vimswitchrc')
#         self.cachePath = os.path.join(self.configPath, 'profiles')
#         self.downloadsPath = os.path.join(self.configPath, 'downloads')
#         self.profileFiles = ['.vimrc', '_vimrc']
#         self.profileDirs = ['.vim', '_vim']
#         self.defaultProfile = Profile('default')
#         self.currentProfile = None
# 
#     def __eq__(self, other):
#         return self.__dict__ == other.__dict__


# Path: vimswitch/test/test_ProfileCopier.py
from . import Stubs
from .BaseTestCase import BaseTestCase
from mock import MagicMock
from vimswitch.Profile import Profile
from vimswitch.ProfileCache import ProfileCache
from vimswitch.ProfileCopier import ProfileCopier
from vimswitch.Settings import Settings
import os



class TestProfileCopier(BaseTestCase):
    def setUp(self):
        self.profile = Profile('test/vimrc')

        self.settings = Settings(os.path.normpath('/home/foo'))