예제 #1
0
 def test_dict_to_fs_fqpn_root_unicode(self):
     """
     Second argument to dict_to_fs can be unicode.
     """
     try:
         fs_utils.dict_to_fs(self.good_input_dict, unicode(self.scratch_dir))
     except:
         self.fail("An exception was raised, so this method can't handle unicode.")
예제 #2
0
    def test_dict_to_fs_filename(self):
        """
        dict_to_fs should be able to create a file with a specified filename.
        """
        fs_dict = {"dummy.txt": ""}
        fs_utils.dict_to_fs(fs_dict, self.scratch_dir)

        scratch_names = os.listdir(self.scratch_dir)

        self.assertEqual(scratch_names, fs_dict.keys())
예제 #3
0
    def test_dict_to_fs_isdir(self):
        """
        dict_to_fs should be able to create a directory.
        """
        dummy_dirname = "dummy"
        fs_dict = {dummy_dirname: {}}
        fs_utils.dict_to_fs(fs_dict, self.scratch_dir)

        dummy_fqpn = os.path.join(self.scratch_dir, dummy_dirname)

        self.assertTrue(os.path.isdir(dummy_fqpn))
예제 #4
0
    def test_dict_to_fs_nonempty_file(self):
        """
        A nonempty string should generate a nonempty file.
        """
        dummy_filename = "dummy.txt"
        fs_dict = {dummy_filename: "Hello world.\n"}
        fs_utils.dict_to_fs(fs_dict, self.scratch_dir)

        dummy_fqpn = os.path.join(self.scratch_dir, dummy_filename)

        self.assertTrue(os.path.getsize(dummy_fqpn) > 0)
예제 #5
0
    def test_dict_to_fs_empty_file(self):
        """
        An empty string should generate an empty file.
        """
        dummy_filename = "dummy.txt"
        fs_dict = {dummy_filename: ""}
        fs_utils.dict_to_fs(fs_dict, self.scratch_dir)

        dummy_fqpn = os.path.join(self.scratch_dir, dummy_filename)

        self.assertEqual(os.path.getsize(dummy_fqpn), 0)
예제 #6
0
    def test_dict_to_fs_isfile(self):
        """
        dict_to_fs should be able to create a file.
        """
        dummy_filename = "dummy.txt"
        fs_dict = {dummy_filename: ""}
        fs_utils.dict_to_fs(fs_dict, self.scratch_dir)

        dummy_fqpn = os.path.join(self.scratch_dir, dummy_filename)

        self.assertTrue(os.path.isfile(dummy_fqpn))
예제 #7
0
    def test_dict_to_fs_dir_nonempty(self):
        """
        dict_to_fs should be able to create a populated directory.
        """
        dummy_dirname = "dummy"
        fs_dict = {dummy_dirname: {"test_file.txt":""}}
        fs_utils.dict_to_fs(fs_dict, self.scratch_dir)

        dummy_fqpn = os.path.join(self.scratch_dir, dummy_dirname)

        should_not_be_empty_list = os.listdir(os.path.join(self.scratch_dir, dummy_dirname))

        self.assertTrue(len(should_not_be_empty_list) > 0)
예제 #8
0
    def test_dict_to_fs_dir_isempty(self):
        """
        dict_to_fs should be able to create an empty directory.
        """
        dummy_dirname = "dummy"
        fs_dict = {dummy_dirname: {}}
        fs_utils.dict_to_fs(fs_dict, self.scratch_dir)

        dummy_fqpn = os.path.join(self.scratch_dir, dummy_dirname)

        should_be_empty_list = os.listdir(os.path.join(self.scratch_dir, dummy_dirname))

        self.assertEqual(should_be_empty_list, [])