Exemplo n.º 1
0
def test_CursorDB_rename_file_is_not_file_exception(data) -> None:
    """Testing CursorDB rename_file method ``FileNotFoundError`` exception. """
    db = CursorDB(data)
    test_p = Path(str(tempfile.tempdir)) / "fffaf"
    with pytest.raises(FileNotFoundError) as excinfo:
        db.rename_file(test_p)
    assert str(excinfo.value) == f"'{test_p}' is not file"
    test_p.unlink(missing_ok=True)

    test_p1 = Path(tempfile.mkdtemp())
    with pytest.raises(FileNotFoundError) as excinfo:
        db.rename_file(test_p1)
    assert str(excinfo.value) == f"'{test_p1}' is not file"
    os.rmdir(test_p1)
Exemplo n.º 2
0
def test_CursorDB_rename_file(data) -> None:
    """Testing CursorDB rename_file method."""
    db = CursorDB(data)

    test_p = Path(str(tempfile.tempdir)) / "fffaf"
    test_p.write_text("test")

    return_p = db.rename_file(test_p)
    assert str(return_p) == str(Path(str(tempfile.tempdir)) / "ffffff")

    test_p.unlink(missing_ok=True)

    test_p1 = Path(str(tempfile.tempdir)) / "aa"
    test_p1.write_text("test")

    return_p = db.rename_file(test_p1)
    assert return_p is None

    test_p1.unlink(missing_ok=True)