- Python Falcon - Discussion
- Python Falcon - Useful Resources
- Python Falcon - Quick Guide
- Python Falcon - Deployment
- Python Falcon - Testing
- Python Falcon - Sqlalchemy Models
- Python Falcon - Websocket
- Python Falcon - CORS
- Python Falcon - Middleware
- Python Falcon - Hooks
- Python Falcon - Error Handling
- Python Falcon - Status Codes
- Python Falcon - Cookies
- Python Falcon - Jinja2 Template
- Python Falcon - Inspect Module
- Falcon - Suffixed Responders
- Python Falcon - Routing
- Python Falcon - App Class
- Python Falcon - Resource Class
- Request & Response
- Python Falcon - API Testing Tools
- Python Falcon - Uvicorn
- Python Falcon - ASGI
- Python Falcon - Waitress
- Python Falcon - Hello World(WSGI)
- Python Falcon - WSGI vs ASGI
- Python Falcon - Environment Setup
- Python Falcon - Introduction
- Python Falcon - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Python Falcon - API Testing Tools
Falcon is a minimapstic framework suitable for developing APIs. An API is an interface between two apppcations. The API developer needs to test its functionapty, repabipty, stabipty, scalabipty, and performance etc. before releasing it for use in production environment.
Various API testing tools are available for this purpose. In this section, we shall learn how to use command pne tools Curl and HTTPie, and a GUI tool called Postman.
cURL
cURL is an open source project that provides pbcurl pbrary and a command pne tool called curl that enables transferring data using various protocols. More than 20 protocols including HTTP are supported. The acronym cURL stands for Cpent URL. The syntax for using Curl from command pne is −
curl [options] [URL1, URL2,..]
The URL parameter consists of protocol dependent, one or more URL strings. The Curl command can be customized with various options. Some of the important command pne options are as follows −
– X: Mention the request method. By default, Curl assumes GET to be the request method. To send POST, PUT or DELTETE requests, this option must be used. For example −
Curl –X DELETE http://localhost:8000/student/1
– H: This option is used to add headers in the request. For example −
Curl –H "Content-Type: apppcation/json" -X GET http://localhost:8000/students
– i: When this option is included in the command pne, all the response headers are displayed. For example −
Curl –I –X DELETE http://localhost:8000/student/2
– d: To include data in the HTTP request for processing, we have to use this option, particularly when POST or PUT request is needed.
Curl –H "Content-Type: apppcation/json" -X PUT -d "{"""marks""":"""50"""}" http://localhost:8000/students/3
HTTPie
The HTTPie is a command pne tool written in Python. It is said to be a "cURLpke tool for humans". It supports forms and file uploads and generates nicely formatted colorized terminal output. Its expressive and intuitive syntax makes it easier to use as compared to Curl.
Examples
GET request − http GET localhost:8000/students
POST request − http POST localhost:8000/students id=4 name="aaa" percent=50
PUT request − http PUT localhost:8000/students/2 id=3 name="Mathews" percent=55
DEETE request − http DELETE localhost:8000/students/2
Postman
Postman is a very popular API testing tool. It is a GUI app as against Curl and HTTPie. It is available in the form of a browser plugin as well as a desktop apppcation. As the browser plugin doesn t accept requests for localhost based APIs, we need to download the desktop version from
After completing the wizard based installation, start the Postman app and create a new request.
The dropdown shows various HTTP request types to choose from.
Enter http://localhost:8000/hello in the request URL field. The response pane on the right shows the result.
We shall use the corresponding request types later when we test the Falcon API for CRUD operations on a SQLite database.
Advertisements