def register_transaction_type_v1() -> Tuple[str, int, Dict[str, str]]: if not flask.request.is_json: raise exceptions.BadRequest("Could not parse JSON") content = flask.request.json try: _validate_create_txn_type_v1(content) except fastjsonschema.JsonSchemaException: raise exceptions.ValidationException("User input did not match JSON schema") transaction_types.register_transaction_type_v1(content) return helpers.flask_http_response(200, helpers.format_success(True))
def register_transaction_type_v1(**kwargs) -> Tuple[str, int, Dict[str, str]]: if not flask.request.is_json: raise exceptions.BadRequest("Could not parse JSON") content = flask.request.json try: _validate_create_txn_type_v1(content) if content.get("custom_indexes"): helpers.verify_custom_indexes_options(content["custom_indexes"]) except fastjsonschema.JsonSchemaException as e: raise exceptions.ValidationException(str(e)) transaction_types.register_transaction_type_v1(content) return helpers.flask_http_response(200, helpers.format_success(True))
def test_register_txn_type_succeeds(self, mock_get_registered_type, mock_queue): txn_type_struct = {"version": "2", "txn_type": "random"} transaction_types.register_transaction_type_v1(txn_type_struct) mock_get_registered_type.assert_called_once() mock_queue.assert_called_once()