Exemple #1
0
def test_rm(backend):
    c = Client(connection=backend())
    c.mkdir(b"/foo/bar")
    c.rm(b"/foo/bar")

    with pytest.raises(PyXSError):
        c.read(b"/foo/bar")

    c.read(b"/foo/bar", b"baz") == b"baz"  # using a default option.

    assert c.read(b"/foo") == b""
Exemple #2
0
def test_client_read(backend):
    c = Client(connection=backend())

    # a) non-existant path.
    try:
        c.read(b"/foo/bar")
    except PyXSError as e:
        assert e.args[0] == errno.ENOENT

    # b) OK-case (`/local` is allways in place).
    assert c.read("/local") == b""
    assert c["/local"] == b""
Exemple #3
0
def test_client_read():
    for backend in [UnixSocketConnection, XenBusConnection]:
        c = Client(connection=backend())

        # a) non-existant path.
        try:
            c.read("/foo/bar")
        except PyXSError as e:
            assert e.args[0] is errno.ENOENT

        # b) OK-case (`/local` is allways in place).
        assert c.read("/local") == ""
        assert c["/local"] == ""
Exemple #4
0
def test_client_read():
    for backend in [UnixSocketConnection, XenBusConnection]:
        c = Client(connection=backend())

        # a) non-existant path.
        try:
            c.read("/foo/bar")
        except PyXSError as e:
            assert e.args[0] is errno.ENOENT

        # b) OK-case (`/local` is allways in place).
        assert c.read("/local") == ""
        assert c["/local"] == ""
Exemple #5
0
def test_rm():
    for backend in [UnixSocketConnection, XenBusConnection]:
        c = Client(connection=backend())
        c.mkdir("/foo/bar")

        try:
            c.rm("/foo/bar")
        except PyXSError as e:
            pytest.fail("No error should've been raised, got: {0}".format(e))

        with pytest.raises(PyXSError):
            c.read("/foo/bar")

        assert c.read("/foo") == ""
Exemple #6
0
def test_mkdir():
    for backend in [UnixSocketConnection, XenBusConnection]:
        c = Client(connection=backend())

        c.mkdir("/foo/bar")
        assert c.ls("/foo") == ["bar"]
        assert c.read("/foo/bar") == ""
Exemple #7
0
def test_mkdir():
    for backend in [UnixSocketConnection, XenBusConnection]:
        c = Client(connection=backend())

        c.mkdir("/foo/bar")
        assert c.ls("/foo") == ["bar"]
        assert c.read("/foo/bar") == ""
Exemple #8
0
def test_write(backend):
    c = Client(connection=backend())

    c.write(b"/foo/bar", b"baz")
    assert c.read(b"/foo/bar") == b"baz"

    c[b"/foo/bar"] = b"boo"
    assert c[b"/foo/bar"] == b"boo"
Exemple #9
0
def test_write():
    for backend in [UnixSocketConnection, XenBusConnection]:
        c = Client(connection=backend())

        c.write("/foo/bar", "baz")
        assert c.read("/foo/bar") == "baz"

        c["/foo/bar"] = "boo"
        assert c["/foo/bar"] == "boo"
Exemple #10
0
def test_write():
    for backend in [UnixSocketConnection, XenBusConnection]:
        c = Client(connection=backend())

        c.write("/foo/bar", "baz")
        assert c.read("/foo/bar") == "baz"

        c["/foo/bar"] = "boo"
        assert c["/foo/bar"] == "boo"
Exemple #11
0
def test_rm():
    for backend in [UnixSocketConnection, XenBusConnection]:
        c = Client(connection=backend())
        c.mkdir("/foo/bar")

        try:
            c.rm("/foo/bar")
        except PyXSError as e:
            pytest.fail("No error should've been raised, got: {0}"
                        .format(e))

        with pytest.raises(PyXSError):
            c.read("/foo/bar")

        try:
            c.read("/foo/bar", "baz") == "baz"  # using a default option.
        except PyXSError:
            pytest.fail("No error should've been raised, got: {0}"
                        .format(e))

        assert c.read("/foo") == ""
Exemple #12
0
def test_mkdir(backend):
    c = Client(connection=backend())

    c.mkdir(b"/foo/bar")
    assert c.ls(b"/foo") == [b"bar"]
    assert c.read(b"/foo/bar") == b""