Ejemplo n.º 1
0
 def test_invalid_file_argument(self):
     # This is obviously not intended use; the function expects a directory
     # as its argument, not a file. Test anyway.
     test_file = r"f:\dev\sleepy"
     self.fs.create_file(test_file)
     assert os.path.exists(test_file) is True
     assert filesystem.listdir_full(test_file) == []
Ejemplo n.º 2
0
def nzb_redirect(wdir, nzbname, pp, script, cat, priority):
    """Check if this job contains only NZB files,
    if so send to queue and remove if on clean-up list
    Returns list of processed NZB's
    """
    files = listdir_full(wdir)

    for nzb_file in files:
        if get_ext(nzb_file) != ".nzb":
            return None

    # For multiple NZBs, cannot use the current job name
    if len(files) != 1:
        nzbname = None

    # Process all NZB files
    for nzb_file in files:
        process_single_nzb(
            get_filename(nzb_file),
            nzb_file,
            pp=pp,
            script=script,
            cat=cat,
            priority=priority,
            dup_check=False,
            nzbname=nzbname,
        )
    return files
Ejemplo n.º 3
0
    def test_no_exceptions(self):
        test_files = (
            r"f:\test\dir\file1.ext",
            r"f:\test\dir\file2",
            r"f:\test\dir\sub\sub\sub\dir\file3.ext",
        )
        for file in test_files:
            self.fs.create_file(file)
            assert os.path.exists(file) is True
        # List our fake directory structure
        results_subdir = filesystem.listdir_full(r"f:\test\dir")
        assert len(results_subdir) == 3
        for entry in test_files:
            assert (entry in results_subdir) is True

        # List the same directory again, this time using its parent as the function argument.
        # Results should be identical, since there's nothing in /test but that one subdirectory
        results_parent = filesystem.listdir_full(r"f:\test")
        # Don't make assumptions about the sorting of the lists of results
        results_parent.sort()
        results_subdir.sort()
        assert results_parent == results_subdir

        # List that subsubsub-directory; no sorting required for a single result
        assert filesystem.listdir_full(r"F:\test\dir\SUB\sub")[0].lower() == r"f:\test\dir\sub\sub\sub\dir\file3.ext"

        # Test non-recursive version
        assert filesystem.listdir_full(r"f:\test", recursive=False) == []
        assert filesystem.listdir_full(r"F:\test\dir\SUB", recursive=False) == []
        assert len(filesystem.listdir_full(r"f:\test\dir", recursive=False)) == 2
Ejemplo n.º 4
0
 def test_exception_appledouble(self):
     # Anything below a .AppleDouble directory should be omitted
     test_file = r"f:\foo\bar\.AppleDouble\Oooooo.ps"
     self.fs.create_file(test_file)
     assert os.path.exists(test_file) is True
     assert filesystem.listdir_full(r"f:\foo") == []
     assert filesystem.listdir_full(r"f:\foo\bar") == []
     assert filesystem.listdir_full(r"F:\foo\bar\.AppleDouble") == []
     assert filesystem.listdir_full(r"f:\foo", recursive=False) == []
     assert filesystem.listdir_full(r"f:\foo\bar", recursive=False) == []
     assert filesystem.listdir_full(r"F:\foo\bar\.AppleDouble", recursive=False) == []
Ejemplo n.º 5
0
 def test_exception_dsstore(self):
     # Anything below a .DS_Store directory should be omitted
     for file in (
         r"f:\some\FILE",
         r"f:\some\.DS_Store\oh.NO",
         r"f:\some\.DS_Store\subdir\The.End",
     ):
         self.fs.create_file(file)
         assert os.path.exists(file) is True
     assert filesystem.listdir_full(r"f:\some") == [r"f:\some\FILE"]
     assert filesystem.listdir_full(r"f:\some\.DS_Store") == []
     assert filesystem.listdir_full(r"f:\some\.DS_Store\subdir") == []
     assert filesystem.listdir_full(r"f:\some", recursive=True) == [r"f:\some\FILE"]
     assert filesystem.listdir_full(r"f:\some\.DS_Store", recursive=True) == []
     assert filesystem.listdir_full(r"f:\some\.DS_Store\subdir", recursive=True) == []
Ejemplo n.º 6
0
 def test_exception_dsstore(self):
     # Anything below a .DS_Store directory should be omitted
     for file in (
         "/some/FILE",
         "/some/.DS_Store/oh.NO",
         "/some/.DS_Store/subdir/The.End",
     ):
         self.fs.create_file(file)
         assert os.path.exists(file) is True
     assert filesystem.listdir_full("/some") == ["/some/FILE"]
     assert filesystem.listdir_full("/some/.DS_Store/") == []
     assert filesystem.listdir_full("/some/.DS_Store/subdir") == []
     assert filesystem.listdir_full("/some", recursive=False) == ["/some/FILE"]
     assert filesystem.listdir_full("/some/.DS_Store/", recursive=False) == []
     assert filesystem.listdir_full("/some/.DS_Store/subdir", recursive=False) == []
Ejemplo n.º 7
0
 def test_nonexistent_dir(self):
     assert filesystem.listdir_full(r"F:\foo\bar") == []
Ejemplo n.º 8
0
 def test_nonexistent_dir(self):
     assert filesystem.listdir_full("/foo/bar") == []