Esempio n. 1
0
 def test_parse_query_parameters_all_values_weird_syntax(self):
     input_dict = {
         "q": "banana",
         "transaction_type": "bananatype",
         "id_only": "faLSe",
         "sort_by": "timestamp",
         "sort_asc": "tRuE",
         "limit": "111",
         "offset": "15",
         "verbatim": "fALsE",
     }
     output = helpers.parse_query_parameters(input_dict)
     self.assertEqual(
         output,
         {
             "q": "banana",
             "transaction_type": "bananatype",
             "id_only": False,
             "sort_by": "timestamp",
             "sort_asc": True,
             "limit": 111,
             "offset": 15,
             "verbatim": False,
         },
     )
Esempio n. 2
0
def query_transaction_v1() -> Tuple[str, int, Dict[str, str]]:
    params = helpers.parse_query_parameters(flask.request.args.to_dict())
    if params.get("transaction_type"):
        should_parse = flask.request.headers.get("Parse-Payload") != "false"
        return helpers.flask_http_response(
            200, transactions.query_transactions_v1(params, should_parse))
    raise exceptions.ValidationException(
        "User input must specify transaction type to query")
Esempio n. 3
0
 def test_parse_query_parameters_min_values(self):
     input_dict = {"q": "banana"}
     output = helpers.parse_query_parameters(input_dict)
     self.assertEqual(
         output, {
             "q": "banana",
             "id_only": False,
             "limit": 10,
             "offset": 0,
             "verbatim": False
         })
Esempio n. 4
0
 def test_parse_query_parameters_extrapolates_sort_asc(self):
     input_dict = {"q": "banana", "sort_by": "fruit"}
     output = helpers.parse_query_parameters(input_dict)
     self.assertEqual(
         output, {
             "q": "banana",
             "id_only": False,
             "limit": 10,
             "offset": 0,
             "sort_by": "fruit",
             "sort_asc": True,
             "verbatim": False
         })
Esempio n. 5
0
def query_blocks_v1(
        block_id: Optional[str] = None) -> Tuple[str, int, Dict[str, str]]:
    params = helpers.parse_query_parameters(flask.request.args.to_dict())
    should_parse = bool(flask.request.headers.get("Parse-Payload"))
    return helpers.flask_http_response(
        200, blocks.query_blocks_v1(params, should_parse))