Ejemplo n.º 1
0
    def test_given_valid_attr_then_return(self):
        param_dict = dict(one=7, two=23)
        post = Request.Post(self.context,
                            self.response_queue, [""],
                            parameters=param_dict)

        self.assertEqual(param_dict, post.parameters)
Ejemplo n.º 2
0
    def test_Post(self, request_mock):
        endpoint = ["BL18I:XSPRESS3", "configure"]
        post = Request.Post(self.context, self.response_queue, endpoint)

        request_mock.assert_called_once_with(self.context,
                                             self.response_queue,
                                             type_="Post")
Ejemplo n.º 3
0
    def test_given_invalid_attr_then_raise_error(self):
        param_dict = dict(one=7, two=23)
        post = Request.Post(self.context,
                            self.response_queue, [""],
                            parameters=param_dict)

        with self.assertRaises(KeyError):
            post.null
Ejemplo n.º 4
0
    def call_server_method(self, method_name, args):
        """Call method_name on the server

        Args:
            method_name (str): Name of the method
            args (dict): Map of arguments to be called with
        """
        request = Request.Post(None, self.q, [self.block.name, method_name],
                               args)
        self.client_comms.q.put(request)
        response = self.q.get()
        assert response.type_ == response.RETURN, \
            "Expected Return, got %s" % response.type_
        return response.value
Ejemplo n.º 5
0
 def test_hello_controller_with_process(self):
     sync_factory = SyncFactory("sched")
     process = Process("proc", sync_factory)
     block = Block("hello")
     HelloController(block)
     process.add_block(block)
     process.start()
     q = sync_factory.create_queue()
     req = Request.Post(response_queue=q, context="ClientConnection",
                        endpoint=["hello", "say_hello"],
                        parameters=dict(name="thing"))
     req.set_id(44)
     process.q.put(req)
     resp = q.get(timeout=1)
     self.assertEqual(resp.id_, 44)
     self.assertEqual(resp.context, "ClientConnection")
     self.assertEqual(resp.type_, "Return")
     self.assertEqual(resp.value, dict(greeting="Hello thing"))