def test_actor_and_port_functions(self):
        self.q = Queue.Queue()

        def cb(key, value):
            self.q.put({"key": key, "value": value})

        port1 = TestPort("out", "out")
        port2 = TestPort("in", "in", )

        port1.peers = [("local", port2.id)]
        port2.peer = ("local", port1.id)

        actor1 = TestActor("actor1", "type1", {}, {port1.name: port1})
        actor2 = TestActor("actor2", "type2", {port2.name: port2}, {})

        self.storage.add_actor(actor1, calvinuuid.uuid("NODE"))
        value = self.storage.get_actor(actor1.id, cb=CalvinCB(func=cb))
        value = self.q.get(timeout=0.2)
        assert value["key"] == actor1.id and value[
            "value"]["name"] == actor1.name

        assert value["value"]["name"] == actor1.name
        assert value["value"]["type"] == actor1._type
        assert value["value"]["inports"] == []
        assert value["value"]["outports"][0]["id"] == port1.id

        value = self.storage.get_port(port1.id, cb=CalvinCB(func=cb))
        value = self.q.get(timeout=0.2)
        assert value["key"] == port1.id
        assert value["value"]["name"] == port1.name
        assert value["value"]["direction"] == port1.direction
        assert value["value"]["peers"] == [["local", port2.id]]

        self.storage.add_actor(actor2, calvinuuid.uuid("NODE"))
        value = self.storage.get_actor(actor2.id, cb=CalvinCB(func=cb))
        value = self.q.get(timeout=0.2)
        assert value["key"] == actor2.id
        assert value["value"]["name"] == actor2.name
        assert value["value"]["type"] == actor2._type
        assert value["value"]["inports"][0]["id"] == port2.id
        assert value["value"]["outports"] == []

        value = self.storage.get_port(port2.id, cb=CalvinCB(func=cb))
        value = self.q.get(timeout=0.2)
        assert value["key"] == port2.id
        assert value["value"]["name"] == port2.name
        assert value["value"]["direction"] == port2.direction
        assert value["value"]["peer"] == ["local", port1.id]

        self.storage.delete_actor(actor1.id, cb=CalvinCB(func=cb))
        value = self.q.get(timeout=0.2)
        assert value
        assert actor1.id not in self.storage.localstore

        self.storage.delete_port(port1.id, cb=CalvinCB(func=cb))
        value = self.q.get(timeout=0.2)
        assert value
        assert port1.id not in self.storage.localstore
dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/runtime/north/tests/test_storage.py/TestStorageNotStarted.test_actor_and_port_functions/original