Пример #1
0
def test_insert_non_node():
    root = Node()

    b = NonNode()

    root.set("/a/b", b)

    assert root.a.b is b
    assert root.get("/a/b") is b
Пример #2
0
def test_inherited_node():
    root = Node()

    c = Node()
    d = Node({"/e": Node()})

    root.set("/a/b/c", c)
    root.set("/a/b/c/d", d)

    assert root.a.b.c.d.has("/e")
Пример #3
0
def test_child_set():
    root = Node()

    a = Node()
    b = Node()

    root.set("/a", a)
    root.set("/a/b", b)

    assert root.a is a
    assert root.get("/a") is a
    assert root.a.b is b
    assert root.get("/a/b") is b
    assert root.a.get("/b") is b
Пример #4
0
    async def create(cls, connection, service):
        remote_objs = Node()
        client_objs = dict()

        for obj_path, service_obj in service.items():
            # Collect the remote object
            remote_obj = await connection.getRemoteObject(
                service.namespace, obj_path)

            remote_objs.set(obj_path, remote_obj)

            # Generate and attach the client object
            obj = Object(remote_obj, service_obj)

            client_objs[obj_path] = obj

            def bind(obj):
                async def proxy_fn(*args):
                    return await obj.call(method_name, *args)

                return proxy_fn

            # Add the shim functions for each method
            for method_name in service_obj.methods.keys():
                client_method = client_method_factory(obj, method_name)
                setattr(obj, method_name, client_method)

            # Signals
            for event_name, xform in service_obj.signals.items():
                remote_obj.notifyOnSignal(
                    event_name, client_emitter_factory(obj, event_name, xform))

            remote_obj.notifyOnSignal("PropertiesChanged",
                                      changed_properties_emitter_factory(obj))

        client = Client(service, remote_objs)

        for path, obj in client_objs.items():
            client.set(path, obj)

        return client
Пример #5
0
def test_parallel_set():
    root = Node()

    a = Node()
    b = Node()

    root.set("/a", a)
    root.set("/b", b)

    assert root.a is a
    assert root.get("/a") is a

    assert root.b is b
    assert root.get("/b") is b
Пример #6
0
def test_simple_set():
    root = Node()

    a = Node()

    root.set("/a", a)

    assert root.a is a
    assert root.get("/a") is a
Пример #7
0
def test_sparse_set():
    root = Node()

    c = Node()

    root.set("/a/b/c", c)

    assert root.a.b.c is c

    assert root.get("/a").b.c is c
    assert root.get("/a/b").c is c

    assert root.a.get("/b").c is c
    assert root.a.get("/b/c") is c

    assert root.a.b.get("/c") is c
Пример #8
0
def test_replaced_node():
    root = Node()

    a = Node()
    b = Node()
    c = Node()
    b_prime = Node()

    root.set("/a", a)
    root.a.set("/b", b)
    root.a.b.set("/c", c)

    root.set("/a/b", b_prime)

    assert root.a is a
    assert root.get("/a") is a
    assert root.a.b is b_prime
    assert root.a.get("/b") is b_prime
    assert root.get("/a/b") is b_prime
    assert root.a.b.c is c
    assert root.a.b.get("/c") is c
    assert root.a.get("/b/c") is c
    assert root.get("/a/b/c") is c
Пример #9
0
 def __init__(self, service_obj, dbus_obj):
     Node.__init__(self)
     EventEmitter.__init__(self)
     self.service_obj = service_obj
     self.iface = service_obj.iface
     self.dbus_obj = dbus_obj