Ejemplo n.º 1
0
def test_file_read_rb(mounted_fs):
    fh = lfs.file_open(mounted_fs, 'test.txt', 'w')
    lfs.file_write(mounted_fs, fh, b'0123456789')
    lfs.file_close(mounted_fs, fh)

    fh = lfs.file_open(mounted_fs, 'test.txt', 'rb')
    data = lfs.file_read(mounted_fs, fh, 10)
    assert data == b'0123456789'
Ejemplo n.º 2
0
def test_file_open_exist(mounted_fs):
    fh = lfs.file_open(mounted_fs, 'test.txt', 'wb')
    lfs.file_write(mounted_fs, fh, b'0123456789')
    lfs.file_close(mounted_fs, fh)

    with pytest.raises(LittleFSError) as excinfo:
        fh = lfs.file_open(mounted_fs, 'test.txt', 'x')

    assert excinfo.value.code == LittleFSError.Error.LFS_ERR_EXIST
Ejemplo n.º 3
0
def test_stat_file(mounted_fs):
    fh = lfs.file_open(mounted_fs, 'test.txt', 'w')
    lfs.file_write(mounted_fs, fh, b'0123456789')
    lfs.file_close(mounted_fs, fh)

    stat = lfs.stat(mounted_fs, 'test.txt')

    assert stat.size == 10
    assert stat.type == 1
    assert stat.name == 'test.txt'
Ejemplo n.º 4
0
def test_file_open_a(mounted_fs):
    fh = lfs.file_open(mounted_fs, 'test.txt', 'w')
    lfs.file_write(mounted_fs, fh, b'0123456789')
    lfs.file_close(mounted_fs, fh)

    fh = lfs.file_open(mounted_fs, 'test.txt', 'a')
    lfs.file_write(mounted_fs, fh, b'0123456789')
    lfs.file_close(mounted_fs, fh)

    info = lfs.stat(mounted_fs, 'test.txt')
    assert info.size == 20
Ejemplo n.º 5
0
def test_file_write(mounted_fs):
    fh = lfs.file_open(mounted_fs, 'test.txt', 'w')
    lfs.file_write(mounted_fs, fh, b'0123456789')