Esempio n. 1
0
def test_can_write_content_in_tempfile():
    fs = FileSystem()

    temp_file = tempfile.mkstemp()
    bytes = fs.write(temp_file[0], "foo")

    assert bytes == 3
def test_can_write_content_in_tempfile():
    fs = FileSystem()

    temp_file = tempfile.mkstemp()
    bytes = fs.write(temp_file[0], "foo")

    assert bytes == 3
def test_can_create_tempfile():
    fs = FileSystem()

    temp_file = fs.tempfile(ROOT_DIR)

    assert len(temp_file) == 2

    os.remove(temp_file[1])
Esempio n. 4
0
def test_can_create_tempfile():
    fs = FileSystem()

    temp_file = fs.tempfile(ROOT_DIR)

    assert len(temp_file) == 2

    os.remove(temp_file[1])
Esempio n. 5
0
def test_can_remove_dir():
    fs = FileSystem()

    dir_path = join(ROOT_DIR, "some_dir")
    os.mkdir(dir_path)

    fs.rmdir(dir_path)

    assert not exists(dir_path)
def test_can_remove_dir():
    fs = FileSystem()

    dir_path = join(ROOT_DIR, "some_dir")
    os.mkdir(dir_path)

    fs.rmdir(dir_path)

    assert not exists(dir_path)
Esempio n. 7
0
def test_can_create_directory():
    fs = FileSystem()

    path = join(ROOT_DIR, "test")

    fs.makedirs(path)

    assert exists(path)

    os.rmdir(path)
def test_can_create_directory():
    fs = FileSystem()

    path = join(ROOT_DIR, "test")

    fs.makedirs(path)

    assert exists(path)

    os.rmdir(path)
Esempio n. 9
0
def test_can_remove_file():
    fs = FileSystem()

    file_path = join(ROOT_DIR, "some_file")
    f = open(file_path, "w")
    f.write("content")
    f.close()

    fs.remove(file_path)

    assert not exists(file_path)
Esempio n. 10
0
def test_can_close_tempfile():
    fs = FileSystem()

    temp_file = tempfile.mkstemp()
    fs.close(temp_file[0])

    try:
        fs.close(temp_file[0])
        assert False
    except OSError:
        pass
Esempio n. 11
0
def test_can_remove_file():
    fs = FileSystem()

    file_path = join(ROOT_DIR, "some_file")
    f = open(file_path, "w")
    f.write("content")
    f.close()

    fs.remove(file_path)

    assert not exists(file_path)
Esempio n. 12
0
def test_can_rename_file():
    fs = FileSystem()

    file_path = join(ROOT_DIR, "some_file")
    f = open(file_path, "w")
    f.write("content")
    f.close()

    new_file_path = join(ROOT_DIR, "new_file")
    fs.rename(file_path, new_file_path)

    f = open(new_file_path, "r")
    assert f.read() == "content"

    f.close()
Esempio n. 13
0
def test_can_rename_file():
    fs = FileSystem()

    file_path = join(ROOT_DIR, "some_file")
    f = open(file_path, "w")
    f.write("content")
    f.close()

    new_file_path = join(ROOT_DIR, "new_file")
    fs.rename(file_path, new_file_path)

    f = open(new_file_path, "r")
    assert f.read() == "content"

    f.close()
Esempio n. 14
0
def test_can_close_tempfile():
    fs = FileSystem()

    temp_file = tempfile.mkstemp()
    fs.close(temp_file[0])

    try:
        fs.close(temp_file[0])
        assert False
    except OSError:
        pass
Esempio n. 15
0
def test_dirname_returns_last_dir():
    fs = FileSystem()
    assert fs.dirname("/root/test/index.html") == '/root/test'
Esempio n. 16
0
def test_join_returns_rooted_path_when_second_path_is_empty():
    fs = FileSystem()
    assert fs.join("/root", "") == '/root/'
Esempio n. 17
0
def test_join_returns_empty_string_when_null():
    fs = FileSystem()
    assert fs.join() == ''
Esempio n. 18
0
def test_join_two_paths_when_second_is_not_rooted():
    fs = FileSystem()
    assert fs.join("/fake", "dir") == "/fake/dir"
Esempio n. 19
0
def test_join_single_path():
    fs = FileSystem()
    assert fs.join("/fake") == "/fake"
Esempio n. 20
0
def test_join_single_path():
    fs = FileSystem()
    assert fs.join("/fake") == "/fake"
Esempio n. 21
0
def test_join_many_paths():
    fs = FileSystem()
    assert fs.join("/fake", "/dir", "/other") == "/fake/dir/other"
Esempio n. 22
0
def test_directory_not_exists():
    fs = FileSystem()
    assert not fs.exists('/fake/dir')
Esempio n. 23
0
def test_dirname_returns_last_dir():
    fs = FileSystem()
    assert fs.dirname("/root/test/index.html") == '/root/test'
Esempio n. 24
0
def test_join_returns_rooted_path_when_second_path_is_empty():
    fs = FileSystem()
    assert fs.join("/root","") == '/root/'
Esempio n. 25
0
def test_join_returns_empty_string_when_null():
    fs = FileSystem()
    assert fs.join() == ''
Esempio n. 26
0
def test_join_two_paths_when_second_is_virtual():
    fs = FileSystem()
    assert fs.join("/fake", "../dir") == "/fake/../dir"
Esempio n. 27
0
def test_current_directory_exists():
    fs = FileSystem()
    assert fs.exists(ROOT_DIR)
Esempio n. 28
0
def test_directory_not_exists():
    fs = FileSystem()
    assert not fs.exists('/fake/dir')
Esempio n. 29
0
def test_can_create_filesystem():
    fs = FileSystem()

    assert fs
    assert isinstance(fs, FileSystem)
Esempio n. 30
0
def test_join_many_paths():
    fs = FileSystem()
    assert fs.join("/fake", "/dir", "/other") == "/fake/dir/other"
Esempio n. 31
0
def test_join_two_paths():
    fs = FileSystem()
    assert fs.join("/fake", "/dir") == "/fake/dir"
Esempio n. 32
0
def test_join_two_paths_when_second_is_not_rooted():
    fs = FileSystem()
    assert fs.join("/fake", "dir") == "/fake/dir"
Esempio n. 33
0
def test_join_two_paths_when_second_is_virtual():
    fs = FileSystem()
    assert fs.join("/fake", "../dir") == "/fake/../dir"
Esempio n. 34
0
def test_current_directory_exists():
    fs = FileSystem()
    assert fs.exists(ROOT_DIR)
Esempio n. 35
0
def test_join_two_paths():
    fs = FileSystem()
    assert fs.join("/fake", "/dir") == "/fake/dir"