Exemple #1
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 #2
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 #3
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 #4
0
def test_watches(backend):
    c = Client(connection=backend())
    c.write(b"/foo/bar", b"baz")
    m = c.monitor()
    m.watch(b"/foo/bar", b"boo")

    # a) we receive the first event immediately, so `wait()` doesn't
    #    block.
    assert m.wait() == (b"/foo/bar", b"boo")

    # b) before the second call we have to make sure someone
    #    will change the path being watched.
    Timer(.5, lambda: c.write(b"/foo/bar", b"baz")).run()
    assert m.wait() == (b"/foo/bar", b"boo")

    # c) changing a children of the watched path triggers watch
    #    event as well.
    Timer(.5, lambda: c.write(b"/foo/bar/baz", b"???")).run()
    assert m.wait() == (b"/foo/bar/baz", b"boo")
Exemple #5
0
def test_watches():
    for backend in [UnixSocketConnection, XenBusConnection]:
        c = Client(connection=backend())
        c.write("/foo/bar", "baz")
        m = c.monitor()
        m.watch("/foo/bar", "boo")

        # a) we receive the first event immediately, so `wait()` doesn't
        #    block.
        assert m.wait() == ("/foo/bar", "boo")

        # b) before the second call we have to make sure someone
        #    will change the path being watched.
        Timer(.5, lambda: c.write("/foo/bar", "baz")).run()
        assert m.wait() == ("/foo/bar", "boo")

        # c) changing a children of the watched path triggers watch
        #    event as well.
        Timer(.5, lambda: c.write("/foo/bar/baz", "???")).run()
        assert m.wait() == ("/foo/bar/baz", "boo")