From 23c2f54bebb6e94147833a4d81afa54ebf91114d Mon Sep 17 00:00:00 2001 From: Samyabrata Maji Date: Mon, 22 Jul 2024 20:11:35 +0530 Subject: [PATCH] feat: fastapi + redis sample app Signed-off-by: Samyabrata Maji --- flask-redis/.dockerignore | 28 + flask-redis/.gitignore | 3 + flask-redis/Dockerfile | 41 + flask-redis/README.md | 102 ++ flask-redis/app.py | 81 ++ flask-redis/docker-compose.yaml | 8 + flask-redis/gunicorn_config.py | 9 + flask-redis/keploy.yml | 43 + .../reports/test-run-0/test-set-0-report.yaml | 871 ++++++++++++++++++ flask-redis/keploy/test-set-0/mocks.yaml | 246 +++++ .../keploy/test-set-0/tests/test-1.yaml | 63 ++ .../keploy/test-set-0/tests/test-2.yaml | 60 ++ .../keploy/test-set-0/tests/test-3.yaml | 61 ++ .../keploy/test-set-0/tests/test-4.yaml | 58 ++ .../keploy/test-set-0/tests/test-5.yaml | 58 ++ .../keploy/test-set-0/tests/test-6.yaml | 58 ++ .../keploy/test-set-0/tests/test-7.yaml | 58 ++ .../keploy/test-set-0/tests/test-8.yaml | 47 + flask-redis/requirements.txt | 13 + flask-redis/schema.py | 11 + 20 files changed, 1919 insertions(+) create mode 100644 flask-redis/.dockerignore create mode 100644 flask-redis/.gitignore create mode 100644 flask-redis/Dockerfile create mode 100644 flask-redis/README.md create mode 100644 flask-redis/app.py create mode 100644 flask-redis/docker-compose.yaml create mode 100644 flask-redis/gunicorn_config.py create mode 100755 flask-redis/keploy.yml create mode 100755 flask-redis/keploy/reports/test-run-0/test-set-0-report.yaml create mode 100755 flask-redis/keploy/test-set-0/mocks.yaml create mode 100755 flask-redis/keploy/test-set-0/tests/test-1.yaml create mode 100755 flask-redis/keploy/test-set-0/tests/test-2.yaml create mode 100755 flask-redis/keploy/test-set-0/tests/test-3.yaml create mode 100755 flask-redis/keploy/test-set-0/tests/test-4.yaml create mode 100755 flask-redis/keploy/test-set-0/tests/test-5.yaml create mode 100755 flask-redis/keploy/test-set-0/tests/test-6.yaml create mode 100755 flask-redis/keploy/test-set-0/tests/test-7.yaml create mode 100755 flask-redis/keploy/test-set-0/tests/test-8.yaml create mode 100644 flask-redis/requirements.txt create mode 100644 flask-redis/schema.py diff --git a/flask-redis/.dockerignore b/flask-redis/.dockerignore new file mode 100644 index 0000000..74d84bb --- /dev/null +++ b/flask-redis/.dockerignore @@ -0,0 +1,28 @@ +**/.DS_Store +**/__pycache__ +**/.venv +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md diff --git a/flask-redis/.gitignore b/flask-redis/.gitignore new file mode 100644 index 0000000..2ebeef0 --- /dev/null +++ b/flask-redis/.gitignore @@ -0,0 +1,3 @@ +venv + +*.pyc \ No newline at end of file diff --git a/flask-redis/Dockerfile b/flask-redis/Dockerfile new file mode 100644 index 0000000..3aecc34 --- /dev/null +++ b/flask-redis/Dockerfile @@ -0,0 +1,41 @@ +# syntax=docker/dockerfile:1 + +ARG PYTHON_VERSION=3.10.12 +FROM python:${PYTHON_VERSION}-slim as base + +# Prevents Python from writing pyc files. +ENV PYTHONDONTWRITEBYTECODE=1 + +# Keeps Python from buffering stdout and stderr to avoid situations where +# the application crashes without emitting any logs due to buffering. +ENV PYTHONUNBUFFERED=1 + +WORKDIR /app + +# Create a non-privileged user that the app will run under. +# See https://docs.docker.com/go/dockerfile-user-best-practices/ +ARG UID=10001 +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/nonexistent" \ + --shell "/sbin/nologin" \ + --no-create-home \ + --uid "${UID}" \ + appuser + +# Download dependencies as a separate step to take advantage of Docker's caching. +# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds. +# Leverage a bind mount to requirements.txt to avoid having to copy them into +# into this layer. +RUN --mount=type=cache,target=/root/.cache/pip \ + --mount=type=bind,source=requirements.txt,target=requirements.txt \ + python -m pip install -r requirements.txt + +# Switch to the non-privileged user to run the application. +USER appuser + +COPY . . +EXPOSE 3000 +ENTRYPOINT ["gunicorn"] +CMD ["--config", "gunicorn_config.py", "app:app"] diff --git a/flask-redis/README.md b/flask-redis/README.md new file mode 100644 index 0000000..9866f5f --- /dev/null +++ b/flask-redis/README.md @@ -0,0 +1,102 @@ +# Keploy + +## Introduction +This is a simple to-do application built using Python's Flask Framework and Redis. It supports all CRUD operations on the to-do items through a RESTful API. + +Here's all the supported endpoints. +Sure, here's the information organized into a markdown table, including the payload details: + +## API Endpoints + +| Method | Endpoint | Payload | Description | +|---|---|---|---| +| GET | / | None | Check the status of the application. | +| GET | /todos | None | Gets all to-dos. | +| GET | /todos/{id} | None | Gets the to-do with the specified id. | +| POST | /todos | `{ "title": "required, "description": "optional" }` | Creates a new to-do. | +| PUT | /todos/{id} | `{ "title": "optional", "description": "optional" }` | Updates the to-do with the given id. Throws error if it does not exist. | +| DELETE | /todos/{id} | None | Deletes the to-do with the given id. | + +## Setup Without Docker + +First install the dependencies. + +```bash +git clone https://github.com/keploy/samples-python.git && cd samples-python/flask-redis +pip3 install -r requirements.txt +``` + +To run the application, use the following command. + +```bash +gunicorn --config gunicorn_config.py app:app +``` + +This will start your server at `https://localhost:3000`. + +## Setup With Docker + +If you docker installed, simply run `docker compose up` and it will start your server. + +Make sure you have provided all the environment variables in `.env` file. + +Head over to `https://localhost:3000` in your browser to check if everything is working. + +## Install Keploy + +Keploy can be installed on Linux directly. If you're on windows, you would need Windows Subsystem For Linux (WSL). Based on your system architecture, install the keploy latest binary release. Read more about it [here](https://keploy.io/docs/server/installation/). + +### For Linux, MacOS and WSL +Create a bridge network in Docker using the following docker network create command. +```bash +docker network create keploy-network +``` + +Run the following command to start the Keploy container. +```bash +alias keploy="docker run --name keploy-v2 -p 16789:16789 --network keploy-network --privileged --pid=host -v $(pwd):$(pwd) -w $(pwd) -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/keploy/keploy" +``` + +## Recording API Calls + +Run the following command to start recording your API calls. + +```bash +keploy record -c "gunicorn --config gunicorn_config.py app:app" +``` + +If you're using docker then use this command. +```bash +keploy record -c "docker compose up" +``` + +Now, you can start making API calls using your preferred client like curl or postman. Keploy will record these calls and generate test-cases and mocks from these API calls. + +Let's make some sample API requests. + +```bash +curl --location 'http://127.0.0.1:3000/todos/' \ +--header 'Content-Type: application/json' \ +--data-raw ' { + "title": "Example TODO 01", + "description": "An Example TODO", + }' +``` +```bash +curl --location 'http://127.0.0.1:3000/todos/' \ +--header 'Content-Type: application/json' \ +--data-raw ' { + "title": "Example TODO 02" + }' +``` +```bash +curl --location 'http://127.0.0.1:8000/todos/' +``` +Make some more requests like PUT, DELETE, etc. + +## Replay Recorded Testcases +Once you're done, you can replay the test cases using the following commands. + +```bash +keploy test -c "gunicorn --config gunicorn_config.py app:app" --delay 20 +``` \ No newline at end of file diff --git a/flask-redis/app.py b/flask-redis/app.py new file mode 100644 index 0000000..c85ee1e --- /dev/null +++ b/flask-redis/app.py @@ -0,0 +1,81 @@ +from flask import Flask, request, jsonify +from marshmallow import ValidationError +from nanoid import generate +import redis +import json +from schema import CreateTodoSchema, UpdateTodoSchema + +app = Flask(__name__) + +db = redis.Redis( + host='localhost', + port=6379, + decode_responses=True +) + +@app.route('/') +def get_status(): + return jsonify({ "status": "ok" }) + + +@app.route("/todos", methods=["GET"]) +def get_todos(): + keys = db.keys() + json_data = [] + for key in keys: + data = db.get(key) + json_data.append({"id": key, **json.loads(data)}) + return jsonify(json_data), 200 + + + +@app.route("/todos/", methods=["GET"]) +def get_todo(id: str): + data = db.get(id) + if data is None: + return jsonify({"message": "Data not found."}), 404 + + json_data = {"id": id, **json.loads(data)} + return jsonify(json_data), 200 + + +@app.route("/todos/", methods=["POST"]) +def create_todos(): + id = generate(size=6) + schema = CreateTodoSchema() + try: + body = schema.load(request.json) + except ValidationError as error: + return jsonify({"errors": error.messages}), 422 + db.set(id, json.dumps(body)) + return jsonify({"success": True, "data": {"id": id, **body}}), 200 + + +@app.route("/todos/", methods=["PUT"]) +def update_todos(id: str): + data = db.get(id) + if data is None: + return jsonify({ "message": "No todo found." }), 404 + + json_data = json.loads(data) + schema = UpdateTodoSchema() + try: + body = schema.load(request.json) + except ValidationError as error: + return jsonify({"errors": error.messages}), 422 + + for key, value in body.items(): + if value is not None: + json_data[key] = value + + db.set(id, json.dumps(json_data)) + json_data = {"id": id, **json_data} + return jsonify(json_data), 200 + + +@app.route("/todos/", methods=["DELETE"]) +def delete_todo(id: str): + status = db.delete(id) + if not status: + return jsonify({ "message" : "Deletion failed.", status: 0 }), 400 + return jsonify({"success": True}), 200 \ No newline at end of file diff --git a/flask-redis/docker-compose.yaml b/flask-redis/docker-compose.yaml new file mode 100644 index 0000000..c712ec7 --- /dev/null +++ b/flask-redis/docker-compose.yaml @@ -0,0 +1,8 @@ +services: + server: + build: + context: . + image: flask-redis-sample-app:latest + ports: + - 3000:3000 + diff --git a/flask-redis/gunicorn_config.py b/flask-redis/gunicorn_config.py new file mode 100644 index 0000000..89a1e1c --- /dev/null +++ b/flask-redis/gunicorn_config.py @@ -0,0 +1,9 @@ +import os + + +workers = int(os.environ.get('GUNICORN_PROCESSES', '2')) +threads = int(os.environ.get('GUNICORN_THREADS', '4')) +timeout = int(os.environ.get('GUNICORN_TIMEOUT', '120')) +bind = os.environ.get('GUNICORN_BIND', '0.0.0.0:3000') +forwarded_allow_ips = '*' +secure_scheme_headers = { 'X-Forwarded-Proto': 'https' } \ No newline at end of file diff --git a/flask-redis/keploy.yml b/flask-redis/keploy.yml new file mode 100755 index 0000000..db66331 --- /dev/null +++ b/flask-redis/keploy.yml @@ -0,0 +1,43 @@ +path: "" +appId: 0 +appName: "" +command: docker compose up +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: "" +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + test-sets: {} + delay: 5 + apiTimeout: 5 + skipCoverage: false + coverageReportPath: "" + ignoreOrdering: true + mongoPassword: default@123 + language: "" + removeUnusedMocks: false + fallBackOnMiss: false + jacocoAgentPath: "" + basePath: "" + mocking: true + ignoredTests: {} +record: + filters: [] + recordTimer: 0s +configPath: "" +bypassRules: [] +generateGithubActions: true +keployContainer: keploy-v2 +keployNetwork: keploy-network +cmdType: native +inCi: false + +# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file. diff --git a/flask-redis/keploy/reports/test-run-0/test-set-0-report.yaml b/flask-redis/keploy/reports/test-run-0/test-set-0-report.yaml new file mode 100755 index 0000000..b4b1f63 --- /dev/null +++ b/flask-redis/keploy/reports/test-run-0/test-set-0-report.yaml @@ -0,0 +1,871 @@ +version: api.keploy.io/v1beta1 +name: test-set-0-report +status: FAILED +success: 6 +failure: 2 +ignored: 0 +total: 8 +tests: + - kind: Http + name: test-set-0 + status: PASSED + started: 1721659134 + completed: 1721659134 + test_case_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0 + mock_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0/mocks + test_case_id: test-1 + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "73" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 95c06185-f3a6-4830-b68d-d6674cd1c728 + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 01", + "description": "An Example TODO." + } + timestamp: 2024-07-22T20:05:28.729611191+05:30 + resp: + status_code: 308 + header: + Connection: keep-alive + Content-Length: "243" + Content-Type: text/html; charset=utf-8 + Date: Mon, 22 Jul 2024 14:38:54 GMT + Location: http://localhost:3000/todos/ + Server: gunicorn + body: | + + + Redirecting... +

Redirecting...

+

You should be redirected automatically to the target URL: http://localhost:3000/todos/. If not, click the link. + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 308 + actual: 308 + headers_result: + - normal: true + expected: + key: Server + value: + - gunicorn + actual: + key: Server + value: + - gunicorn + - normal: true + expected: + key: Connection + value: + - keep-alive + actual: + key: Connection + value: + - keep-alive + - normal: true + expected: + key: Content-Length + value: + - "243" + actual: + key: Content-Length + value: + - "243" + - normal: true + expected: + key: Content-Type + value: + - text/html; charset=utf-8 + actual: + key: Content-Type + value: + - text/html; charset=utf-8 + - normal: true + expected: + key: Date + value: + - Mon, 22 Jul 2024 14:35:28 GMT + actual: + key: Date + value: + - Mon, 22 Jul 2024 14:38:54 GMT + - normal: true + expected: + key: Location + value: + - http://localhost:3000/todos/ + actual: + key: Location + value: + - http://localhost:3000/todos/ + body_result: + - normal: true + type: PLAIN + expected: | + + + Redirecting... +

Redirecting...

+

You should be redirected automatically to the target URL: http://localhost:3000/todos/. If not, click the link. + actual: | + + + Redirecting... +

Redirecting...

+

You should be redirected automatically to the target URL: http://localhost:3000/todos/. If not, click the link. + dep_result: [] + - kind: Http + name: test-set-0 + status: FAILED + started: 1721659134 + completed: 1721659134 + test_case_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0 + mock_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0/mocks + test_case_id: test-2 + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/ + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "73" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 95c06185-f3a6-4830-b68d-d6674cd1c728 + Referer: http://localhost:3000/todos + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 01", + "description": "An Example TODO." + } + timestamp: 2024-07-22T20:05:28.735213232+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "99" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:38:54 GMT + Server: gunicorn + body: | + {"data":{"description":"An Example TODO.","id":"t3htfO","title":"Example TODO 01"},"success":true} + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Connection + value: + - keep-alive + actual: + key: Connection + value: + - keep-alive + - normal: true + expected: + key: Content-Length + value: + - "99" + actual: + key: Content-Length + value: + - "99" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + - normal: true + expected: + key: Date + value: + - Mon, 22 Jul 2024 14:35:28 GMT + actual: + key: Date + value: + - Mon, 22 Jul 2024 14:38:54 GMT + - normal: true + expected: + key: Server + value: + - gunicorn + actual: + key: Server + value: + - gunicorn + body_result: + - normal: false + type: JSON + expected: | + {"data":{"description":"An Example TODO.","id":"g_EwTj","title":"Example TODO 01"},"success":true} + actual: | + {"data":{"description":"An Example TODO.","id":"t3htfO","title":"Example TODO 01"},"success":true} + dep_result: [] + - kind: Http + name: test-set-0 + status: PASSED + started: 1721659134 + completed: 1721659134 + test_case_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0 + mock_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0/mocks + test_case_id: test-3 + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "34" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 66f7abad-b534-498a-b7e9-2f61ecc51ab6 + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 01" + } + timestamp: 2024-07-22T20:05:45.91731793+05:30 + resp: + status_code: 308 + header: + Connection: keep-alive + Content-Length: "243" + Content-Type: text/html; charset=utf-8 + Date: Mon, 22 Jul 2024 14:38:54 GMT + Location: http://localhost:3000/todos/ + Server: gunicorn + body: | + + + Redirecting... +

Redirecting...

+

You should be redirected automatically to the target URL: http://localhost:3000/todos/. If not, click the link. + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 308 + actual: 308 + headers_result: + - normal: true + expected: + key: Connection + value: + - keep-alive + actual: + key: Connection + value: + - keep-alive + - normal: true + expected: + key: Content-Length + value: + - "243" + actual: + key: Content-Length + value: + - "243" + - normal: true + expected: + key: Content-Type + value: + - text/html; charset=utf-8 + actual: + key: Content-Type + value: + - text/html; charset=utf-8 + - normal: true + expected: + key: Date + value: + - Mon, 22 Jul 2024 14:35:45 GMT + actual: + key: Date + value: + - Mon, 22 Jul 2024 14:38:54 GMT + - normal: true + expected: + key: Location + value: + - http://localhost:3000/todos/ + actual: + key: Location + value: + - http://localhost:3000/todos/ + - normal: true + expected: + key: Server + value: + - gunicorn + actual: + key: Server + value: + - gunicorn + body_result: + - normal: true + type: PLAIN + expected: | + + + Redirecting... +

Redirecting...

+

You should be redirected automatically to the target URL: http://localhost:3000/todos/. If not, click the link. + actual: | + + + Redirecting... +

Redirecting...

+

You should be redirected automatically to the target URL: http://localhost:3000/todos/. If not, click the link. + dep_result: [] + - kind: Http + name: test-set-0 + status: FAILED + started: 1721659134 + completed: 1721659134 + test_case_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0 + mock_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0/mocks + test_case_id: test-4 + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/ + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "34" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 66f7abad-b534-498a-b7e9-2f61ecc51ab6 + Referer: http://localhost:3000/todos + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 01" + } + timestamp: 2024-07-22T20:05:45.920170425+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "66" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:38:54 GMT + Server: gunicorn + body: | + {"data":{"id":"ZlYt4L","title":"Example TODO 01"},"success":true} + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Content-Length + value: + - "66" + actual: + key: Content-Length + value: + - "66" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + - normal: true + expected: + key: Date + value: + - Mon, 22 Jul 2024 14:35:45 GMT + actual: + key: Date + value: + - Mon, 22 Jul 2024 14:38:54 GMT + - normal: true + expected: + key: Server + value: + - gunicorn + actual: + key: Server + value: + - gunicorn + - normal: true + expected: + key: Connection + value: + - keep-alive + actual: + key: Connection + value: + - keep-alive + body_result: + - normal: false + type: JSON + expected: | + {"data":{"id":"Bd2_aR","title":"Example TODO 01"},"success":true} + actual: | + {"data":{"id":"ZlYt4L","title":"Example TODO 01"},"success":true} + dep_result: [] + - kind: Http + name: test-set-0 + status: PASSED + started: 1721659134 + completed: 1721659134 + test_case_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0 + mock_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0/mocks + test_case_id: test-5 + req: + method: PUT + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/g_EwTj + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "75" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 6f6c626a-a8b6-47da-8082-b4680d860ea9 + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 02", + "description": "An Example TODO 02" + } + timestamp: 2024-07-22T20:06:31.95777189+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "77" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:38:54 GMT + Server: gunicorn + body: | + {"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"} + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Date + value: + - Mon, 22 Jul 2024 14:36:31 GMT + actual: + key: Date + value: + - Mon, 22 Jul 2024 14:38:54 GMT + - normal: true + expected: + key: Server + value: + - gunicorn + actual: + key: Server + value: + - gunicorn + - normal: true + expected: + key: Connection + value: + - keep-alive + actual: + key: Connection + value: + - keep-alive + - normal: true + expected: + key: Content-Length + value: + - "77" + actual: + key: Content-Length + value: + - "77" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + body_result: + - normal: true + type: JSON + expected: | + {"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"} + actual: | + {"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"} + dep_result: [] + - kind: Http + name: test-set-0 + status: PASSED + started: 1721659134 + completed: 1721659134 + test_case_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0 + mock_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0/mocks + test_case_id: test-6 + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/g_EwTj + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "75" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 02c19ee8-8416-48c5-bcf7-2160052b49cc + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 02", + "description": "An Example TODO 02" + } + timestamp: 2024-07-22T20:06:42.495868854+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "77" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:38:54 GMT + Server: gunicorn + body: | + {"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"} + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Date + value: + - Mon, 22 Jul 2024 14:36:42 GMT + actual: + key: Date + value: + - Mon, 22 Jul 2024 14:38:54 GMT + - normal: true + expected: + key: Server + value: + - gunicorn + actual: + key: Server + value: + - gunicorn + - normal: true + expected: + key: Connection + value: + - keep-alive + actual: + key: Connection + value: + - keep-alive + - normal: true + expected: + key: Content-Length + value: + - "77" + actual: + key: Content-Length + value: + - "77" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + body_result: + - normal: true + type: JSON + expected: | + {"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"} + actual: | + {"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"} + dep_result: [] + - kind: Http + name: test-set-0 + status: PASSED + started: 1721659134 + completed: 1721659134 + test_case_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0 + mock_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0/mocks + test_case_id: test-7 + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "75" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 6aed3d6d-d840-4dfd-8c31-01d24af26e81 + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 02", + "description": "An Example TODO 02" + } + timestamp: 2024-07-22T20:06:45.810219479+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "121" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:38:54 GMT + Server: gunicorn + body: | + [{"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"},{"id":"Bd2_aR","title":"Example TODO 01"}] + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Server + value: + - gunicorn + actual: + key: Server + value: + - gunicorn + - normal: true + expected: + key: Connection + value: + - keep-alive + actual: + key: Connection + value: + - keep-alive + - normal: true + expected: + key: Content-Length + value: + - "121" + actual: + key: Content-Length + value: + - "121" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + - normal: true + expected: + key: Date + value: + - Mon, 22 Jul 2024 14:36:45 GMT + actual: + key: Date + value: + - Mon, 22 Jul 2024 14:38:54 GMT + body_result: + - normal: true + type: JSON + expected: | + [{"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"},{"id":"Bd2_aR","title":"Example TODO 01"}] + actual: | + [{"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"},{"id":"Bd2_aR","title":"Example TODO 01"}] + dep_result: [] + - kind: Http + name: test-set-0 + status: PASSED + started: 1721659134 + completed: 1721659134 + test_case_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0 + mock_path: /home/subhradip/sammaji/samples-python-fork/flask-redis/keploy/test-set-0/mocks + test_case_id: test-8 + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/Bd2_aR + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Host: localhost:3000 + Postman-Token: 0b8b2977-b387-4c0b-a9cf-030b7c283bb7 + User-Agent: PostmanRuntime/7.40.0 + body: "" + timestamp: 2024-07-22T20:07:02.486055325+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "17" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:38:54 GMT + Server: gunicorn + body: | + {"success":true} + status_message: "" + proto_major: 0 + proto_minor: 0 + timestamp: 0001-01-01T00:00:00Z + noise: + header.Date: [] + result: + status_code: + normal: true + expected: 200 + actual: 200 + headers_result: + - normal: true + expected: + key: Connection + value: + - keep-alive + actual: + key: Connection + value: + - keep-alive + - normal: true + expected: + key: Content-Length + value: + - "17" + actual: + key: Content-Length + value: + - "17" + - normal: true + expected: + key: Content-Type + value: + - application/json + actual: + key: Content-Type + value: + - application/json + - normal: true + expected: + key: Date + value: + - Mon, 22 Jul 2024 14:37:02 GMT + actual: + key: Date + value: + - Mon, 22 Jul 2024 14:38:54 GMT + - normal: true + expected: + key: Server + value: + - gunicorn + actual: + key: Server + value: + - gunicorn + body_result: + - normal: true + type: JSON + expected: | + {"success":true} + actual: | + {"success":true} + dep_result: [] +test_set: test-set-0 diff --git a/flask-redis/keploy/test-set-0/mocks.yaml b/flask-redis/keploy/test-set-0/mocks.yaml new file mode 100755 index 0000000..8512e5a --- /dev/null +++ b/flask-redis/keploy/test-set-0/mocks.yaml @@ -0,0 +1,246 @@ +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-0 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*4\r\n$6\r\nCLIENT\r\n$7\r\nSETINFO\r\n$8\r\nLIB-NAME\r\n$8\r\nredis-py\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-07-22T20:05:28.73868767+05:30 + restimestampmock: 2024-07-22T20:05:28.738872821+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-1 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*4\r\n$6\r\nCLIENT\r\n$7\r\nSETINFO\r\n$7\r\nLIB-VER\r\n$5\r\n5.0.7\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-07-22T20:05:28.739170209+05:30 + restimestampmock: 2024-07-22T20:05:28.739352498+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-2 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*3\r\n$3\r\nSET\r\n$6\r\ng_EwTj\r\n$63\r\n{\"title\": \"Example TODO 01\", \"description\": \"An Example TODO.\"}\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-07-22T20:05:28.739623974+05:30 + restimestampmock: 2024-07-22T20:05:28.739738026+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-3 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*3\r\n$3\r\nSET\r\n$6\r\nBd2_aR\r\n$28\r\n{\"title\": \"Example TODO 01\"}\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-07-22T20:05:45.921454264+05:30 + restimestampmock: 2024-07-22T20:05:45.92178783+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-4 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*4\r\n$6\r\nCLIENT\r\n$7\r\nSETINFO\r\n$8\r\nLIB-NAME\r\n$8\r\nredis-py\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-07-22T20:06:31.961805347+05:30 + restimestampmock: 2024-07-22T20:06:31.962030588+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-5 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*4\r\n$6\r\nCLIENT\r\n$7\r\nSETINFO\r\n$7\r\nLIB-VER\r\n$5\r\n5.0.7\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-07-22T20:06:31.962384479+05:30 + restimestampmock: 2024-07-22T20:06:31.962508379+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-6 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$3\r\nGET\r\n$6\r\ng_EwTj\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "$63\r\n{\"title\": \"Example TODO 01\", \"description\": \"An Example TODO.\"}\r\n" + reqtimestampmock: 2024-07-22T20:06:31.96271588+05:30 + restimestampmock: 2024-07-22T20:06:31.962862269+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-7 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*3\r\n$3\r\nSET\r\n$6\r\ng_EwTj\r\n$65\r\n{\"title\": \"Example TODO 02\", \"description\": \"An Example TODO 02\"}\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "+OK\r\n" + reqtimestampmock: 2024-07-22T20:06:31.964285235+05:30 + restimestampmock: 2024-07-22T20:06:31.964469758+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-8 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$3\r\nGET\r\n$6\r\ng_EwTj\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "$65\r\n{\"title\": \"Example TODO 02\", \"description\": \"An Example TODO 02\"}\r\n" + reqtimestampmock: 2024-07-22T20:06:42.497140541+05:30 + restimestampmock: 2024-07-22T20:06:42.49734022+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-9 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$4\r\nKEYS\r\n$1\r\n*\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "*2\r\n$6\r\ng_EwTj\r\n$6\r\nBd2_aR\r\n" + reqtimestampmock: 2024-07-22T20:06:45.811740293+05:30 + restimestampmock: 2024-07-22T20:06:45.811971681+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-10 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$3\r\nGET\r\n$6\r\ng_EwTj\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "$65\r\n{\"title\": \"Example TODO 02\", \"description\": \"An Example TODO 02\"}\r\n" + reqtimestampmock: 2024-07-22T20:06:45.812264808+05:30 + restimestampmock: 2024-07-22T20:06:45.812451008+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-11 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$3\r\nGET\r\n$6\r\nBd2_aR\r\n" + redisresponses: + - origin: server + message: + - type: string + data: "$28\r\n{\"title\": \"Example TODO 01\"}\r\n" + reqtimestampmock: 2024-07-22T20:06:45.812816702+05:30 + restimestampmock: 2024-07-22T20:06:45.81296337+05:30 +--- +version: api.keploy.io/v1beta1 +kind: Redis +name: mock-12 +spec: + metadata: + type: config + redisrequests: + - origin: client + message: + - type: string + data: "*2\r\n$3\r\nDEL\r\n$6\r\nBd2_aR\r\n" + redisresponses: + - origin: server + message: + - type: string + data: ":1\r\n" + reqtimestampmock: 2024-07-22T20:07:02.487151778+05:30 + restimestampmock: 2024-07-22T20:07:02.487372689+05:30 diff --git a/flask-redis/keploy/test-set-0/tests/test-1.yaml b/flask-redis/keploy/test-set-0/tests/test-1.yaml new file mode 100755 index 0000000..fff6f9e --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-1.yaml @@ -0,0 +1,63 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-1 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "73" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 95c06185-f3a6-4830-b68d-d6674cd1c728 + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 01", + "description": "An Example TODO." + } + timestamp: 2024-07-22T20:05:28.729611191+05:30 + resp: + status_code: 308 + header: + Connection: keep-alive + Content-Length: "243" + Content-Type: text/html; charset=utf-8 + Date: Mon, 22 Jul 2024 14:35:28 GMT + Location: http://localhost:3000/todos/ + Server: gunicorn + body: | + + + Redirecting... +

Redirecting...

+

You should be redirected automatically to the target URL: http://localhost:3000/todos/. If not, click the link. + status_message: Permanent Redirect + proto_major: 0 + proto_minor: 0 + timestamp: 2024-07-22T20:05:28.79497592+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1721658928 +curl: |- + curl --request POST \ + --url http://localhost:3000/todos \ + --header 'Content-Type: application/json' \ + --header 'User-Agent: PostmanRuntime/7.40.0' \ + --header 'Accept: */*' \ + --header 'Postman-Token: 95c06185-f3a6-4830-b68d-d6674cd1c728' \ + --header 'Host: localhost:3000' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --data '{ + "title": "Example TODO 01", + "description": "An Example TODO." + }' diff --git a/flask-redis/keploy/test-set-0/tests/test-2.yaml b/flask-redis/keploy/test-set-0/tests/test-2.yaml new file mode 100755 index 0000000..93a39e1 --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-2.yaml @@ -0,0 +1,60 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-2 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/ + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "73" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 95c06185-f3a6-4830-b68d-d6674cd1c728 + Referer: http://localhost:3000/todos + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 01", + "description": "An Example TODO." + } + timestamp: 2024-07-22T20:05:28.735213232+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "99" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:35:28 GMT + Server: gunicorn + body: | + {"data":{"description":"An Example TODO.","id":"g_EwTj","title":"Example TODO 01"},"success":true} + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-07-22T20:05:30.803153552+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1721658930 +curl: |- + curl --request POST \ + --url http://localhost:3000/todos/ \ + --header 'Accept: */*' \ + --header 'Content-Type: application/json' \ + --header 'Postman-Token: 95c06185-f3a6-4830-b68d-d6674cd1c728' \ + --header 'Connection: keep-alive' \ + --header 'Host: localhost:3000' \ + --header 'Referer: http://localhost:3000/todos' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'User-Agent: PostmanRuntime/7.40.0' \ + --data '{ + "title": "Example TODO 01", + "description": "An Example TODO." + }' diff --git a/flask-redis/keploy/test-set-0/tests/test-3.yaml b/flask-redis/keploy/test-set-0/tests/test-3.yaml new file mode 100755 index 0000000..107457c --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-3.yaml @@ -0,0 +1,61 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-3 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "34" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 66f7abad-b534-498a-b7e9-2f61ecc51ab6 + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 01" + } + timestamp: 2024-07-22T20:05:45.91731793+05:30 + resp: + status_code: 308 + header: + Connection: keep-alive + Content-Length: "243" + Content-Type: text/html; charset=utf-8 + Date: Mon, 22 Jul 2024 14:35:45 GMT + Location: http://localhost:3000/todos/ + Server: gunicorn + body: | + + + Redirecting... +

Redirecting...

+

You should be redirected automatically to the target URL: http://localhost:3000/todos/. If not, click the link. + status_message: Permanent Redirect + proto_major: 0 + proto_minor: 0 + timestamp: 2024-07-22T20:05:45.961027334+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1721658945 +curl: |- + curl --request POST \ + --url http://localhost:3000/todos \ + --header 'User-Agent: PostmanRuntime/7.40.0' \ + --header 'Accept: */*' \ + --header 'Postman-Token: 66f7abad-b534-498a-b7e9-2f61ecc51ab6' \ + --header 'Host: localhost:3000' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --header 'Content-Type: application/json' \ + --data '{ + "title": "Example TODO 01" + }' diff --git a/flask-redis/keploy/test-set-0/tests/test-4.yaml b/flask-redis/keploy/test-set-0/tests/test-4.yaml new file mode 100755 index 0000000..aa8b819 --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-4.yaml @@ -0,0 +1,58 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-4 +spec: + metadata: {} + req: + method: POST + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/ + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "34" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 66f7abad-b534-498a-b7e9-2f61ecc51ab6 + Referer: http://localhost:3000/todos + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 01" + } + timestamp: 2024-07-22T20:05:45.920170425+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "66" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:35:45 GMT + Server: gunicorn + body: | + {"data":{"id":"Bd2_aR","title":"Example TODO 01"},"success":true} + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-07-22T20:05:47.96930896+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1721658947 +curl: |- + curl --request POST \ + --url http://localhost:3000/todos/ \ + --header 'Connection: keep-alive' \ + --header 'Postman-Token: 66f7abad-b534-498a-b7e9-2f61ecc51ab6' \ + --header 'Content-Type: application/json' \ + --header 'User-Agent: PostmanRuntime/7.40.0' \ + --header 'Accept: */*' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Host: localhost:3000' \ + --header 'Referer: http://localhost:3000/todos' \ + --data '{ + "title": "Example TODO 01" + }' diff --git a/flask-redis/keploy/test-set-0/tests/test-5.yaml b/flask-redis/keploy/test-set-0/tests/test-5.yaml new file mode 100755 index 0000000..d62655a --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-5.yaml @@ -0,0 +1,58 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-5 +spec: + metadata: {} + req: + method: PUT + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/g_EwTj + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "75" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 6f6c626a-a8b6-47da-8082-b4680d860ea9 + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 02", + "description": "An Example TODO 02" + } + timestamp: 2024-07-22T20:06:31.95777189+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "77" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:36:31 GMT + Server: gunicorn + body: | + {"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"} + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-07-22T20:06:34.047727882+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1721658994 +curl: |- + curl --request PUT \ + --url http://localhost:3000/todos/g_EwTj \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --header 'Content-Type: application/json' \ + --header 'User-Agent: PostmanRuntime/7.40.0' \ + --header 'Accept: */*' \ + --header 'Postman-Token: 6f6c626a-a8b6-47da-8082-b4680d860ea9' \ + --header 'Host: localhost:3000' \ + --data '{ + "title": "Example TODO 02", + "description": "An Example TODO 02" + }' diff --git a/flask-redis/keploy/test-set-0/tests/test-6.yaml b/flask-redis/keploy/test-set-0/tests/test-6.yaml new file mode 100755 index 0000000..710ba2e --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-6.yaml @@ -0,0 +1,58 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-6 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/g_EwTj + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "75" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 02c19ee8-8416-48c5-bcf7-2160052b49cc + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 02", + "description": "An Example TODO 02" + } + timestamp: 2024-07-22T20:06:42.495868854+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "77" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:36:42 GMT + Server: gunicorn + body: | + {"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"} + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-07-22T20:06:46.595835536+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1721659006 +curl: |- + curl --request GET \ + --url http://localhost:3000/todos/g_EwTj \ + --header 'Postman-Token: 02c19ee8-8416-48c5-bcf7-2160052b49cc' \ + --header 'Host: localhost:3000' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --header 'Content-Type: application/json' \ + --header 'User-Agent: PostmanRuntime/7.40.0' \ + --header 'Accept: */*' \ + --data '{ + "title": "Example TODO 02", + "description": "An Example TODO 02" + }' diff --git a/flask-redis/keploy/test-set-0/tests/test-7.yaml b/flask-redis/keploy/test-set-0/tests/test-7.yaml new file mode 100755 index 0000000..68bd4c9 --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-7.yaml @@ -0,0 +1,58 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-7 +spec: + metadata: {} + req: + method: GET + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Content-Length: "75" + Content-Type: application/json + Host: localhost:3000 + Postman-Token: 6aed3d6d-d840-4dfd-8c31-01d24af26e81 + User-Agent: PostmanRuntime/7.40.0 + body: |- + { + "title": "Example TODO 02", + "description": "An Example TODO 02" + } + timestamp: 2024-07-22T20:06:45.810219479+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "121" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:36:45 GMT + Server: gunicorn + body: | + [{"description":"An Example TODO 02","id":"g_EwTj","title":"Example TODO 02"},{"id":"Bd2_aR","title":"Example TODO 01"}] + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-07-22T20:06:47.902113573+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1721659007 +curl: |- + curl --request GET \ + --url http://localhost:3000/todos \ + --header 'Content-Type: application/json' \ + --header 'User-Agent: PostmanRuntime/7.40.0' \ + --header 'Accept: */*' \ + --header 'Postman-Token: 6aed3d6d-d840-4dfd-8c31-01d24af26e81' \ + --header 'Host: localhost:3000' \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --data '{ + "title": "Example TODO 02", + "description": "An Example TODO 02" + }' diff --git a/flask-redis/keploy/test-set-0/tests/test-8.yaml b/flask-redis/keploy/test-set-0/tests/test-8.yaml new file mode 100755 index 0000000..1812230 --- /dev/null +++ b/flask-redis/keploy/test-set-0/tests/test-8.yaml @@ -0,0 +1,47 @@ +version: api.keploy.io/v1beta1 +kind: Http +name: test-8 +spec: + metadata: {} + req: + method: DELETE + proto_major: 1 + proto_minor: 1 + url: http://localhost:3000/todos/Bd2_aR + header: + Accept: '*/*' + Accept-Encoding: gzip, deflate, br + Connection: keep-alive + Host: localhost:3000 + Postman-Token: 0b8b2977-b387-4c0b-a9cf-030b7c283bb7 + User-Agent: PostmanRuntime/7.40.0 + body: "" + timestamp: 2024-07-22T20:07:02.486055325+05:30 + resp: + status_code: 200 + header: + Connection: keep-alive + Content-Length: "17" + Content-Type: application/json + Date: Mon, 22 Jul 2024 14:37:02 GMT + Server: gunicorn + body: | + {"success":true} + status_message: OK + proto_major: 0 + proto_minor: 0 + timestamp: 2024-07-22T20:07:04.562705189+05:30 + objects: [] + assertions: + noise: + header.Date: [] + created: 1721659024 +curl: | + curl --request DELETE \ + --url http://localhost:3000/todos/Bd2_aR \ + --header 'Accept-Encoding: gzip, deflate, br' \ + --header 'Connection: keep-alive' \ + --header 'User-Agent: PostmanRuntime/7.40.0' \ + --header 'Accept: */*' \ + --header 'Postman-Token: 0b8b2977-b387-4c0b-a9cf-030b7c283bb7' \ + --header 'Host: localhost:3000' \ diff --git a/flask-redis/requirements.txt b/flask-redis/requirements.txt new file mode 100644 index 0000000..8372e80 --- /dev/null +++ b/flask-redis/requirements.txt @@ -0,0 +1,13 @@ +async-timeout==4.0.3 +blinker==1.8.2 +click==8.1.7 +Flask==3.0.3 +gunicorn==22.0.0 +itsdangerous==2.2.0 +Jinja2==3.1.4 +MarkupSafe==2.1.5 +marshmallow==3.21.3 +nanoid==2.0.0 +packaging==24.1 +redis==5.0.7 +Werkzeug==3.0.3 diff --git a/flask-redis/schema.py b/flask-redis/schema.py new file mode 100644 index 0000000..32163df --- /dev/null +++ b/flask-redis/schema.py @@ -0,0 +1,11 @@ +from marshmallow import Schema, fields + + +class CreateTodoSchema(Schema): + title = fields.Str(required=True) + description = fields.Str(required=False) + + +class UpdateTodoSchema(Schema): + title = fields.Str(required=False) + description = fields.Str(required=False) \ No newline at end of file