Ejemplo n.º 1
0
    def test_insert_secret_with_multicall2(self):
        # create client with secret
        secret = "hello"
        client = Client(secret=secret)

        responses.add_callback(responses.POST,
                               client.server,
                               callback=self.call_params_callback)

        # create params
        params_1 = ["2089b05ecca3d829"]
        params_2 = ["2fa07b6e85c40205"]
        calls = [(client.REMOVE, params_1), (client.REMOVE, params_2)]
        # copy params and insert secret
        expected_params = [[
            {
                "methodName": client.REMOVE,
                "params": deepcopy(params_1)
            },
            {
                "methodName": client.REMOVE,
                "params": deepcopy(params_2)
            },
        ]]
        for param in expected_params[0]:
            param["params"].insert(0, f"token:{secret}")

        # call function and assert result
        resp = client.multicall2(calls, insert_secret=True)
        assert resp == expected_params
Ejemplo n.º 2
0
    def test_multicall2(self):
        client = Client()

        responses.add_callback(responses.POST,
                               client.server,
                               callback=self.call_params_callback)

        # create params
        params_1 = ["2089b05ecca3d829"]
        params_2 = ["2fa07b6e85c40205"]
        calls = [(client.REMOVE, params_1), (client.REMOVE, params_2)]
        # copy params and insert secret
        expected_params = [[
            {
                "methodName": client.REMOVE,
                "params": deepcopy(params_1)
            },
            {
                "methodName": client.REMOVE,
                "params": deepcopy(params_2)
            },
        ]]

        # call function and assert result
        resp = client.multicall2(calls)
        assert resp == expected_params