Esempio n. 1
0
    def __set(self, updates):
        req = proto.Application()
        req.app_id = self.app_id

        if "payload_format" in updates:
            req.payload_format = updates["payload_format"]

        if "register_on_join_access_key" in updates:
            req.register_on_join_access_key = updates[("register_on_"
                                                       "join_access_key")]

        if "decoder" in updates:
            req.decoder = updates["decoder"]

        if "converter" in updates:
            req.converter = updates["converter"]

        if "encoder" in updates:
            req.encoder = updates["encoder"]

        if "validator" in updates:
            req.validator = updates["validator"]

        meta = self.__create_metadata()
        try:
            return self.client.SetApplication(req, TIME_OUT, meta)
        except grpc.RpcError as err:
            raise RuntimeError("Error while updating the",
                               " application: {}".format(err.code().name))
Esempio n. 2
0
 def __init__(self):
     self.application = proto.Application()
     self.applicationIdentifier = proto.ApplicationIdentifier()
     self.device = proto.Device()
     self.deviceIdentifier = proto.DeviceIdentifier()
     self.deviceList = proto.DeviceList()
     self.err = None
    def test_payload_format(self):
        self.mock.reset()
        self.mock.application = handler.Application()
        self.mock.application.payload_format = "custom"
        res = self.manager.get()
        assert res["application"].payload_format == "custom"

        self.manager.set_payload_format("other")
        assert self.mock.application.payload_format == "other"
    def test_custom_payload(self):
        self.mock.reset()
        self.mock.application = handler.Application()
        self.mock.application.payload_format = "custom"
        self.mock.application.decoder = "decoder"
        self.mock.application.converter = "converter"
        self.mock.application.validator = "validator"
        self.mock.application.encoder = "encoder"
        res = self.manager.get()
        assert res["application"].payload_format == "custom" and \
            res["application"].validator =="validator" and \
                res["application"].decoder =="decoder"

        self.manager.set_custom_payload_functions(validator="nvalidator",
                                                  decoder="ndecoder")
        res = self.manager.get()
        assert res["application"].payload_format == "custom" and \
            res["application"].validator =="nvalidator" and \
                res["application"].decoder =="ndecoder"
 def test_get(self):
     self.mock.reset()
     self.mock.application = handler.Application()
     self.mock.application.app_id = "test"
     res = self.manager.get()
     assert res["application"].app_id == "test"