示例#1
0
 def setUp(self):
     FileSystemTestCase.setUp(self)
     self.diskIo = DiskIo()
     self.settings = Settings(self.getWorkingDir())
     self.diskIo.createDirWithParents(self.settings.cachePath)
     self.profileCache = ProfileCache(self.settings, self.diskIo)
     self.testProfile = Profile('test/vimrc')
示例#2
0
 def setUp(self):
     FileSystemTestCase.setUp(self)
     self.diskIo = DiskIo()
     self.settings = Settings(self.getWorkingDir())
     self.diskIo.createDirWithParents(self.settings.cachePath)
     self.profileCache = ProfileCache(self.settings, self.diskIo)
     self.testProfile = Profile('test/vimrc')
示例#3
0
class TestProfileCache(FileSystemTestCase):
    def setUp(self):
        FileSystemTestCase.setUp(self)
        self.diskIo = DiskIo()
        self.settings = Settings(self.getWorkingDir())
        self.diskIo.createDirWithParents(self.settings.cachePath)
        self.profileCache = ProfileCache(self.settings, self.diskIo)
        self.testProfile = Profile('test/vimrc')

    # ProfileCache.contains

    def test_contains_whenDirExists_returnsTrue(self):
        profileDir = self.getTestPath('.vimswitch/profiles/test.vimrc')
        self.diskIo.createDir(profileDir)

        result = self.profileCache.contains(self.testProfile)

        self.assertTrue(result)

    def test_contains_whenDirDoesNotExist_returnsFalse(self):
        result = self.profileCache.contains(self.testProfile)
        self.assertFalse(result)

    # ProfileCache.delete

    def test_delete_deletesProfile(self):
        profileDir = self.getTestPath('.vimswitch/profiles/test.vimrc')
        vimrcFilePath = self.getTestPath(
            '.vimswitch/profiles/test.vimrc/.vimrc')
        self.diskIo.createDir(profileDir)
        self.diskIo.createFile(vimrcFilePath, 'test data')

        self.profileCache.delete(self.testProfile)

        self.assertFalse(self.profileCache.contains(self.testProfile))

    # ProfileCache.getProfileLocation

    def test_getProfileLocation(self):
        self.settings.cachePath = '/foo/bar/cachePath'
        profile = Profile('test/vimrc')
        result = self.profileCache.getProfileLocation(profile)
        self.assertEquals(result,
                          os.path.normpath('/foo/bar/cachePath/test.vimrc'))

    # ProfileCache.createEmptyProfile

    def test_createEmptyProfile_profileDoesNotExist_createsProfileDir(self):
        profile = Profile('default')

        self.profileCache.createEmptyProfile(profile)

        profileDir = self.getTestPath('.vimswitch/profiles/default')
        self.assertTrue(self.diskIo.dirExists(profileDir))
示例#4
0
class TestProfileCache(FileSystemTestCase):

    def setUp(self):
        FileSystemTestCase.setUp(self)
        self.diskIo = DiskIo()
        self.settings = Settings(self.getWorkingDir())
        self.diskIo.createDirWithParents(self.settings.cachePath)
        self.profileCache = ProfileCache(self.settings, self.diskIo)
        self.testProfile = Profile('test/vimrc')

    # ProfileCache.contains

    def test_contains_whenDirExists_returnsTrue(self):
        profileDir = self.getTestPath('.vimswitch/profiles/test.vimrc')
        self.diskIo.createDir(profileDir)

        result = self.profileCache.contains(self.testProfile)

        self.assertTrue(result)

    def test_contains_whenDirDoesNotExist_returnsFalse(self):
        result = self.profileCache.contains(self.testProfile)
        self.assertFalse(result)

    # ProfileCache.delete

    def test_delete_deletesProfile(self):
        profileDir = self.getTestPath('.vimswitch/profiles/test.vimrc')
        vimrcFilePath = self.getTestPath('.vimswitch/profiles/test.vimrc/.vimrc')
        self.diskIo.createDir(profileDir)
        self.diskIo.createFile(vimrcFilePath, 'test data')

        self.profileCache.delete(self.testProfile)

        self.assertFalse(self.profileCache.contains(self.testProfile))

    # ProfileCache.getProfileLocation

    def test_getProfileLocation(self):
        self.settings.cachePath = '/foo/bar/cachePath'
        profile = Profile('test/vimrc')
        result = self.profileCache.getProfileLocation(profile)
        self.assertEquals(result, os.path.normpath('/foo/bar/cachePath/test.vimrc'))

    # ProfileCache.createEmptyProfile

    def test_createEmptyProfile_profileDoesNotExist_createsProfileDir(self):
        profile = Profile('default')

        self.profileCache.createEmptyProfile(profile)

        profileDir = self.getTestPath('.vimswitch/profiles/default')
        self.assertTrue(self.diskIo.dirExists(profileDir))
示例#5
0
 def setUp(self):
     self.profile = Profile('test/vimrc')
     self.settings = Settings(os.path.normpath('/home/foo'))
     self.diskIo = Stubs.DiskIoStub()
     # We use the real ProfileCache (with stubbed dependencies) because
     # ProfileCache.getProfileLocation gets called by ProfileCopier
     self.profileCache = ProfileCache(self.settings, self.diskIo)
     self.profileDataIo = Stubs.ProfileDataIoStub()
     self.profileCopier = ProfileCopier(self.settings, self.profileCache,
                                        self.profileDataIo)