A sample App using flask and redis
- Clone the repository and move to flask-redis folder
- Create a .env file and copy-paste below credentials:
REDIS_HOST=redis
REDIS_PORT=6379brew install redisIf homebrew is not installed, then go to https://brew.sh/ and install it.
git clone https://github.com/keploy/samples-typescript && cd samples-typescript/flask-redis
# Install the dependencies
pip3 install -r requirements.txtLet's get started by setting up the Keploy alias with this command:
source /dev/stdin <<<"$(curl -fsSL https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh || echo 'echo Keploy installer download failed >&2; return 1')"There are 2 ways you can run this sample application.
Note: You no longer need to download a
ca.crtor runsetup_ca.sh. Keploy generates its MITM CA per run and sets the trust environment variables for the app it launches automatically. (The oldpkg/core/proxy/asset/URLs are retired.)
- Start the redis server:
This command starts the redis server.
redis-server
- Start recording tests:
sudo -E env "PATH=$PATH" keploybin record -c 'python3 app.py'
Make API Calls using Hoppscotch, Postman or cURL command. Keploy will capture those calls to generate test suites containing test cases and data mocks.
-
Refer to flask-redis/api.txt to make api calls.
-
Observe terminal output: Let's go ahead and create a few more test cases for different endpoints!
-
Start the application:
python3 app.py
-
Run the recorded tests:
sudo -E env "PATH=$PATH" keploybin test -c 'python3 app.py' --delay 10
-
Observe test run results: Voila!! Our test cases have passed 🌟
Since we have to setup our app using docker(make sure your docker is running)
docker network create keploy-networkWe will run the keploy in record mode with docker-compose to start our application:-
keploy record -c "sudo docker-compose up" --containerName "flask-web"
Make API Calls using Hoppscotch, Postman or curl command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks.
- Refer to flask-redis/api.txt to make api calls
keploy test -c 'sudo docker-compose up' --containerName "flask-web" --delay 10Voila!! Our testcases has passed 🌟