Example #1
0
    def test_get_tags_from_files_and_subfolders(self):

        self.assertEqual(
            filetags.get_tags_from_files_and_subfolders(self.tempdir,
                                                        use_cache=False), {
                                                            'baz': 2,
                                                            'bar': 3,
                                                            'teststring1': 1
                                                        })
Example #2
0
    def setUp(self):

        ## create temporary directory:
        self.tempdir = tempfile.mkdtemp()
        os.chdir(self.tempdir)
        print "\nTestHierarchyWithFilesAndFolders: temporary directory: " + self.tempdir

        ## initial tests without files:
        self.assertEqual(filetags.get_tags_from_files_and_subfolders(self.tempdir, use_cache=False), {})

        ## create set of test files:
        self.create_tmp_file("foo1 -- bar.txt")
        self.create_tmp_file("foo2 -- bar baz.txt")
        self.create_tmp_file("foo3 -- bar baz teststring1.txt")
Example #3
0
    def setUp(self):
        """This setup function creates following dir/file structure:

        tempdir   (via tempfile.mkdtemp())
          |_ "foo1 -- bar.txt"
          |_ "foo2 -- bar baz.txt"
          |_ "foo3 -- baz teststring1.txt"
          |_ sub dir 1/
               |_ "foo4 -- bar.txt"
               |_ "foo5.txt"
               |_ "foo6 -- baz teststring1.txt"
               |_ "foo7 -- teststring1.txt"
               |_ "foo8 -- baz.txt"
               |_ "foo9 -- baz bar.txt"
          |_ sub dir 2/  (empty)
        """

        # create temporary directory:
        self.tempdir = tempfile.mkdtemp()
        os.chdir(self.tempdir)
        print("\nTestHierarchyWithFilesAndFolders: temporary directory: " +
              self.tempdir)

        # initial tests without files:
        self.assertEqual(
            filetags.get_tags_from_files_and_subfolders(self.tempdir,
                                                        use_cache=False), {})

        # create set of test files:
        self.create_tmp_file(self.tempdir, "foo1 -- bar.txt")
        self.create_tmp_file(self.tempdir, "foo2 -- bar baz.txt")
        self.create_tmp_file(self.tempdir, "foo3 -- baz teststring1.txt")

        # create first sub directory and its files:
        self.subdir1 = os.path.join(self.tempdir, "sub dir 1")
        os.makedirs(self.subdir1)
        self.create_tmp_file(self.subdir1, "foo4 -- bar.txt")
        self.create_tmp_file(self.subdir1, "foo5.txt")
        self.create_tmp_file(self.subdir1, "foo6 -- baz teststring1.txt")
        self.create_tmp_file(self.subdir1, "foo7 -- teststring1.txt")
        self.create_tmp_file(self.subdir1, "foo8 -- baz.txt")
        self.create_tmp_file(self.subdir1, "foo9 -- baz bar.txt")

        # create second sub directory (empty)
        self.subdir2 = os.path.join(self.tempdir, "sub dir 2")
        os.makedirs(self.subdir2)

        if platform.system() != 'Windows':
            os.sync()
Example #4
0
    def setUp(self):
        """This setup function creates following dir/file structure:

        tempdir   (via tempfile.mkdtemp())
          |_ "foo1 -- bar.txt"
          |_ "foo2 -- bar baz.txt"
          |_ "foo3 -- baz teststring1.txt"
          |_ sub dir 1/
               |_ "foo4 -- bar.txt"
               |_ "foo5.txt"
               |_ "foo6 -- baz teststring1.txt"
               |_ "foo7 -- teststring1.txt"
               |_ "foo8 -- baz.txt"
               |_ "foo9 -- baz bar.txt"
          |_ sub dir 2/  (empty)
        """

        # create temporary directory:
        self.tempdir = tempfile.mkdtemp()
        os.chdir(self.tempdir)
        print("\nTestHierarchyWithFilesAndFolders: temporary directory: " + self.tempdir)

        # initial tests without files:
        self.assertEqual(filetags.get_tags_from_files_and_subfolders(self.tempdir, use_cache=False), {})

        # create set of test files:
        self.create_tmp_file(self.tempdir, "foo1 -- bar.txt")
        self.create_tmp_file(self.tempdir, "foo2 -- bar baz.txt")
        self.create_tmp_file(self.tempdir, "foo3 -- baz teststring1.txt")

        # create first sub directory and its files:
        self.subdir1 = os.path.join(self.tempdir, "sub dir 1")
        os.makedirs(self.subdir1)
        self.create_tmp_file(self.subdir1, "foo4 -- bar.txt")
        self.create_tmp_file(self.subdir1, "foo5.txt")
        self.create_tmp_file(self.subdir1, "foo6 -- baz teststring1.txt")
        self.create_tmp_file(self.subdir1, "foo7 -- teststring1.txt")
        self.create_tmp_file(self.subdir1, "foo8 -- baz.txt")
        self.create_tmp_file(self.subdir1, "foo9 -- baz bar.txt")

        # create second sub directory (empty)
        self.subdir2 = os.path.join(self.tempdir, "sub dir 2")
        os.makedirs(self.subdir2)

        if platform.system() != 'Windows':
            os.sync()
Example #5
0
    def setUp(self):

        # create temporary directory:
        self.tempdir = tempfile.mkdtemp()
        os.chdir(self.tempdir)
        print("\nTestHierarchyWithFilesAndFolders: temporary directory: " +
              self.tempdir)

        # initial tests without files:
        self.assertEqual(
            filetags.get_tags_from_files_and_subfolders(self.tempdir,
                                                        use_cache=False), {})

        # create set of test files:
        self.create_tmp_file("foo1 -- bar.txt")
        self.create_tmp_file("foo2 -- bar baz.txt")
        self.create_tmp_file("foo3 -- bar baz teststring1.txt")

        if platform.system() != 'Windows':
            os.sync()
Example #6
0
    def test_get_tags_from_files_and_subfolders(self):

        self.assertEqual(filetags.get_tags_from_files_and_subfolders(self.tempdir, use_cache=False), {u'baz': 2, u'bar': 3, u'teststring1': 1})
Example #7
0
    def test_get_tags_from_files_and_subfolders(self):

        self.assertEqual(filetags.get_tags_from_files_and_subfolders(self.tempdir, False, False), {u'baz': 2, u'bar': 3, u'labelgreen': 1})