Example #1
0
 def precondition(self):
     #sshcfg = self.cfg.ssh
     cls = TestDirectoriesAndFiles
     cfg = self.cfg.cache_manager
     TestHelper.create_source_file(cfg, cls.FILE_1, cls.FILE_1_CONTENT)
     TestHelper.create_source_dir(cfg, cls.SUBDIR_1)
     TestHelper.create_source_file(cfg, cls.FILE_2_SUBPATH, cls.FILE_2_CONTENT)
Example #2
0
    def test(self):
        dir_path = "/TestCacheManager.test_listDir"
        cfg = self.cfg.cache_manager
        TestHelper.create_source_dir(cfg, dir_path)

        subdir_name = 'subdir'
        dir_path2 = os.sep.join([dir_path, subdir_name])
        TestHelper.create_source_dir(cfg, dir_path2)

        file_name = '1.txt'
        file_path = os.sep.join([dir_path, file_name])
        TestHelper.create_source_file(cfg, file_path, 'file_content ... ')

        self.assertTrue(self.sut.exists(dir_path))
        #precond:
        self.sut.getAttributes(dir_path)

        listDir_out = self.sut.listDirectory(dir_path)

        input = [file_name, subdir_name]
        self.assertEqual(sorted(input), sorted(listDir_out))

        cache_root_path = self.sut._cfg.cache_root_dir
        cache_dir_walker = disk_cache.CachedDirWalker(cache_root_path)
        path_transformer = path_factory.PathTransformer()

        cached_subdir_path = os.sep.join(
            [cache_root_path, dir_path, path_transformer.transformDirpath(subdir_name)])

        self.assertTrue(os.path.exists(cached_subdir_path))

        cached_file_path = os.sep.join(
            [cache_root_path, path_transformer.transformFilepath(file_name)])

        self.assertFalse(os.path.exists(cached_file_path))
Example #3
0
 def precondition(self):
     #sshcfg = self.cfg.ssh
     cls = TestDirectoriesAndFiles
     cfg = self.cfg.cache_manager
     TestHelper.create_source_file(cfg, cls.FILE_1, cls.FILE_1_CONTENT)
     TestHelper.create_source_dir(cfg, cls.SUBDIR_1)
     TestHelper.create_source_file(cfg, cls.FILE_2_SUBPATH,
                                   cls.FILE_2_CONTENT)
Example #4
0
    def setUp(self):
        cfg = TestHelper.get_cfg()
        tests_root = cfg.ut_tests_root
        testcase_current = cfg.ut_current_tc
        tc_wdir = self.__test_dir = os.sep.join([tests_root, self.__class__.__name__])
        os.makedirs(tc_wdir)
        if (os.path.lexists(testcase_current)):
            os.unlink(testcase_current)
        os.symlink(tc_wdir, testcase_current)
        TestHelper.create_source_dir(cfg.cache_manager)

        return self.setUpImpl()
Example #5
0
    def setUp(self):
        cfg = TestHelper.get_cfg()
        tests_root = cfg.ut_tests_root
        testcase_current = cfg.ut_current_tc
        tc_wdir = self.__test_dir = os.sep.join(
            [tests_root, self.__class__.__name__])
        os.makedirs(tc_wdir)
        if (os.path.lexists(testcase_current)):
            os.unlink(testcase_current)
        os.symlink(tc_wdir, testcase_current)
        TestHelper.create_source_dir(cfg.cache_manager)

        return self.setUpImpl()
Example #6
0
 def precondition(self):
     cfg = self.cfg.cache_manager
     TestHelper.create_source_dir(cfg, TestDirectoriesOnly.SUBDIR_1)
     TestHelper.create_source_dir(cfg, TestDirectoriesOnly.SUBDIR_2)
     TestHelper.create_source_dir(cfg,
                                  os.sep.join([TestDirectoriesOnly.SUBDIR_2,
                                               TestDirectoriesOnly.SUB_SUBDIR_2]))
Example #7
0
    def test(self):
        dir_path = "/TestCacheManager.test_listDir"
        cfg = self.cfg.cache_manager
        TestHelper.create_source_dir(cfg, dir_path)

        subdir_name = 'subdir'
        dir_path2 = os.sep.join([dir_path, subdir_name])
        TestHelper.create_source_dir(cfg, dir_path2)

        file_name = '1.txt'
        file_path = os.sep.join([dir_path, file_name])
        TestHelper.create_source_file(cfg, file_path, 'file_content ... ')

        self.assertTrue(self.sut.exists(dir_path))
        #precond:
        self.sut.getAttributes(dir_path)

        listDir_out = self.sut.listDirectory(dir_path)

        input = [file_name, subdir_name]
        self.assertEqual(sorted(input), sorted(listDir_out))

        cache_root_path = self.sut._cfg.cache_root_dir
        cache_dir_walker = disk_cache.CachedDirWalker(cache_root_path)
        path_transformer = path_factory.PathTransformer()

        cached_subdir_path = os.sep.join([
            cache_root_path, dir_path,
            path_transformer.transformDirpath(subdir_name)
        ])

        self.assertTrue(os.path.exists(cached_subdir_path))

        cached_file_path = os.sep.join(
            [cache_root_path,
             path_transformer.transformFilepath(file_name)])

        self.assertFalse(os.path.exists(cached_file_path))
Example #8
0
 def precondition(self):
     cfg = self.cfg.cache_manager
     TestHelper.create_source_dir(cfg, TestDirectoriesOnly.SUBDIR_1)
     TestHelper.create_source_dir(cfg, TestDirectoriesOnly.SUBDIR_2)
     TestHelper.create_source_dir(
         cfg,
         os.sep.join([
             TestDirectoriesOnly.SUBDIR_2, TestDirectoriesOnly.SUB_SUBDIR_2
         ]))
Example #9
0
    def precondition(self):
        cfg = self.cfg.cache_manager
        cls = RelativePaths
        TestHelper.create_source_dir(cfg, cls.SUBDIR)
        TestHelper.create_source_file(cfg, cls.FILE, cls.FILE_CONTENT)

        TestHelper.create_source_dir(cfg, cls.SUBDIR_2)
        TestHelper.create_source_file(cfg, cls.FILE_2, cls.FILE_CONTENT_2)

        TestHelper.create_source_dir(cfg, cls.SUBDIR_3)
        TestHelper.create_source_file(cfg, cls.FILE_3, cls.FILE_CONTENT_3)
Example #10
0
    def precondition(self):
        cfg = self.cfg.cache_manager
        cls = RelativePaths
        TestHelper.create_source_dir(cfg, cls.SUBDIR)
        TestHelper.create_source_file(cfg, cls.FILE, cls.FILE_CONTENT)

        TestHelper.create_source_dir(cfg, cls.SUBDIR_2)
        TestHelper.create_source_file(cfg, cls.FILE_2, cls.FILE_CONTENT_2)

        TestHelper.create_source_dir(cfg, cls.SUBDIR_3)
        TestHelper.create_source_file(cfg, cls.FILE_3, cls.FILE_CONTENT_3)
Example #11
0
 def test(self):
     dir_path = '/TestCacheManager.test_isDirectory'
     TestHelper.create_source_dir(self.cfg.cache_manager, dir_path)
     self.assertTrue(self.sut.exists(dir_path))
     self.assertTrue(self.sut.isDirectory(dir_path))
Example #12
0
 def test(self):
     dir_path = '/TestCacheManager.test_isDirectory'
     TestHelper.create_source_dir(self.cfg.cache_manager, dir_path)
     self.assertTrue(self.sut.exists(dir_path))
     self.assertTrue(self.sut.isDirectory(dir_path))