示例#1
0
def test_path():
    """Test path of Image file object."""

    path = "./test/testsource/(814837) ろさ - 空と私.jpg"
    re_pattern = re.compile("(?<=^\()\d*(?=\))")
    img = Image(path, re_pattern)
    assert_equal(img.path, path)
示例#2
0
def test_id_dir():
    """Test id of Image directory object."""
    path = "./test/testsource/(206921) cherrypin - イラスト集め"

    # first check if directory exists
    assert os.path.exists(path)

    re_pattern = re.compile("(?<=^\()\d*(?=\))")
    img = Image(path, re_pattern)
    assert_equal(img.artist_id, "206921")
示例#3
0
def test_id_file():
    """Test id of Image file object."""
    path = "./test/testsource/(814837) ろさ - 空と私.jpg"

    # first check if file exists
    assert os.path.exists(path)

    re_pattern = re.compile("(?<=^\()\d*(?=\))")
    img = Image(path, re_pattern)
    assert_equal(img.artist_id, "814837")
示例#4
0
文件: search.py 项目: ko89/pixivsort
    def find_images(self):
        """Reads the source path and finds image files and directories.
            Returns a list of all Image file and directory objects."""
        imagelist = []
        filelist = os.listdir(self.src_path)
        for file in filelist:
            filepath = os.path.join(self.src_path, file)

            img = Image(filepath, self.src_regex)
            if img.artist_id != None:
                imagelist.append(img)

        return imagelist
示例#5
0
def test_copy_file():
    """Test copying an Image file object."""
    # If pathnames don't work a switch may be needed
    # using: platform.system() == 'Windows'

    sourcefile = "./test/testsource/(814837) ろさ - 空と私.jpg"
    destpath = "./test/testdestination"

    re_pattern = re.compile("(?<=^\()\d*(?=\))")
    img = Image(sourcefile, re_pattern)

    img.copy(destpath)

    destfile = "./test/testdestination/(814837) ろさ - 空と私.jpg"
    assert os.path.exists(destfile)

    # Move image back.
    img2 = Image(destfile, re_pattern)

    img2.copy(sourcefile)
示例#6
0
def test_copy_dir():
    """Test copying an Image directory object."""
    # If pathnames don't work a switch will be needed
    # using: platform.system() == 'Windows'

    # Location of the test directory and the test destination
    sourcefile = "./test/testsource/(206921) cherrypin - イラスト集め"
    destpath = "./test/testdestination"

    # Create Image object and move it to the test destination
    re_pattern = re.compile("(?<=^\()\d*(?=\))")
    img = Image(sourcefile, re_pattern)
    img.copy(destpath)

    # The directory and it's contents should now be at the test destination
    destfile = "./test/testdestination/(206921) cherrypin - イラスト集め"
    # If not the test fails
    assert os.path.exists(destfile)

    # Move directory back in place.
    img2 = Image(destfile, re_pattern)
    img2.copy("./test/testsource")
示例#7
0
def test_copy_file():
    """Test copying an Image file object."""
    # If pathnames don't work a switch may be needed
    # using: platform.system() == 'Windows'
    
    sourcefile = "./test/testsource/(814837) ろさ - 空と私.jpg"
    destpath = "./test/testdestination"

    re_pattern = re.compile("(?<=^\()\d*(?=\))")
    img = Image(sourcefile, re_pattern)
    
    img.copy(destpath)
    
    destfile =  "./test/testdestination/(814837) ろさ - 空と私.jpg"
    assert os.path.exists(destfile)
    
    # Move image back.
    img2 = Image(destfile, re_pattern)
    
    img2.copy(sourcefile)
示例#8
0
def test_copy_dir():
    """Test copying an Image directory object."""
    # If pathnames don't work a switch will be needed
    # using: platform.system() == 'Windows'
    
    # Location of the test directory and the test destination
    sourcefile = "./test/testsource/(206921) cherrypin - イラスト集め"
    destpath = "./test/testdestination"

    # Create Image object and move it to the test destination
    re_pattern = re.compile("(?<=^\()\d*(?=\))")
    img = Image(sourcefile, re_pattern)
    img.copy(destpath)
    
    # The directory and it's contents should now be at the test destination
    destfile =  "./test/testdestination/(206921) cherrypin - イラスト集め"
    # If not the test fails
    assert os.path.exists(destfile)
    
    # Move directory back in place.
    img2 = Image(destfile, re_pattern)
    img2.copy("./test/testsource")