diff --git a/fastapi-postgres/README.md b/fastapi-postgres/README.md index d902662..ebe959d 100644 --- a/fastapi-postgres/README.md +++ b/fastapi-postgres/README.md @@ -13,6 +13,7 @@ Make the following requests to the respective endpoints - ```bash git clone https://github.com/keploy/samples-python.git && cd samples-python/fastapi-postgres +pip3 install coverage pip3 install -r requirements.txt ``` @@ -21,8 +22,7 @@ pip3 install -r requirements.txt Keploy can be installed on Linux directly and on Windows with the help of WSL. Based on your system architecture, install the keploy latest binary release ```bash - curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh - keploy +curl -O -L https:///keploy.io/install.sh && source install.sh ``` ### Starting the PostgreSQL Instance @@ -34,9 +34,9 @@ docker-compose up -d ### Capture the Testcases -This command will start the recording of API calls using ebpf:- +This command will start the recording of API calls : -```shell +```sh sudo -E PATH=$PATH keploy record -c "uvicorn application.main:app --reload" ``` @@ -99,12 +99,20 @@ curl --location --request DELETE 'http://127.0.0.1:8000/students/1' Now all these API calls were captured as **editable** testcases and written to `keploy/tests` folder. The keploy directory would also have `mocks` file that contains all the outputs of postgres operations. +![keploy testcase](./img/testcases.png) + ## Run the Testcases Now let's run the application in test mode. ```shell -sudo -E PATH=$PATH keploy test -c "uvicorn application.main:app --reload" --delay 10 +sudo -E PATH=$PATH keploy test -c "python3 -m uvicorn application.main:app" --delay 10 ``` +We will get output something like below - + +![keploy testcase](./img/testrun.png) + +By making just 2 api call, we have generated a complete test suite for our application and acheived 72% coverage. + +So, no need to setup fake database/apis like Postgres or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Postgres ๐Ÿ˜„** -So, no need to setup fake database/apis like Postgres or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Postgres ๐Ÿ˜„** diff --git a/fastapi-postgres/application/database.py b/fastapi-postgres/application/database.py index 8b00777..17e68c4 100644 --- a/fastapi-postgres/application/database.py +++ b/fastapi-postgres/application/database.py @@ -3,7 +3,7 @@ from sqlalchemy.orm import sessionmaker -SQLALCHEMY_DATABASE_URL = "postgresql://postgres:postgres@postgres:5432/studentdb" +SQLALCHEMY_DATABASE_URL = "postgresql://postgres:postgres@localhost:5432/studentdb" engine = create_engine(SQLALCHEMY_DATABASE_URL) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) diff --git a/fastapi-postgres/application/main.py b/fastapi-postgres/application/main.py index 294ad02..c078fe2 100644 --- a/fastapi-postgres/application/main.py +++ b/fastapi-postgres/application/main.py @@ -1,14 +1,21 @@ from fastapi import Depends, FastAPI, HTTPException from sqlalchemy.orm import Session +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker +from sqlalchemy.ext.declarative import declarative_base +import asyncio from . import models, crud, schemas -from .database import SessionLocal, engine +# Database setup +SQLALCHEMY_DATABASE_URL = "postgresql://postgres:postgres@localhost:5432/studentdb" +engine = create_engine(SQLALCHEMY_DATABASE_URL) +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) +Base = declarative_base() models.Base.metadata.create_all(bind=engine) app = FastAPI() - # Dependency def get_db(): db = SessionLocal() @@ -17,7 +24,6 @@ def get_db(): finally: db.close() - @app.post('/students/', response_model=schemas.Student) def create_student(student: schemas.StudentCreate, db: Session = Depends(get_db)): db_student = crud.get_student_byEmail(db, student_email=student.email) @@ -26,7 +32,6 @@ def create_student(student: schemas.StudentCreate, db: Session = Depends(get_db) data = crud.create_student(db, student=student) return data - @app.get('/students/', response_model=list[schemas.Student]) def read_students(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)): students = crud.get_students(db, skip, limit) @@ -34,7 +39,6 @@ def read_students(skip: int = 0, limit: int = 100, db: Session = Depends(get_db) raise HTTPException(404, 'Data not found!!') return students - @app.get('/students/{student_id}', response_model=schemas.Student) def read_student(student_id: int, db: Session = Depends(get_db)): student = crud.get_student(db, student_id=student_id) @@ -42,7 +46,6 @@ def read_student(student_id: int, db: Session = Depends(get_db)): raise HTTPException(status_code=404, detail=f'Student with ID={student_id} not found!!') return student - @app.put('/students/{student_id}', response_model=schemas.Student) def update_student(student_id: int, student: schemas.StudentUpdate, db: Session = Depends(get_db)): student = crud.update_student(db, student=student, student_id=student_id) @@ -50,10 +53,18 @@ def update_student(student_id: int, student: schemas.StudentUpdate, db: Session raise HTTPException(status_code=404, detail=f'Student with ID={student_id} not found!!') return student - @app.delete('/students/{student_id}', response_model=schemas.Student) def delete_student(student_id: int, db: Session = Depends(get_db)): student = crud.delete_student(db, student_id=student_id) if student is None: raise HTTPException(status_code=404, detail=f'Student with ID={student_id} not found!!') return student + +# Graceful shutdown +@app.on_event("shutdown") +async def shutdown_event(): + # Example: Close the database connection pool + print("Shutting down...") + # Assuming SQLAlchemy engine has a dispose method to release resources + engine.dispose() + diff --git a/fastapi-postgres/application/test_crud.py b/fastapi-postgres/application/test_crud.py new file mode 100644 index 0000000..b33d4c8 --- /dev/null +++ b/fastapi-postgres/application/test_crud.py @@ -0,0 +1,55 @@ +import pytest +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker + +from .database import Base, SessionLocal +from . import crud, models, schemas + +# Create an in-memory SQLite database for testing +SQLALCHEMY_DATABASE_URL = "sqlite:///./test.db" +engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}) +TestingSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) + +# Create the database tables +Base.metadata.create_all(bind=engine) + +@pytest.fixture(scope="module") +def db_session(): + connection = engine.connect() + transaction = connection.begin() + session = TestingSessionLocal(bind=connection) + + yield session + + session.close() + transaction.rollback() + connection.close() + +def test_create_student(db_session): + student_in = schemas.StudentCreate(name="John Doe", email="john.doe@example.com", password="password", stream="Science") + student = crud.create_student(db_session, student_in) + assert student.name == "John Doe" + assert student.email == "john.doe@example.com" + +def test_get_student(db_session): + student_in = schemas.StudentCreate(name="Jane Doe", email="jane.doe@example.com", password="password", stream="Arts") + student = crud.create_student(db_session, student_in) + fetched_student = crud.get_student(db_session, student.id) + assert fetched_student.name == "Jane Doe" + assert fetched_student.email == "jane.doe@example.com" + +def test_update_student(db_session): + student_in = schemas.StudentCreate(name="Jim Beam", email="jim.beam@example.com", password="password", stream="Commerce") + student = crud.create_student(db_session, student_in) + student_update = schemas.StudentUpdate(name="Jim Updated", email="jim.updated@example.com", password="newpassword", stream="Commerce") + updated_student = crud.update_student(db_session, student_update, student.id) + assert updated_student.name == "Jim Updated" + assert updated_student.email == "jim.updated@example.com" + +def test_delete_student(db_session): + student_in = schemas.StudentCreate(name="Will Smith", email="will.smith@example.com", password="password", stream="Engineering") + student = crud.create_student(db_session, student_in) + deleted_student = crud.delete_student(db_session, student.id) + assert deleted_student is not None + assert deleted_student.name == "Will Smith" + assert crud.get_student(db_session, student.id) is None diff --git a/fastapi-postgres/docker-compose.yml b/fastapi-postgres/docker-compose.yml index aa2e85c..80ec447 100644 --- a/fastapi-postgres/docker-compose.yml +++ b/fastapi-postgres/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: '3.9' services: postgres: @@ -30,4 +30,4 @@ services: networks: keploy-network: - external: true + external: true \ No newline at end of file diff --git a/fastapi-postgres/img/testcases.png b/fastapi-postgres/img/testcases.png new file mode 100644 index 0000000..1c4a2f0 Binary files /dev/null and b/fastapi-postgres/img/testcases.png differ diff --git a/fastapi-postgres/img/testrun.png b/fastapi-postgres/img/testrun.png new file mode 100644 index 0000000..11029fc Binary files /dev/null and b/fastapi-postgres/img/testrun.png differ diff --git a/fastapi-postgres/keploy.yml b/fastapi-postgres/keploy.yml new file mode 100755 index 0000000..d6e6628 --- /dev/null +++ b/fastapi-postgres/keploy.yml @@ -0,0 +1,43 @@ +path: "" +appId: 0 +appName: "" +command: uvicorn application.main:app --reload +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/fastapi-postgres/keploy/test-set-1/mocks.yaml b/fastapi-postgres/keploy/test-set-1/mocks.yaml deleted file mode 100755 index 86b47c1..0000000 --- a/fastapi-postgres/keploy/test-set-1/mocks.yaml +++ /dev/null @@ -1,1219 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-0 -spec: - metadata: - type: config - postgresrequests: - - identifier: StartupRequest - length: 8 - payload: AAAACATSFi8= - ssl_request: - is_ssl: true - auth_type: 0 - postgresresponses: - - payload: Tg== - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.216898875Z - restimestampmock: 2024-02-09T10:20:50.218562705Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-1 -spec: - metadata: - type: config - postgresrequests: - - identifier: StartupRequest - payload: AAAAKgADAAB1c2VyAHBvc3RncmVzAGRhdGFiYXNlAHN0dWRlbnRkYgAA - auth_type: 0 - postgresresponses: - - header: [R] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - authentication_sasl: - auth_mechanisms: - - SCRAM-SHA-256 - msg_type: 82 - auth_type: 10 - reqtimestampmock: 2024-02-09T10:20:50.232737784Z - restimestampmock: 2024-02-09T10:20:50.233296602Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-2 -spec: - metadata: - type: config - postgresrequests: - - header: [p] - identifier: ClientRequest - length: 8 - password_message: - password: SCRAM-SHA-256 - msg_type: 112 - auth_type: 0 - postgresresponses: - - header: [R] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - authentication_sasl_continue: {data: [114, 61, 68, 54, 118, 109, 56, 118, 117, 82, 116, 89, 111, 116, 75, 81, 75, 86, 74, 100, 55, 47, 85, 115, 107, 90, 70, 78, 88, 79, 112, 80, 88, 84, 67, 105, 103, 86, 51, 101, 73, 90, 48, 105, 119, 117, 65, 106, 111, 83, 44, 115, 61, 117, 110, 74, 50, 122, 68, 57, 75, 121, 76, 47, 109, 83, 114, 117, 111, 102, 121, 55, 112, 84, 81, 61, 61, 44, 105, 61, 52, 48, 57, 54]} - msg_type: 82 - auth_type: 11 - reqtimestampmock: 2024-02-09T10:20:50.234459113Z - restimestampmock: 2024-02-09T10:20:50.234488904Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-3 -spec: - metadata: - type: config - postgresrequests: - - header: [p] - identifier: ClientRequest - length: 8 - msg_type: 112 - auth_type: 0 - postgresresponses: - - header: [R, R, S, S, S, S, S, S, S, S, S, S, S, S, S, S, K, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - authentication_sasl_final: {data: [118, 61, 118, 48, 53, 82, 117, 66, 89, 50, 52, 51, 72, 85, 67, 97, 116, 102, 83, 55, 67, 69, 70, 43, 72, 84, 106, 89, 90, 79, 118, 115, 115, 78, 48, 56, 116, 120, 99, 48, 103, 106, 105, 119, 85, 61]} - backend_key_data: - process_id: 34 - secret_key: 4065475156 - parameter_status: - - name: in_hot_standby - value: "off" - - name: integer_datetimes - value: "on" - - name: TimeZone - value: Etc/UTC - - name: IntervalStyle - value: postgres - - name: is_superuser - value: "on" - - name: application_name - value: "" - - name: default_transaction_read_only - value: "off" - - name: scram_iterations - value: "4096" - - name: DateStyle - value: ISO, MDY - - name: standard_conforming_strings - value: "on" - - name: session_authorization - value: postgres - - name: client_encoding - value: UTF8 - - name: server_version - value: 16.1 (Debian 16.1-1.pgdg120+1) - - name: server_encoding - value: UTF8 - - name: server_encoding - value: UTF8 - - name: server_encoding - value: UTF8 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.240419203Z - restimestampmock: 2024-02-09T10:20:50.24047866Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-4 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.241574547Z - restimestampmock: 2024-02-09T10:20:50.241651254Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-5 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAAHdTRUxFQ1QgdC5vaWQsIHR5cGFycmF5CkZST00gcGdfdHlwZSB0IEpPSU4gcGdfbmFtZXNwYWNlIG5zCiAgICBPTiB0eXBuYW1lc3BhY2UgPSBucy5vaWQKV0hFUkUgdHlwbmFtZSA9ICdoc3RvcmUnOwoA - query: - string: 'SELECT t.oid, typarray FROM pg_type t JOIN pg_namespace ns ON typnamespace = ns.oid WHERE typname = ''hstore''; ' - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 48 - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [111, 105, 100], table_oid: 1247, table_attribute_number: 1, data_type_oid: 26, data_type_size: 4, type_modifier: -1, format: 0}, {name: [116, 121, 112, 97, 114, 114, 97, 121], table_oid: 1247, table_attribute_number: 15, data_type_oid: 26, data_type_size: 4, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.243360791Z - restimestampmock: 2024-02-09T10:20:50.243385416Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-6 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: ROLLBACK - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 82 - - 79 - - 76 - - 76 - - 66 - - 65 - - 67 - - 75 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.244072772Z - restimestampmock: 2024-02-09T10:20:50.244098563Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-7 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.244693006Z - restimestampmock: 2024-02-09T10:20:50.244715338Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-8 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: select pg_catalog.version() - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAACAAAXZlcnNpb24AAAAAAAAAAAAAGf///////wAARAAAAIMAAQAAAHlQb3N0Z3JlU1FMIDE2LjEgKERlYmlhbiAxNi4xLTEucGdkZzEyMCsxKSBvbiBhYXJjaDY0LXVua25vd24tbGludXgtZ251LCBjb21waWxlZCBieSBnY2MgKERlYmlhbiAxMi4yLjAtMTQpIDEyLjIuMCwgNjQtYml0QwAAAA1TRUxFQ1QgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 49 - data_row: [{row_values: ['PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit']}, {row_values: ['PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit']}, {row_values: ['PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit']}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [118, 101, 114, 115, 105, 111, 110], table_oid: 0, table_attribute_number: 0, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.24516216Z - restimestampmock: 2024-02-09T10:20:50.245191367Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-9 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: select current_schema() - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAACcAAWN1cnJlbnRfc2NoZW1hAAAAAAAAAAAAABMAQP////8AAEQAAAAQAAEAAAAGcHVibGljQwAAAA1TRUxFQ1QgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 49 - data_row: [{row_values: [public]}, {row_values: [public]}, {row_values: [public]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [99, 117, 114, 114, 101, 110, 116, 95, 115, 99, 104, 101, 109, 97], table_oid: 0, table_attribute_number: 0, data_type_oid: 19, data_type_size: 64, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.246241214Z - restimestampmock: 2024-02-09T10:20:50.246281713Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-10 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: show transaction isolation level - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAAC4AAXRyYW5zYWN0aW9uX2lzb2xhdGlvbgAAAAAAAAAAAAAZ////////AABEAAAAGAABAAAADnJlYWQgY29tbWl0dGVkQwAAAAlTSE9XAFoAAAAFVA== - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 72 - - 79 - - 87 - data_row: [{row_values: [read committed]}, {row_values: [read committed]}, {row_values: [read committed]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [116, 114, 97, 110, 115, 97, 99, 116, 105, 111, 110, 95, 105, 115, 111, 108, 97, 116, 105, 111, 110], table_oid: 0, table_attribute_number: 0, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.247356559Z - restimestampmock: 2024-02-09T10:20:50.247387933Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-11 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: show standard_conforming_strings - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAADQAAXN0YW5kYXJkX2NvbmZvcm1pbmdfc3RyaW5ncwAAAAAAAAAAAAAZ////////AABEAAAADAABAAAAAm9uQwAAAAlTSE9XAFoAAAAFVA== - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 72 - - 79 - - 87 - data_row: [{row_values: ["on"]}, {row_values: ["on"]}, {row_values: ["on"]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [115, 116, 97, 110, 100, 97, 114, 100, 95, 99, 111, 110, 102, 111, 114, 109, 105, 110, 103, 95, 115, 116, 114, 105, 110, 103, 115], table_oid: 0, table_attribute_number: 0, data_type_oid: 25, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.248114456Z - restimestampmock: 2024-02-09T10:20:50.24815283Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-12 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: ROLLBACK - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 82 - - 79 - - 76 - - 76 - - 66 - - 65 - - 67 - - 75 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.248975766Z - restimestampmock: 2024-02-09T10:20:50.24899789Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-13 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.252045225Z - restimestampmock: 2024-02-09T10:20:50.252072266Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-14 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAAYdTRUxFQ1QgcGdfY2F0YWxvZy5wZ19jbGFzcy5yZWxuYW1lIApGUk9NIHBnX2NhdGFsb2cucGdfY2xhc3MgSk9JTiBwZ19jYXRhbG9nLnBnX25hbWVzcGFjZSBPTiBwZ19jYXRhbG9nLnBnX25hbWVzcGFjZS5vaWQgPSBwZ19jYXRhbG9nLnBnX2NsYXNzLnJlbG5hbWVzcGFjZSAKV0hFUkUgcGdfY2F0YWxvZy5wZ19jbGFzcy5yZWxuYW1lID0gJ3N0dWRlbnRzJyBBTkQgcGdfY2F0YWxvZy5wZ19jbGFzcy5yZWxraW5kID0gQU5ZIChBUlJBWVsncicsICdwJywgJ2YnLCAndicsICdtJ10pIEFORCBwZ19jYXRhbG9nLnBnX3RhYmxlX2lzX3Zpc2libGUocGdfY2F0YWxvZy5wZ19jbGFzcy5vaWQpIEFORCBwZ19jYXRhbG9nLnBnX25hbWVzcGFjZS5uc3BuYW1lICE9ICdwZ19jYXRhbG9nJwA= - query: - string: SELECT pg_catalog.pg_class.relname FROM pg_catalog.pg_class JOIN pg_catalog.pg_namespace ON pg_catalog.pg_namespace.oid = pg_catalog.pg_class.relnamespace WHERE pg_catalog.pg_class.relname = 'students' AND pg_catalog.pg_class.relkind = ANY (ARRAY['r', 'p', 'f', 'v', 'm']) AND pg_catalog.pg_table_is_visible(pg_catalog.pg_class.oid) AND pg_catalog.pg_namespace.nspname != 'pg_catalog' - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAACAAAXJlbG5hbWUAAAAE6wACAAAAEwBA/////wAARAAAABIAAQAAAAhzdHVkZW50c0MAAAANU0VMRUNUIDEAWgAAAAVU - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 49 - data_row: [{row_values: [students]}, {row_values: [students]}, {row_values: [students]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [114, 101, 108, 110, 97, 109, 101], table_oid: 1259, table_attribute_number: 2, data_type_oid: 19, data_type_size: 64, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.253162445Z - restimestampmock: 2024-02-09T10:20:50.253222319Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-15 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: COMMIT - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 67 - - 79 - - 77 - - 77 - - 73 - - 84 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:20:50.254107087Z - restimestampmock: 2024-02-09T10:20:50.25412767Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-16 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.542685552Z - restimestampmock: 2024-02-09T10:21:01.542714843Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-17 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAATBTRUxFQ1Qgc3R1ZGVudHMuIklEIiBBUyAic3R1ZGVudHNfSUQiLCBzdHVkZW50cy4iTmFtZSIgQVMgInN0dWRlbnRzX05hbWUiLCBzdHVkZW50cy4iRW1haWwiIEFTICJzdHVkZW50c19FbWFpbCIsIHN0dWRlbnRzLiJIYXNoZWQgUGFzc3dvcmQiIEFTICJzdHVkZW50c19IYXNoZWQgUGFzc3dvcmQiLCBzdHVkZW50cy4iU3ViamVjdCBTdHJlYW0iIEFTICJzdHVkZW50c19TdWJqZWN0IFN0cmVhbSIgCkZST00gc3R1ZGVudHMgCldIRVJFIHN0dWRlbnRzLiJFbWFpbCIgPSAnZXZhd2hpdGVAZXhhbXBsZS5jb20nIAogTElNSVQgMQA= - query: - string: SELECT students."ID" AS "students_ID", students."Name" AS "students_Name", students."Email" AS "students_Email", students."Hashed Password" AS "students_Hashed Password", students."Subject Stream" AS "students_Subject Stream" FROM students WHERE students."Email" = 'evawhite@example.com' LIMIT 1 - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 48 - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 78, 97, 109, 101], table_oid: 24577, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 69, 109, 97, 105, 108], table_oid: 24577, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 72, 97, 115, 104, 101, 100, 32, 80, 97, 115, 115, 119, 111, 114, 100], table_oid: 24577, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 83, 117, 98, 106, 101, 99, 116, 32, 83, 116, 114, 101, 97, 109], table_oid: 24577, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.543969268Z - restimestampmock: 2024-02-09T10:21:01.544053057Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-18 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: INSERT INTO students ("Name", "Email", "Hashed Password", "Subject Stream") VALUES ('Eva White', 'evawhite@example.com', 'sfwbxijuf222', 'Mathematics') RETURNING students."ID" - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAABsAAUlEAAAAYAEAAQAAABcABP////8AAEQAAAALAAEAAAABMUMAAAAPSU5TRVJUIDAgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 73 - - 78 - - 83 - - 69 - - 82 - - 84 - - 32 - - 48 - - 32 - - 49 - data_row: [{row_values: ["1"]}, {row_values: ["1"]}, {row_values: ["1"]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.546426702Z - restimestampmock: 2024-02-09T10:21:01.546463701Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-19 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: COMMIT - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 67 - - 79 - - 77 - - 77 - - 73 - - 84 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.551006372Z - restimestampmock: 2024-02-09T10:21:01.55108062Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-20 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.552699118Z - restimestampmock: 2024-02-09T10:21:01.552721743Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-21 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAAJtTRUxFQ1Qgc3R1ZGVudHMuIklEIiwgc3R1ZGVudHMuIk5hbWUiLCBzdHVkZW50cy4iRW1haWwiLCBzdHVkZW50cy4iSGFzaGVkIFBhc3N3b3JkIiwgc3R1ZGVudHMuIlN1YmplY3QgU3RyZWFtIiAKRlJPTSBzdHVkZW50cyAKV0hFUkUgc3R1ZGVudHMuIklEIiA9IDEA - query: - string: SELECT students."ID", students."Name", students."Email", students."Hashed Password", students."Subject Stream" FROM students WHERE students."ID" = 1 - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAAI0ABUlEAAAAYAEAAQAAABcABP////8AAE5hbWUAAABgAQACAAAEE////////wAARW1haWwAAABgAQADAAAEE////////wAASGFzaGVkIFBhc3N3b3JkAAAAYAEABAAABBP///////8AAFN1YmplY3QgU3RyZWFtAAAAYAEABQAABBP///////8AAEQAAABPAAUAAAABMQAAAAlFdmEgV2hpdGUAAAAUZXZhd2hpdGVAZXhhbXBsZS5jb20AAAAMc2Z3YnhpanVmMjIyAAAAC01hdGhlbWF0aWNzQwAAAA1TRUxFQ1QgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 49 - data_row: [{row_values: ["1", Eva White, evawhite@example.com, sfwbxijuf222, Mathematics]}, {row_values: ["1", Eva White, evawhite@example.com, sfwbxijuf222, Mathematics]}, {row_values: ["1", Eva White, evawhite@example.com, sfwbxijuf222, Mathematics]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {name: [78, 97, 109, 101], table_oid: 24577, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [69, 109, 97, 105, 108], table_oid: 24577, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [72, 97, 115, 104, 101, 100, 32, 80, 97, 115, 115, 119, 111, 114, 100], table_oid: 24577, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [83, 117, 98, 106, 101, 99, 116, 32, 83, 116, 114, 101, 97, 109], table_oid: 24577, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.553203147Z - restimestampmock: 2024-02-09T10:21:01.553236062Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-22 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: ROLLBACK - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 82 - - 79 - - 76 - - 76 - - 66 - - 65 - - 67 - - 75 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:01.556089153Z - restimestampmock: 2024-02-09T10:21:01.556110861Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-23 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.223148624Z - restimestampmock: 2024-02-09T10:21:11.223211164Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-24 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAAS9TRUxFQ1Qgc3R1ZGVudHMuIklEIiBBUyAic3R1ZGVudHNfSUQiLCBzdHVkZW50cy4iTmFtZSIgQVMgInN0dWRlbnRzX05hbWUiLCBzdHVkZW50cy4iRW1haWwiIEFTICJzdHVkZW50c19FbWFpbCIsIHN0dWRlbnRzLiJIYXNoZWQgUGFzc3dvcmQiIEFTICJzdHVkZW50c19IYXNoZWQgUGFzc3dvcmQiLCBzdHVkZW50cy4iU3ViamVjdCBTdHJlYW0iIEFTICJzdHVkZW50c19TdWJqZWN0IFN0cmVhbSIgCkZST00gc3R1ZGVudHMgCldIRVJFIHN0dWRlbnRzLiJFbWFpbCIgPSAnam9obmRvZUBleGFtcGxlLmNvbScgCiBMSU1JVCAxAA== - query: - string: SELECT students."ID" AS "students_ID", students."Name" AS "students_Name", students."Email" AS "students_Email", students."Hashed Password" AS "students_Hashed Password", students."Subject Stream" AS "students_Subject Stream" FROM students WHERE students."Email" = 'johndoe@example.com' LIMIT 1 - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 48 - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 78, 97, 109, 101], table_oid: 24577, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 69, 109, 97, 105, 108], table_oid: 24577, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 72, 97, 115, 104, 101, 100, 32, 80, 97, 115, 115, 119, 111, 114, 100], table_oid: 24577, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [115, 116, 117, 100, 101, 110, 116, 115, 95, 83, 117, 98, 106, 101, 99, 116, 32, 83, 116, 114, 101, 97, 109], table_oid: 24577, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.224563961Z - restimestampmock: 2024-02-09T10:21:11.224606043Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-25 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: INSERT INTO students ("Name", "Email", "Hashed Password", "Subject Stream") VALUES ('John Doe', 'johndoe@example.com', 'skpioepf234', 'Mathematics') RETURNING students."ID" - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAABsAAUlEAAAAYAEAAQAAABcABP////8AAEQAAAALAAEAAAABMkMAAAAPSU5TRVJUIDAgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 73 - - 78 - - 83 - - 69 - - 82 - - 84 - - 32 - - 48 - - 32 - - 49 - data_row: [{row_values: ["2"]}, {row_values: ["2"]}, {row_values: ["2"]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.226669655Z - restimestampmock: 2024-02-09T10:21:11.226748861Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-26 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: COMMIT - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 67 - - 79 - - 77 - - 77 - - 73 - - 84 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.232155218Z - restimestampmock: 2024-02-09T10:21:11.232190134Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-27 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: BEGIN - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 66 - - 69 - - 71 - - 73 - - 78 - ready_for_query: - txstatus: 84 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.233212565Z - restimestampmock: 2024-02-09T10:21:11.233238147Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-28 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - payload: UQAAAJtTRUxFQ1Qgc3R1ZGVudHMuIklEIiwgc3R1ZGVudHMuIk5hbWUiLCBzdHVkZW50cy4iRW1haWwiLCBzdHVkZW50cy4iSGFzaGVkIFBhc3N3b3JkIiwgc3R1ZGVudHMuIlN1YmplY3QgU3RyZWFtIiAKRlJPTSBzdHVkZW50cyAKV0hFUkUgc3R1ZGVudHMuIklEIiA9IDIA - query: - string: SELECT students."ID", students."Name", students."Email", students."Hashed Password", students."Subject Stream" FROM students WHERE students."ID" = 2 - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [T, D, C, Z] - identifier: ServerResponse - length: 8 - payload: VAAAAI0ABUlEAAAAYAEAAQAAABcABP////8AAE5hbWUAAABgAQACAAAEE////////wAARW1haWwAAABgAQADAAAEE////////wAASGFzaGVkIFBhc3N3b3JkAAAAYAEABAAABBP///////8AAFN1YmplY3QgU3RyZWFtAAAAYAEABQAABBP///////8AAEQAAABMAAUAAAABMgAAAAhKb2huIERvZQAAABNqb2huZG9lQGV4YW1wbGUuY29tAAAAC3NrcGlvZXBmMjM0AAAAC01hdGhlbWF0aWNzQwAAAA1TRUxFQ1QgMQBaAAAABVQ= - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 83 - - 69 - - 76 - - 69 - - 67 - - 84 - - 32 - - 49 - data_row: [{row_values: ["2", John Doe, johndoe@example.com, skpioepf234, Mathematics]}, {row_values: ["2", John Doe, johndoe@example.com, skpioepf234, Mathematics]}, {row_values: ["2", John Doe, johndoe@example.com, skpioepf234, Mathematics]}] - ready_for_query: - txstatus: 84 - row_description: {fields: [{name: [73, 68], table_oid: 24577, table_attribute_number: 1, data_type_oid: 23, data_type_size: 4, type_modifier: -1, format: 0}, {name: [78, 97, 109, 101], table_oid: 24577, table_attribute_number: 2, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [69, 109, 97, 105, 108], table_oid: 24577, table_attribute_number: 3, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [72, 97, 115, 104, 101, 100, 32, 80, 97, 115, 115, 119, 111, 114, 100], table_oid: 24577, table_attribute_number: 4, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}, {name: [83, 117, 98, 106, 101, 99, 116, 32, 83, 116, 114, 101, 97, 109], table_oid: 24577, table_attribute_number: 5, data_type_oid: 1043, data_type_size: -1, type_modifier: -1, format: 0}]} - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.233889547Z - restimestampmock: 2024-02-09T10:21:11.233922754Z ---- -version: api.keploy.io/v1beta1 -kind: Postgres -name: mock-29 -spec: - metadata: - type: config - postgresrequests: - - header: [Q] - identifier: ClientRequest - length: 8 - query: - string: ROLLBACK - msg_type: 81 - auth_type: 0 - postgresresponses: - - header: [C, Z] - identifier: ServerResponse - length: 8 - authentication_md5_password: - salt: - - 0 - - 0 - - 0 - - 0 - command_complete: - - command_tag: - - 82 - - 79 - - 76 - - 76 - - 66 - - 65 - - 67 - - 75 - ready_for_query: - txstatus: 73 - msg_type: 90 - auth_type: 0 - reqtimestampmock: 2024-02-09T10:21:11.236845177Z - restimestampmock: 2024-02-09T10:21:11.236868259Z diff --git a/fastapi-postgres/keploy/test-set-1/tests/test-1.yaml b/fastapi-postgres/keploy/test-set-1/tests/test-1.yaml deleted file mode 100755 index e5100d2..0000000 --- a/fastapi-postgres/keploy/test-set-1/tests/test-1.yaml +++ /dev/null @@ -1,55 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-1 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/students/ - header: - Accept: '*/*' - Content-Length: "105" - Content-Type: application/json - Host: 127.0.0.1:8000 - User-Agent: curl/8.2.1 - body: |- - { - "name": "Eva White", - "email": "evawhite@example.com", - "password": "evawhite111" - } - body_type: "" - timestamp: 2024-02-09T10:21:01.532943145Z - host: "" - resp: - status_code: 200 - header: - Content-Length: "107" - Content-Type: application/json - Date: Fri, 09 Feb 2024 10:21:00 GMT - Server: uvicorn - body: '{"name":"Eva White","email":"evawhite@example.com","password":"sfwbxijuf222","stream":"Mathematics","id":1}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2024-02-09T10:21:03.574647019Z - objects: [] - assertions: - noise: - header.Date: [] - created: 1707474063 -curl: |- - curl --request POST \ - --url http://127.0.0.1:8000/students/ \ - --header 'Host: 127.0.0.1:8000' \ - --header 'User-Agent: curl/8.2.1' \ - --header 'Accept: */*' \ - --header 'Content-Type: application/json' \ - --data '{ - "name": "Eva White", - "email": "evawhite@example.com", - "password": "evawhite111" - }' diff --git a/fastapi-postgres/keploy/test-set-1/tests/test-2.yaml b/fastapi-postgres/keploy/test-set-1/tests/test-2.yaml deleted file mode 100755 index ecddaf6..0000000 --- a/fastapi-postgres/keploy/test-set-1/tests/test-2.yaml +++ /dev/null @@ -1,55 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-2 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/students/ - header: - Accept: '*/*' - Content-Length: "106" - Content-Type: application/json - Host: 127.0.0.1:8000 - User-Agent: curl/8.2.1 - body: |4- - { - "name": "John Doe", - "email": "johndoe@example.com", - "password": "johndoe123" - } - body_type: "" - timestamp: 2024-02-09T10:21:11.21894436Z - host: "" - resp: - status_code: 200 - header: - Content-Length: "104" - Content-Type: application/json - Date: Fri, 09 Feb 2024 10:21:10 GMT - Server: uvicorn - body: '{"name":"John Doe","email":"johndoe@example.com","password":"skpioepf234","stream":"Mathematics","id":2}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2024-02-09T10:21:13.238027535Z - objects: [] - assertions: - noise: - header.Date: [] - created: 1707474073 -curl: |- - curl --request POST \ - --url http://127.0.0.1:8000/students/ \ - --header 'User-Agent: curl/8.2.1' \ - --header 'Accept: */*' \ - --header 'Content-Type: application/json' \ - --header 'Host: 127.0.0.1:8000' \ - --data ' { - "name": "John Doe", - "email": "johndoe@example.com", - "password": "johndoe123" - }' diff --git a/fastapi-postgres/requirements.txt b/fastapi-postgres/requirements.txt index 5201c90..c7ad5e0 100644 --- a/fastapi-postgres/requirements.txt +++ b/fastapi-postgres/requirements.txt @@ -16,7 +16,6 @@ itsdangerous==2.1.2 Jinja2==3.1.2 MarkupSafe==2.1.3 orjson==3.9.8 -psycopg2==2.9.9 psycopg2-binary==2.9.9 pydantic==2.4.2 pydantic-extra-types==2.1.0 diff --git a/fastapi-twilio/README.md b/fastapi-twilio/README.md index 0afbc7e..d1d5ca9 100644 --- a/fastapi-twilio/README.md +++ b/fastapi-twilio/README.md @@ -6,6 +6,7 @@ A sample FastAPI-Twilio app to test Keploy integration capabilities using [FastA ```bash git clone https://github.com/keploy/samples-python.git && cd samples-python/fastapi-twilio +pip3 install coverage pip3 install -r requirements.txt ``` @@ -14,8 +15,7 @@ pip3 install -r requirements.txt Keploy can be installed on Linux directly and on Windows with the help of WSL. Based on your system architecture, install the keploy latest binary release ```bash - curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh - keploy +curl -O https://keploy.io/install.sh && source install.sh ``` ### Get your Twilio Credentials @@ -28,7 +28,7 @@ Once you get the Twilio Account SID, Auth Token, and Phone Number, modify the `. This command will start the recording of API calls:- ```shell -keploy record -c "uvicorn main:app --reload" +keploy record -c "uvicorn main:app" ``` Make API Calls using Hoppscotch, Postman or cURL command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks. @@ -37,25 +37,25 @@ Make API Calls using Hoppscotch, Postman or cURL command. Keploy with capture th 1. Replace the place holder below i.e. `YOUR_REGISTERED_PERSONAL_PHONE_NUMBER` with your registered personal phone number that you linked with Twilio. - ```bash - curl --location 'http://127.0.0.1:8000/send-sms/' \ - --header 'Content-Type: application/json' \ - --data '{ - "Body": "Test, testtt, testttttttssss :)", - "To": "YOUR_REGISTERED_PERSONAL_PHONE_NUMBER", - }' - ``` +```bash +curl --location 'http://127.0.0.1:8000/send-sms/' \ + --header 'Content-Type: application/json' \ + --data-raw '{ + "Body": "Test", + "To": "" + }' +``` 2. Replace the place holder below i.e. `SOME_WRONG_PHONE_NUMBER` with any wrong phone number and make the request. - ```bash - curl --location 'http://127.0.0.1:8000/send-sms/' \ +```bash +curl --location 'http://127.0.0.1:8000/send-sms/' \ --header 'Content-Type: application/json' \ - --data '{ + --data-raw '{ "Body": "Test, testtt, testttttttssss :)", - "To": "SOME_WRONG_PHONE_NUMBER", + "To": "", }' - ``` +``` Now all these API calls were captured as **editable** testcases and written to `keploy/tests` folder. The keploy directory would also have `mocks` file that contains all the outputs of Twilio operations. @@ -64,7 +64,9 @@ Now all these API calls were captured as **editable** testcases and written to ` Now let's run the application in test mode. ```shell -keploy test -c "uvicorn main:app --reload" --delay 10 +keploy test -c "python3 -m uvicorn main:app" --delay 10 ``` -So, no need to setup fake apis like Twilio or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Twilio ๐Ÿ˜„** +So, no need to setup fake apis like Twilio or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Twilio ๐Ÿ˜„** . We can notice that for a single API without using Twilio, we got around 89% of coverage : + +![testRun](./img/testrun.png) diff --git a/fastapi-twilio/img/testrun.png b/fastapi-twilio/img/testrun.png new file mode 100644 index 0000000..8173f8e Binary files /dev/null and b/fastapi-twilio/img/testrun.png differ diff --git a/fastapi-twilio/keploy-config.yaml b/fastapi-twilio/keploy-config.yaml deleted file mode 100755 index c7e3e02..0000000 --- a/fastapi-twilio/keploy-config.yaml +++ /dev/null @@ -1,64 +0,0 @@ -record: - path: "" - # mandatory - command: "" - proxyport: 0 - containerName: "" - networkName: "" - delay: 5 - passThroughPorts: [] -test: - path: "" - # mandatory - command: "" - proxyport: 0 - containerName: "" - networkName: "" - testSets: [] - globalNoise: |- - { - "global": { - "body": {}, - "header": {} - }, - "test-sets": { - "test-set-name": { - "body": {}, - "header": {} - } - } - } - delay: 5 - apiTimeout: 5 - passThroughPorts: [] - # - # Example on using globalNoise - # globalNoise: |- - # { - # "global": { - # "body": { - # # to ignore some values for a field, - # # pass regex patterns to the corresponding array value - # "url": ["https?://\S+", "http://\S+"], - # }, - # "header": { - # # to ignore the entire field, pass an empty array - # "Date: [], - # } - # }, - # # to ignore fields or the corresponding values for a specific test-set, - # # pass the test-set-name as a key to the "test-sets" object and - # # populate the corresponding "body" and "header" objects - # "test-sets": { - # "test-set-1": { - # "body": { - # # ignore all the values for the "url" field - # "url": [] - # }, - # "header": { - # # we can also pass the exact value to ignore for a field - # "User-Agent": ["PostmanRuntime/7.34.0"] - # } - # } - # } - # } diff --git a/fastapi-twilio/keploy.yml b/fastapi-twilio/keploy.yml new file mode 100755 index 0000000..34deba8 --- /dev/null +++ b/fastapi-twilio/keploy.yml @@ -0,0 +1,43 @@ +path: "" +appId: 0 +appName: "" +command: uvicorn main:app +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/fastapi-twilio/keploy/test-set-0/mocks.yaml b/fastapi-twilio/keploy/test-set-0/mocks.yaml deleted file mode 100755 index cd2a8bf..0000000 --- a/fastapi-twilio/keploy/test-set-0/mocks.yaml +++ /dev/null @@ -1,162 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: mocks -spec: - metadata: - name: Http - operation: POST - type: HTTP_CLIENT - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: /2010-04-01/Accounts/AC19413687d9ce28c80cda944730f8b286/Messages.json - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate - Authorization: Basic QUMxOTQxMzY4N2Q5Y2UyOGM4MGNkYTk0NDczMGY4YjI4NjpjMTc0MDc5YzU2NTA0N2FmYWJmNDk5MWI2ZGQ1MmFiYg== - Connection: keep-alive - Content-Length: "82" - Content-Type: application/x-www-form-urlencoded - User-Agent: python-requests/2.31.0 - body: Body=Test%2C+testtt%2C+testttttttssss+%3A%29&From=%2B16413324066&To=%2B91700004379 - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 400 - header: - Access-Control-Allow-Credentials: "true" - Access-Control-Allow-Headers: Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Idempotency-Key - Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS - Access-Control-Allow-Origin: '*' - Access-Control-Expose-Headers: ETag - Connection: keep-alive - Content-Length: 158,158 - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:29 GMT - Strict-Transport-Security: max-age=31536000 - Twilio-Concurrent-Requests: "1" - Twilio-Request-Duration: "0.051" - Twilio-Request-Id: RQec3c4676524fe2951583489e90bc1b33 - X-Api-Domain: api.twilio.com - X-Home-Region: us1 - X-Powered-By: AT-5000 - X-Shenanigans: none - body: '{"code": 21211, "message": "The ''To'' number +9170000XXXX is not a valid phone number", "more_info": "https://www.twilio.com/docs/errors/21211", "status": 400}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 0001-01-01T00:00:00Z - objects: [] - created: 1699953989 - reqTimestampMock: 2023-11-14T14:56:28.791864295+05:30 - resTimestampMock: 2023-11-14T14:56:29.304057844+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Http -name: mocks -spec: - metadata: - name: Http - operation: POST - type: HTTP_CLIENT - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: /2010-04-01/Accounts/AC19413687d9ce28c80cda944730f8b286/Messages.json - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate - Authorization: Basic QUMxOTQxMzY4N2Q5Y2UyOGM4MGNkYTk0NDczMGY4YjI4NjpjMTc0MDc5YzU2NTA0N2FmYWJmNDk5MWI2ZGQ1MmFiYg== - Connection: keep-alive - Content-Length: "83" - Content-Type: application/x-www-form-urlencoded - User-Agent: python-requests/2.31.0 - body: Body=Test%2C+testtt%2C+testttttttssss+%3A%29&From=%2B16413324066&To=%2B917000043797 - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 201 - header: - Access-Control-Allow-Credentials: "true" - Access-Control-Allow-Headers: Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Idempotency-Key - Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS - Access-Control-Allow-Origin: '*' - Access-Control-Expose-Headers: ETag - Connection: keep-alive - Content-Length: 834,834 - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:35 GMT - Twilio-Concurrent-Requests: "1" - Twilio-Request-Duration: "0.131" - Twilio-Request-Id: RQ2f5288499581f3fe12524b11bbb3d866 - X-Api-Domain: api.twilio.com - X-Home-Region: us1 - X-Powered-By: AT-5000 - X-Shenanigans: none - body: '{"body": "Sent from your Twilio trial account - Test, testtt, testttttttssss :)", "num_segments": "1", "direction": "outbound-api", "from": "+16413324066", "date_updated": "Tue, 14 Nov 2023 09:26:35 +0000", "price": null, "error_message": null, "uri": "/2010-04-01/Accounts/AC19413687d9ce28c80cda944730f8b286/Messages/SM2f5288499581f3fe12524b11bbb3d866.json", "account_sid": "AC19413687d9ce28c80cda944730f8b286", "num_media": "0", "to": "+917000043797", "date_created": "Tue, 14 Nov 2023 09:26:35 +0000", "status": "queued", "sid": "SM2f5288499581f3fe12524b11bbb3d866", "date_sent": null, "messaging_service_sid": null, "error_code": null, "price_unit": "USD", "api_version": "2010-04-01", "subresource_uris": {"media": "/2010-04-01/Accounts/AC19413687d9ce28c80cda944730f8b286/Messages/SM2f5288499581f3fe12524b11bbb3d866/Media.json"}}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 0001-01-01T00:00:00Z - objects: [] - created: 1699953995 - reqTimestampMock: 2023-11-14T14:56:34.833506359+05:30 - resTimestampMock: 2023-11-14T14:56:35.27188354+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Http -name: mocks -spec: - metadata: - name: Http - operation: POST - type: HTTP_CLIENT - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: /2010-04-01/Accounts/AC19413687d9ce28c80cda944730f8b286/Messages.json - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate - Authorization: Basic QUMxOTQxMzY4N2Q5Y2UyOGM4MGNkYTk0NDczMGY4YjI4NjpjMTc0MDc5YzU2NTA0N2FmYWJmNDk5MWI2ZGQ1MmFiYg== - Connection: keep-alive - Content-Length: "81" - Content-Type: application/x-www-form-urlencoded - User-Agent: python-requests/2.31.0 - body: Body=Test%2C+testtt%2C+testttttttssss+%3A%29&From=%2B16413324066&To=%2B9170000437 - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 400 - header: - Access-Control-Allow-Credentials: "true" - Access-Control-Allow-Headers: Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Idempotency-Key - Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS - Access-Control-Allow-Origin: '*' - Access-Control-Expose-Headers: ETag - Connection: keep-alive - Content-Length: 335,335 - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:27:21 GMT - Twilio-Concurrent-Requests: "1" - Twilio-Request-Duration: "0.080" - Twilio-Request-Id: RQb54d7f05d29e83bc89889cc136bcd99d - X-Api-Domain: api.twilio.com - X-Home-Region: us1 - X-Powered-By: AT-5000 - X-Shenanigans: none - body: '{"code": 21608, "message": "The number +917000XXXX is unverified. Trial accounts cannot send messages to unverified numbers; verify +917000XXXX at twilio.com/user/account/phone-numbers/verified, or purchase a Twilio number to send messages to unverified numbers", "more_info": "https://www.twilio.com/docs/errors/21608", "status": 400}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 0001-01-01T00:00:00Z - objects: [] - created: 1699954041 - reqTimestampMock: 2023-11-14T14:57:20.914415283+05:30 - resTimestampMock: 2023-11-14T14:57:21.298027703+05:30 diff --git a/fastapi-twilio/keploy/test-set-0/tests/test-1.yaml b/fastapi-twilio/keploy/test-set-0/tests/test-1.yaml deleted file mode 100755 index c088b98..0000000 --- a/fastapi-twilio/keploy/test-set-0/tests/test-1.yaml +++ /dev/null @@ -1,58 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-1 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "75" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: c871b715-7aae-46b6-8e0d-1341aa426624 - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+91700004379" - } - body_type: "" - timestamp: 2023-11-14T14:56:25.800517709+05:30 - resp: - status_code: 200 - header: - Content-Length: "73" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:25 GMT - Server: uvicorn - body: '{"message":"Failed to send SMS. Please check the provided phone number."}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2023-11-14T14:56:32.013566624+05:30 - objects: [] - assertions: - noise: - header.Date: [] - created: 1699953992 -curl: |- - curl --request POST \ - --url http://127.0.0.1:8000/send-sms/ \ - --header 'User-Agent: PostmanRuntime/7.34.0' \ - --header 'Accept: */*' \ - --header 'Postman-Token: c871b715-7aae-46b6-8e0d-1341aa426624' \ - --header 'Host: 127.0.0.1:8000' \ - --header 'Accept-Encoding: gzip, deflate, br' \ - --header 'Connection: keep-alive' \ - --header 'Content-Type: application/json' \ - --data '{ - "Body": "Test, testtt, testttttttssss :)", - "To": "+91700004379" - }' diff --git a/fastapi-twilio/keploy/test-set-0/tests/test-2.yaml b/fastapi-twilio/keploy/test-set-0/tests/test-2.yaml deleted file mode 100755 index bb9db1e..0000000 --- a/fastapi-twilio/keploy/test-set-0/tests/test-2.yaml +++ /dev/null @@ -1,58 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-2 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "76" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: a3780363-733f-4c88-915b-d4d69384822c - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+917000043797" - } - body_type: "" - timestamp: 2023-11-14T14:56:33.722179585+05:30 - resp: - status_code: 200 - header: - Content-Length: "36" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:33 GMT - Server: uvicorn - body: '{"message":"SMS sent successfully!"}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2023-11-14T14:56:37.588988851+05:30 - objects: [] - assertions: - noise: - header.Date: [] - created: 1699953997 -curl: |- - curl --request POST \ - --url http://127.0.0.1:8000/send-sms/ \ - --header 'Content-Type: application/json' \ - --header 'User-Agent: PostmanRuntime/7.34.0' \ - --header 'Accept: */*' \ - --header 'Postman-Token: a3780363-733f-4c88-915b-d4d69384822c' \ - --header 'Host: 127.0.0.1:8000' \ - --header 'Accept-Encoding: gzip, deflate, br' \ - --header 'Connection: keep-alive' \ - --data '{ - "Body": "Test, testtt, testttttttssss :)", - "To": "+917000043797" - }' diff --git a/fastapi-twilio/keploy/test-set-0/tests/test-3.yaml b/fastapi-twilio/keploy/test-set-0/tests/test-3.yaml deleted file mode 100755 index 3a01fb6..0000000 --- a/fastapi-twilio/keploy/test-set-0/tests/test-3.yaml +++ /dev/null @@ -1,58 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-3 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "74" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: 5e8c1a07-c35d-4816-8b32-c6bcfd28d94d - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+9170000437" - } - body_type: "" - timestamp: 2023-11-14T14:57:19.642139975+05:30 - resp: - status_code: 200 - header: - Content-Length: "73" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:27:18 GMT - Server: uvicorn - body: '{"message":"Failed to send SMS. Please check the provided phone number."}' - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2023-11-14T14:57:23.973137683+05:30 - objects: [] - assertions: - noise: - header.Date: [] - created: 1699954043 -curl: |- - curl --request POST \ - --url http://127.0.0.1:8000/send-sms/ \ - --header 'Accept: */*' \ - --header 'Postman-Token: 5e8c1a07-c35d-4816-8b32-c6bcfd28d94d' \ - --header 'Host: 127.0.0.1:8000' \ - --header 'Accept-Encoding: gzip, deflate, br' \ - --header 'Connection: keep-alive' \ - --header 'Content-Type: application/json' \ - --header 'User-Agent: PostmanRuntime/7.34.0' \ - --data '{ - "Body": "Test, testtt, testttttttssss :)", - "To": "+9170000437" - }' diff --git a/fastapi-twilio/keploy/testReports/report-1.yaml b/fastapi-twilio/keploy/testReports/report-1.yaml deleted file mode 100755 index acf2233..0000000 --- a/fastapi-twilio/keploy/testReports/report-1.yaml +++ /dev/null @@ -1,284 +0,0 @@ -version: api.keploy.io/v1beta1 -name: report-1 -status: PASSED -success: 3 -failure: 0 -total: 3 -tests: - - kind: Http - name: report-1 - status: PASSED - started: 1699954104 - completed: 1699954106 - test_case_path: /home/shashwat/test/python-twilio/keploy/test-set-0 - mock_path: "" - test_case_id: test-1 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "75" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: c871b715-7aae-46b6-8e0d-1341aa426624 - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+91700004379" - } - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 200 - header: - Content-Length: "73" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:25 GMT - Server: uvicorn - body: '{"message":"Failed to send SMS. Please check the provided phone number."}' - body_type: "" - 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: - - "73" - actual: - key: Content-Length - value: - - "73" - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Tue, 14 Nov 2023 09:26:25 GMT - actual: - key: Date - value: - - Tue, 14 Nov 2023 09:28:24 GMT - - normal: true - expected: - key: Server - value: - - uvicorn - actual: - key: Server - value: - - uvicorn - body_result: - - normal: true - type: JSON - expected: '{"message":"Failed to send SMS. Please check the provided phone number."}' - actual: '{"message":"Failed to send SMS. Please check the provided phone number."}' - dep_result: [] - - kind: Http - name: report-1 - status: PASSED - started: 1699954106 - completed: 1699954107 - test_case_path: /home/shashwat/test/python-twilio/keploy/test-set-0 - mock_path: "" - test_case_id: test-2 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "76" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: a3780363-733f-4c88-915b-d4d69384822c - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+917000043797" - } - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 200 - header: - Content-Length: "36" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:26:33 GMT - Server: uvicorn - body: '{"message":"SMS sent successfully!"}' - body_type: "" - 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-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Tue, 14 Nov 2023 09:26:33 GMT - actual: - key: Date - value: - - Tue, 14 Nov 2023 09:28:26 GMT - - normal: true - expected: - key: Server - value: - - uvicorn - actual: - key: Server - value: - - uvicorn - - normal: true - expected: - key: Content-Length - value: - - "36" - actual: - key: Content-Length - value: - - "36" - body_result: - - normal: true - type: JSON - expected: '{"message":"SMS sent successfully!"}' - actual: '{"message":"SMS sent successfully!"}' - dep_result: [] - - kind: Http - name: report-1 - status: PASSED - started: 1699954107 - completed: 1699954108 - test_case_path: /home/shashwat/test/python-twilio/keploy/test-set-0 - mock_path: "" - test_case_id: test-3 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://127.0.0.1:8000/send-sms/ - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Connection: keep-alive - Content-Length: "74" - Content-Type: application/json - Host: 127.0.0.1:8000 - Postman-Token: 5e8c1a07-c35d-4816-8b32-c6bcfd28d94d - User-Agent: PostmanRuntime/7.34.0 - body: |- - { - "Body": "Test, testtt, testttttttssss :)", - "To": "+9170000437" - } - body_type: "" - timestamp: 0001-01-01T00:00:00Z - resp: - status_code: 200 - header: - Content-Length: "73" - Content-Type: application/json - Date: Tue, 14 Nov 2023 09:27:18 GMT - Server: uvicorn - body: '{"message":"Failed to send SMS. Please check the provided phone number."}' - body_type: "" - 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-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Tue, 14 Nov 2023 09:27:18 GMT - actual: - key: Date - value: - - Tue, 14 Nov 2023 09:28:27 GMT - - normal: true - expected: - key: Server - value: - - uvicorn - actual: - key: Server - value: - - uvicorn - - normal: true - expected: - key: Content-Length - value: - - "73" - actual: - key: Content-Length - value: - - "73" - body_result: - - normal: true - type: JSON - expected: '{"message":"Failed to send SMS. Please check the provided phone number."}' - actual: '{"message":"Failed to send SMS. Please check the provided phone number."}' - dep_result: [] -test_set: test-set-0 diff --git a/fastapi-twilio/main.py b/fastapi-twilio/main.py index 82800cd..4cbb40c 100644 --- a/fastapi-twilio/main.py +++ b/fastapi-twilio/main.py @@ -3,18 +3,17 @@ from dotenv import load_dotenv from pydantic import BaseModel import os +import asyncio - +# Load environment variables from a .env file load_dotenv() - class Message(BaseModel): Body: str To: str app = FastAPI() - @app.post('/send-sms/') def send_sms(data: Message): twilio_account_sid = os.getenv('TWILIO_ACCOUNT_SID') @@ -37,3 +36,10 @@ def send_sms(data: Message): return {"message": "Failed to send SMS. Please check the provided phone number."} except Exception as e: return {"message": str(e)} + +# Graceful shutdown +@app.on_event("shutdown") +async def shutdown_event(): + print("Shutting down gracefully...") + # Perform any additional cleanup here if needed + # For example, closing database connections or other resources \ No newline at end of file diff --git a/fastapi-twilio/requirements.txt b/fastapi-twilio/requirements.txt index d86cb8b..7a9ca73 100644 --- a/fastapi-twilio/requirements.txt +++ b/fastapi-twilio/requirements.txt @@ -26,3 +26,28 @@ typing_extensions==4.8.0 urllib3==2.0.7 uvicorn==0.24.0.post1 yarl==1.9.2 +blinker==1.5 +chardet==5.1.0 +configobj==5.0.8 +cryptography==38.0.4 +httplib2==0.20.4 +Jinja2==3.1.2 +jsonpatch==1.32 +jsonpointer==2.3 +jsonschema==4.10.3 +markdown-it-py==2.1.0 +MarkupSafe==2.1.2 +mdurl==0.1.2 +netifaces==0.11.0 +oauthlib==3.2.2 +Pygments==2.14.0 +pyparsing==3.0.9 +pyrsistent==0.18.1 +pyserial==3.5 +PySimpleSOAP==1.16.2 +python-debian==0.1.49 +python-debianbts==4.0.1 +PyYAML==6.0 +rich==13.3.1 +six==1.16.0 +ssh-import-id==5.10 diff --git a/flask-mongo/.coverage b/flask-mongo/.coverage deleted file mode 100644 index b9fdbfc..0000000 Binary files a/flask-mongo/.coverage and /dev/null differ diff --git a/flask-mongo/.coveragerc b/flask-mongo/.coveragerc deleted file mode 100644 index 387d12b..0000000 --- a/flask-mongo/.coveragerc +++ /dev/null @@ -1,4 +0,0 @@ -[run] -omit = - /usr/* -sigterm = true \ No newline at end of file diff --git a/flask-mongo/README.md b/flask-mongo/README.md index 526fad3..5239c2b 100644 --- a/flask-mongo/README.md +++ b/flask-mongo/README.md @@ -1,6 +1,7 @@ +# Flask-Mongo Sample Application + This application is a simple student management API built using Python's Flask framework and MongoDB for data storage. It allows you to perform basic CRUD (Create, Read, Update, Delete) operations on student records. The API supports CORS (Cross-Origin Resource Sharing) to facilitate cross-domain requests. -## Table of Contents # Introduction @@ -10,10 +11,18 @@ This application is a simple student management API built using Python's Flask f - Install WSL (`wsl --install`) for Windows Windows. -## Optional ๐Ÿ› ๏ธ +#### Optional ๐Ÿ› ๏ธ - Install Colima( `brew install colima && colima start` ) for MacOS MacOs. +## Install Keploy + +- Install Keploy CLI using the following command: + +```bash +curl -O -L https://keploy.io/install.sh && source install.sh +``` + ## Get Started! ๐ŸŽฌ ## Setup the MongoDB Database ๐Ÿ“ฆ @@ -34,40 +43,16 @@ docker run -p 27017:27017 -d --network backend --name mongo mongo ```bash git clone https://github.com/keploy/samples-python.git && cd samples-python/flask-mongo +pip3 install -r requirements.txt ``` ## Installation ๐Ÿ“ฅ -Depending on your OS, choose your adventure: - --
- Linux Linux or Windows Windows - - Alright, let's equip ourselves with the **latest Keploy binary**: - - ```bash - curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp - - sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy - ``` - - If everything goes right, your screen should look a bit like this: - - Moving on... -
- Run App with Docker Container Docker - - #### Add alias for Keploy: - - ```bash - alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -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 -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy' - ``` - - ### Lights, Camera, Record! ๐ŸŽฅ + ### With Docker ๐ŸŽฅ Build the app image: - ```bash + ```sh docker build -t flask-app:1.0 . ``` @@ -88,7 +73,13 @@ Depending on your OS, choose your adventure: **1. Make a POST request** ```bash - curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345 + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students + ``` + + Let's add one more student: + + ```sh + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students ``` **2. Make a GET request** @@ -226,12 +217,9 @@ Depending on your OS, choose your adventure: Happy coding! โœจ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ปโœจ -
-
- -
- Run App on ๐Ÿง Linux +--- + ## Running In Linux/WSL We'll be running our sample application right on Linux, but just to make things a tad more thrilling, we'll have the database (PostgreSQL) chill on Docker. Ready? Let's get the party started!๐ŸŽ‰ ### ๐Ÿ“ผ Roll the Tape - Recording Time! @@ -262,205 +250,14 @@ Depending on your OS, choose your adventure: **1. Make a POST request** - ```bash - curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345 - ``` - - **2. Make a GET request** - - ```bash - curl http://localhost:6000/students - ``` - - **3. Make a PUT request** - - ```bash - curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345 - ``` - - **4. Make a GET request** - - ```bash - curl http://localhost:6000/students/12345 - ``` - - **5. Make a DELETE request** - - ```bash - curl -X DELETE http://localhost:6000/students/12345 - ``` - - Give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the **Keploy directory** and you'll discover your handiwork in `test-1.yml` and `mocks.yml`. - - ```yaml - version: api.keploy.io/v1beta2 - kind: Http - name: test-1 - spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://localhost:6000/students - header: - Accept: "*/*" - Content-Length: "56" - Content-Type: application/json - Host: localhost:6000 - User-Agent: curl/7.81.0 - body: '{"student_id": "12344", "name": "John Doeww", "age": 10}' - body_type: "" - timestamp: 2023-11-13T13:02:32.241333562Z - resp: - status_code: 200 - header: - Content-Length: "48" - Content-Type: application/json - Date: Mon, 13 Nov 2023 13:02:32 GMT - Server: Werkzeug/2.2.2 Python/3.9.18 - body: | - { - "message": "Student created successfully" - } - body_type: "" - status_message: "" - proto_major: 0 - proto_minor: 0 - timestamp: 2023-11-13T13:02:34.752123715Z - objects: [] - assertions: - noise: - - header.Date - created: 1699880554 - curl: |- - curl --request POST \ - --url http://localhost:6000/students \ - --header 'Host: localhost:6000' \ - --header 'User-Agent: curl/7.81.0' \ - --header 'Accept: */*' \ - --header 'Content-Type: application/json' \ - --data '{"student_id": "12344", "name": "John Doeww", "age": 10}' - ``` - - This is how `mocks.yml` generated would look like:- - - ```yaml - version: api.keploy.io/v1beta2 - kind: Mongo - name: mocks - spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"students","filter":{"student_id":"12345"},"projection":{"_id":{"$numberInt":"0"}},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"vPKsEFRdTLytlbnyVimqIA==","subType":"04"}}},"$db":"studentsdb"} }], checksum: 0 }' - requests: - - header: - length: 187 - requestId: 2127584089 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"find":"students","filter":{"student_id":"12345"},"projection":{"_id":{"$numberInt":"0"}},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"vPKsEFRdTLytlbnyVimqIA==","subType":"04"}}},"$db":"studentsdb"} }' - checksum: 0 - read_delay: 3469848802 - responses: - - header: - length: 166 - requestId: 154 - responseTo: 2127584089 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"student_id":"12345","name":"John Doe","age":{"$numberInt":"20"}}],"id":{"$numberLong":"0"},"ns":"studentsdb.students"},"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 869555 - created: 1699880576 - reqTimestampMock: 2023-11-13T13:02:56.385067848Z - resTimestampMock: 2023-11-13T13:02:56.386374941Z + ```bash + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students ``` - Want to see if everything works as expected? - - #### Run Tests - - Time to put things to the test ๐Ÿงช + Let's add one more student: - ```shell - keploy test -c "python3 app.py" --delay 10 - ``` - - > The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking. - - Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the `mocks.yml`, or fiddle with the request or response in `test-x.yml`. Run the tests again and see the magic unfold!โœจ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ปโœจ - - ## Wrapping it up ๐ŸŽ‰ - - Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible. ๐Ÿ˜Š๐Ÿš€ - - Happy coding! โœจ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ปโœจ -
- -
- -
- --
- MacOS MacOs - - Dive straight in, but first in case you're using **Keploy** with **Colima**, give it a gentle nudge with (`colima start`). Let's make sure it's awake and ready for action! - - ### Add alias for Keploy ๐Ÿฐ: - - For the sake of convenience (and a bit of Mac magic ๐Ÿช„), let's set up a shortcut for Keploy: - - ### Use Keploy with Docker-Desktop - - Note: To run Keploy on MacOS through [Docker](https://docs.docker.com/desktop/release-notes/#4252) the version must be `4.25.2` or above. - - #### Creating Docker Volume - - ```bash - docker volume create --driver local --opt type=debugfs --opt device=debugfs debugfs - ``` - - ```bash - alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v debugfs:/sys/kernel/debug:rw -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy' - ``` - - ### Use Keploy with Colima - - ```bash - alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -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 -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy' - ``` - - ### Lights, Camera, Record! ๐ŸŽฅ - - Build the app image: - - ```bash - docker build -t flask-app:1.0 . - ``` - - Capture the test-cases- - - ```shell - keploy record -c "docker run -p 6000:6000 --name DjangoApp --network backend --name flask-app flask-app:1.0" - ``` - - ๐Ÿ”ฅ**Make some API calls**. Postman, Hoppscotch or even curl - take your pick! - - Let's make URLs short and sweet: - - ### Generate testcases - - To generate testcases we just need to **make some API calls.** - - **1. Make a POST request** - - ```bash - curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345 + ```sh + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students ``` **2. Make a GET request** @@ -577,16 +374,19 @@ Depending on your OS, choose your adventure: reqTimestampMock: 2023-11-13T13:02:56.385067848Z resTimestampMock: 2023-11-13T13:02:56.386374941Z ``` + + On terminal we can see the testcases generated - - Want to see if everything works as expected? + ![keploy testcases](./img/testcases.png) #### Run Tests Time to put things to the test ๐Ÿงช ```shell - keploy test -c "sudo docker run -p 6000:6000 --rm --network backend --name flask-app flask-app:1.0" --delay 10 + keploy test -c "python3 app.py" --delay 10 ``` + ![keploy testrun](./img/testrun-with-coverage.png) > The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking. @@ -594,7 +394,6 @@ Depending on your OS, choose your adventure: ## Wrapping it up ๐ŸŽ‰ - Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible.๐Ÿ˜Š๐Ÿš€ + Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible. ๐Ÿ˜Š๐Ÿš€ - Happy coding! โœจ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ปโœจ -
\ No newline at end of file + Happy coding! โœจ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ปโœจ \ No newline at end of file diff --git a/flask-mongo/__pycache__/app.cpython-310.pyc b/flask-mongo/__pycache__/app.cpython-310.pyc deleted file mode 100644 index e502979..0000000 Binary files a/flask-mongo/__pycache__/app.cpython-310.pyc and /dev/null differ diff --git a/flask-mongo/__pycache__/test_app.cpython-310-pytest-8.1.1.pyc b/flask-mongo/__pycache__/test_app.cpython-310-pytest-8.1.1.pyc deleted file mode 100644 index ca0d856..0000000 Binary files a/flask-mongo/__pycache__/test_app.cpython-310-pytest-8.1.1.pyc and /dev/null differ diff --git a/flask-mongo/__pycache__/test_app.cpython-310.pyc b/flask-mongo/__pycache__/test_app.cpython-310.pyc deleted file mode 100644 index e052133..0000000 Binary files a/flask-mongo/__pycache__/test_app.cpython-310.pyc and /dev/null differ diff --git a/flask-mongo/__pycache__/test_keploy.cpython-310-pytest-8.1.1.pyc b/flask-mongo/__pycache__/test_keploy.cpython-310-pytest-8.1.1.pyc deleted file mode 100644 index f77eaa0..0000000 Binary files a/flask-mongo/__pycache__/test_keploy.cpython-310-pytest-8.1.1.pyc and /dev/null differ diff --git a/flask-mongo/app.py b/flask-mongo/app.py index 9e88224..31c1a76 100644 --- a/flask-mongo/app.py +++ b/flask-mongo/app.py @@ -2,12 +2,14 @@ from pymongo import MongoClient from flask_cors import CORS import collections.abc +from keploy import FlaskCoverageMiddleware app = Flask(__name__) cors = CORS(app, resources={r"/api/*": {"origins": "*"}}) +app.wsgi_app = FlaskCoverageMiddleware(app.wsgi_app) # Connect to MongoDB -client = MongoClient('mongodb://mongo:27017/') +client = MongoClient('mongodb://localhost:27017/') db = client['studentsdb'] students_collection = db['students'] diff --git a/flask-mongo/call.sh b/flask-mongo/call.sh new file mode 100644 index 0000000..ca13ded --- /dev/null +++ b/flask-mongo/call.sh @@ -0,0 +1,13 @@ + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students + + curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12347", "name": "Bob Brown", "age": 24}' http://localhost:6000/students + + curl http://localhost:6000/students + curl http://localhost:6000/students/12345 + curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345 + curl -X DELETE http://localhost:6000/students/12345 \ No newline at end of file diff --git a/flask-mongo/docker-compose.yml b/flask-mongo/docker-compose.yml index 2970065..5e8b47b 100644 --- a/flask-mongo/docker-compose.yml +++ b/flask-mongo/docker-compose.yml @@ -8,7 +8,7 @@ services: volumes: - data:/data/db networks: - - backend + - keploy-network flask-app: image: flask-app:1.0 @@ -20,10 +20,10 @@ services: depends_on: - mongo networks: - - backend + - keploy-network networks: - backend: + keploy-network: external: true volumes: data: \ No newline at end of file diff --git a/flask-mongo/img/testcases.png b/flask-mongo/img/testcases.png new file mode 100644 index 0000000..2199621 Binary files /dev/null and b/flask-mongo/img/testcases.png differ diff --git a/flask-mongo/img/testrun-with-coverage.png b/flask-mongo/img/testrun-with-coverage.png new file mode 100644 index 0000000..2f3ee30 Binary files /dev/null and b/flask-mongo/img/testrun-with-coverage.png differ diff --git a/flask-mongo/keploy.yml b/flask-mongo/keploy.yml new file mode 100755 index 0000000..e71edbf --- /dev/null +++ b/flask-mongo/keploy.yml @@ -0,0 +1,43 @@ +path: "" +appId: 0 +appName: "" +command: python3 app.py +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-mongo/keploy/reports/test-run-0/test-set-0-report.yaml b/flask-mongo/keploy/reports/test-run-0/test-set-0-report.yaml deleted file mode 100644 index c4c5d3c..0000000 --- a/flask-mongo/keploy/reports/test-run-0/test-set-0-report.yaml +++ /dev/null @@ -1,446 +0,0 @@ -version: api.keploy.io/v1beta1 -name: test-set-0-report -status: FAILED -success: 0 -failure: 4 -total: 4 -tests: - - kind: Http - name: test-set-0 - status: FAILED - started: 1713873653 - completed: 1713873653 - test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0 - mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml - test_case_id: test-1 - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Content-Length: "59" - Content-Type: application/json - Host: localhost:5000 - Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1 - User-Agent: PostmanRuntime/7.32.1 - body: '{"title": "Task 6","description": "Description for Task 6"}' - timestamp: 2024-04-22T16:38:39.232565209+05:30 - resp: - status_code: 200 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "267" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:08:39 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "tasks": [ - { - "description": "should update", - "id": "6626362fc7c5eddf174c88e4", - "title": "Updated" - }, - { - "description": "Should work", - "id": "66263667c7c5eddf174c88e5", - "title": "Let's Check another time" - } - ] - } - status_message: OK - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:38:41.245704918+05:30 - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Mon, 22 Apr 2024 11:08:39 GMT - actual: - key: Date - value: - - Tue, 23 Apr 2024 12:00:53 GMT - - normal: true - expected: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - actual: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - - normal: true - expected: - key: Access-Control-Allow-Origin - value: - - '*' - actual: - key: Access-Control-Allow-Origin - value: - - '*' - - normal: false - expected: - key: Content-Length - value: - - "267" - actual: - key: Content-Length - value: - - "191" - body_result: - - normal: true - type: JSON - expected: | - { - "tasks": [ - { - "description": "should update", - "id": "6626362fc7c5eddf174c88e4", - "title": "Updated" - }, - { - "description": "Should work", - "id": "66263667c7c5eddf174c88e5", - "title": "Let's Check another time" - } - ] - } - actual: | - {"tasks":[{"description":"should update","id":"6626362fc7c5eddf174c88e4","title":"Updated"},{"description":"Should work","id":"66263667c7c5eddf174c88e5","title":"Let's Check another time"}]} - dep_result: [] - - kind: Http - name: test-set-0 - status: FAILED - started: 1713873653 - completed: 1713873653 - test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0 - mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml - test_case_id: test-2 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Content-Length: "57" - Content-Type: application/json - Host: localhost:5000 - Postman-Token: 7aabbe61-38ec-4169-a4d8-31cb3546ca01 - User-Agent: PostmanRuntime/7.32.1 - body: '{"title":"Hey, let''s Check","description":"It will work"}' - timestamp: 2024-04-22T16:39:05.814517536+05:30 - resp: - status_code: 201 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "81" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:09:05 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "id": "66264551a6e962a1cbd50429", - "message": "Task created successfully" - } - status_message: Created - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:39:07.866639952+05:30 - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 201 - actual: 201 - headers_result: - - normal: false - expected: - key: Content-Length - value: - - "81" - actual: - key: Content-Length - value: - - "72" - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Mon, 22 Apr 2024 11:09:05 GMT - actual: - key: Date - value: - - Tue, 23 Apr 2024 12:00:53 GMT - - normal: true - expected: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - actual: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - - normal: true - expected: - key: Access-Control-Allow-Origin - value: - - '*' - actual: - key: Access-Control-Allow-Origin - value: - - '*' - body_result: - - normal: false - type: JSON - expected: | - { - "id": "66264551a6e962a1cbd50429", - "message": "Task created successfully" - } - actual: | - {"id":"6627a2f5a20cac37a4bb3d0f","message":"Task created successfully"} - dep_result: [] - - kind: Http - name: test-set-0 - status: FAILED - started: 1713873653 - completed: 1713873653 - test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0 - mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml - test_case_id: test-3 - req: - method: PUT - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks/6626362fc7c5eddf174c88e4 - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Content-Length: "53" - Content-Type: application/json - Host: localhost:5000 - Postman-Token: 89d42b67-eafb-474e-ac5a-1df4982a9fe3 - User-Agent: PostmanRuntime/7.32.1 - body: '{"title": "Updated again","description": "hey there"}' - timestamp: 2024-04-22T16:39:52.181533473+05:30 - resp: - status_code: 200 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "45" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:09:52 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "message": "Task updated successfully" - } - status_message: OK - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:39:54.273657454+05:30 - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Access-Control-Allow-Origin - value: - - '*' - actual: - key: Access-Control-Allow-Origin - value: - - '*' - - normal: false - expected: - key: Content-Length - value: - - "45" - actual: - key: Content-Length - value: - - "40" - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Mon, 22 Apr 2024 11:09:52 GMT - actual: - key: Date - value: - - Tue, 23 Apr 2024 12:00:53 GMT - - normal: true - expected: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - actual: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - body_result: - - normal: true - type: JSON - expected: | - { - "message": "Task updated successfully" - } - actual: | - {"message":"Task updated successfully"} - dep_result: [] - - kind: Http - name: test-set-0 - status: FAILED - started: 1713873653 - completed: 1713873653 - test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0 - mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml - test_case_id: test-4 - req: - method: DELETE - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks/66263667c7c5eddf174c88e5 - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Host: localhost:5000 - Postman-Token: 0f3d6037-f57c-4fb3-be52-e6ffed1566e6 - User-Agent: PostmanRuntime/7.32.1 - body: "" - timestamp: 2024-04-22T16:40:08.615353613+05:30 - resp: - status_code: 200 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "45" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:10:08 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "message": "Task deleted successfully" - } - status_message: OK - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:40:10.646676187+05:30 - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Access-Control-Allow-Origin - value: - - '*' - actual: - key: Access-Control-Allow-Origin - value: - - '*' - - normal: false - expected: - key: Content-Length - value: - - "45" - actual: - key: Content-Length - value: - - "40" - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Mon, 22 Apr 2024 11:10:08 GMT - actual: - key: Date - value: - - Tue, 23 Apr 2024 12:00:53 GMT - - normal: true - expected: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - actual: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - body_result: - - normal: true - type: JSON - expected: | - { - "message": "Task deleted successfully" - } - actual: | - {"message":"Task deleted successfully"} - dep_result: [] -test_set: test-set-0 diff --git a/flask-mongo/keploy/reports/test-run-1/test-set-0-report.yaml b/flask-mongo/keploy/reports/test-run-1/test-set-0-report.yaml deleted file mode 100644 index 61157f7..0000000 --- a/flask-mongo/keploy/reports/test-run-1/test-set-0-report.yaml +++ /dev/null @@ -1,446 +0,0 @@ -version: api.keploy.io/v1beta1 -name: test-set-0-report -status: FAILED -success: 0 -failure: 4 -total: 4 -tests: - - kind: Http - name: test-set-0 - status: FAILED - started: 1713873824 - completed: 1713873824 - test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0 - mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml - test_case_id: test-1 - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Content-Length: "59" - Content-Type: application/json - Host: localhost:5000 - Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1 - User-Agent: PostmanRuntime/7.32.1 - body: '{"title": "Task 6","description": "Description for Task 6"}' - timestamp: 2024-04-22T16:38:39.232565209+05:30 - resp: - status_code: 200 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "267" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:08:39 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "tasks": [ - { - "description": "should update", - "id": "6626362fc7c5eddf174c88e4", - "title": "Updated" - }, - { - "description": "Should work", - "id": "66263667c7c5eddf174c88e5", - "title": "Let's Check another time" - } - ] - } - status_message: OK - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:38:41.245704918+05:30 - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Mon, 22 Apr 2024 11:08:39 GMT - actual: - key: Date - value: - - Tue, 23 Apr 2024 12:03:44 GMT - - normal: true - expected: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - actual: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - - normal: true - expected: - key: Access-Control-Allow-Origin - value: - - '*' - actual: - key: Access-Control-Allow-Origin - value: - - '*' - - normal: false - expected: - key: Content-Length - value: - - "267" - actual: - key: Content-Length - value: - - "191" - body_result: - - normal: true - type: JSON - expected: | - { - "tasks": [ - { - "description": "should update", - "id": "6626362fc7c5eddf174c88e4", - "title": "Updated" - }, - { - "description": "Should work", - "id": "66263667c7c5eddf174c88e5", - "title": "Let's Check another time" - } - ] - } - actual: | - {"tasks":[{"description":"should update","id":"6626362fc7c5eddf174c88e4","title":"Updated"},{"description":"Should work","id":"66263667c7c5eddf174c88e5","title":"Let's Check another time"}]} - dep_result: [] - - kind: Http - name: test-set-0 - status: FAILED - started: 1713873824 - completed: 1713873824 - test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0 - mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml - test_case_id: test-2 - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Content-Length: "57" - Content-Type: application/json - Host: localhost:5000 - Postman-Token: 7aabbe61-38ec-4169-a4d8-31cb3546ca01 - User-Agent: PostmanRuntime/7.32.1 - body: '{"title":"Hey, let''s Check","description":"It will work"}' - timestamp: 2024-04-22T16:39:05.814517536+05:30 - resp: - status_code: 201 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "81" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:09:05 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "id": "66264551a6e962a1cbd50429", - "message": "Task created successfully" - } - status_message: Created - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:39:07.866639952+05:30 - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 201 - actual: 201 - headers_result: - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Mon, 22 Apr 2024 11:09:05 GMT - actual: - key: Date - value: - - Tue, 23 Apr 2024 12:03:44 GMT - - normal: true - expected: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - actual: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - - normal: true - expected: - key: Access-Control-Allow-Origin - value: - - '*' - actual: - key: Access-Control-Allow-Origin - value: - - '*' - - normal: false - expected: - key: Content-Length - value: - - "81" - actual: - key: Content-Length - value: - - "72" - body_result: - - normal: false - type: JSON - expected: | - { - "id": "66264551a6e962a1cbd50429", - "message": "Task created successfully" - } - actual: | - {"id":"6627a3a0dcedca8503554d0d","message":"Task created successfully"} - dep_result: [] - - kind: Http - name: test-set-0 - status: FAILED - started: 1713873824 - completed: 1713873824 - test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0 - mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml - test_case_id: test-3 - req: - method: PUT - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks/6626362fc7c5eddf174c88e4 - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Content-Length: "53" - Content-Type: application/json - Host: localhost:5000 - Postman-Token: 89d42b67-eafb-474e-ac5a-1df4982a9fe3 - User-Agent: PostmanRuntime/7.32.1 - body: '{"title": "Updated again","description": "hey there"}' - timestamp: 2024-04-22T16:39:52.181533473+05:30 - resp: - status_code: 200 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "45" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:09:52 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "message": "Task updated successfully" - } - status_message: OK - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:39:54.273657454+05:30 - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Mon, 22 Apr 2024 11:09:52 GMT - actual: - key: Date - value: - - Tue, 23 Apr 2024 12:03:44 GMT - - normal: true - expected: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - actual: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - - normal: true - expected: - key: Access-Control-Allow-Origin - value: - - '*' - actual: - key: Access-Control-Allow-Origin - value: - - '*' - - normal: false - expected: - key: Content-Length - value: - - "45" - actual: - key: Content-Length - value: - - "40" - body_result: - - normal: true - type: JSON - expected: | - { - "message": "Task updated successfully" - } - actual: | - {"message":"Task updated successfully"} - dep_result: [] - - kind: Http - name: test-set-0 - status: FAILED - started: 1713873824 - completed: 1713873824 - test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0 - mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml - test_case_id: test-4 - req: - method: DELETE - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks/66263667c7c5eddf174c88e5 - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Host: localhost:5000 - Postman-Token: 0f3d6037-f57c-4fb3-be52-e6ffed1566e6 - User-Agent: PostmanRuntime/7.32.1 - body: "" - timestamp: 2024-04-22T16:40:08.615353613+05:30 - resp: - status_code: 200 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "45" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:10:08 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "message": "Task deleted successfully" - } - status_message: OK - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:40:10.646676187+05:30 - noise: - header.Date: [] - result: - status_code: - normal: true - expected: 200 - actual: 200 - headers_result: - - normal: false - expected: - key: Content-Length - value: - - "45" - actual: - key: Content-Length - value: - - "40" - - normal: true - expected: - key: Content-Type - value: - - application/json - actual: - key: Content-Type - value: - - application/json - - normal: true - expected: - key: Date - value: - - Mon, 22 Apr 2024 11:10:08 GMT - actual: - key: Date - value: - - Tue, 23 Apr 2024 12:03:44 GMT - - normal: true - expected: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - actual: - key: Server - value: - - Werkzeug/3.0.2 Python/3.10.12 - - normal: true - expected: - key: Access-Control-Allow-Origin - value: - - '*' - actual: - key: Access-Control-Allow-Origin - value: - - '*' - body_result: - - normal: true - type: JSON - expected: | - { - "message": "Task deleted successfully" - } - actual: | - {"message":"Task deleted successfully"} - dep_result: [] -test_set: test-set-0 diff --git a/flask-mongo/keploy/test-set-0/mocks.yaml b/flask-mongo/keploy/test-set-0/mocks.yaml deleted file mode 100644 index 8b4d319..0000000 --- a/flask-mongo/keploy/test-set-0/mocks.yaml +++ /dev/null @@ -1,319 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Mongo -name: mock-0 -spec: - metadata: - operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo","version": "4.6.3"},"os": {"type": "Linux","name": "Linux","architecture": "x86_64","version": "5.15.146.1-microsoft-standard-WSL2"},"platform": "CPython 3.10.12.final.0"}}, returnFieldsSelector: }' - type: config - requests: - - header: - length: 283 - requestId: 1804289383 - responseTo: 0 - Opcode: 2004 - message: - flags: 0 - collection_name: admin.$cmd - number_to_skip: 0 - number_to_return: -1 - query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo","version":"4.6.3"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.15.146.1-microsoft-standard-WSL2"},"platform":"CPython 3.10.12.final.0"}}' - return_fields_selector: "" - responses: - - header: - length: 329 - requestId: 238 - responseTo: 1804289383 - Opcode: 1 - message: - response_flags: 8 - cursor_id: 0 - starting_from: 0 - number_returned: 1 - documents: - - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1713784113763"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"18"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}' - read_delay: 1010011 - created: 1713784113 - reqTimestampMock: 2024-04-22T16:38:33.762559618+05:30 - resTimestampMock: 2024-04-22T16:38:33.763749062+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Mongo -name: mock-1 -spec: - metadata: - operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo","version": "4.6.3"},"os": {"type": "Linux","name": "Linux","architecture": "x86_64","version": "5.15.146.1-microsoft-standard-WSL2"},"platform": "CPython 3.10.12.final.0"},"compression": []}, returnFieldsSelector: }' - type: config - requests: - - header: - length: 301 - requestId: 1714636915 - responseTo: 0 - Opcode: 2004 - message: - flags: 0 - collection_name: admin.$cmd - number_to_skip: 0 - number_to_return: -1 - query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo","version":"4.6.3"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.15.146.1-microsoft-standard-WSL2"},"platform":"CPython 3.10.12.final.0"},"compression":[]}' - return_fields_selector: "" - responses: - - header: - length: 329 - requestId: 242 - responseTo: 1714636915 - Opcode: 1 - message: - response_flags: 8 - cursor_id: 0 - starting_from: 0 - number_returned: 1 - documents: - - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1713784119236"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"22"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}' - read_delay: 527460 - created: 1713784119 - reqTimestampMock: 2024-04-22T16:38:39.236318621+05:30 - resTimestampMock: 2024-04-22T16:38:39.236994457+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Mongo -name: mock-2 -spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"tasks","filter":{},"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }], checksum: 0 }' - requests: - - header: - length: 113 - requestId: 1957747793 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"find":"tasks","filter":{},"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }' - checksum: 0 - read_delay: 336283 - responses: - - header: - length: 272 - requestId: 243 - responseTo: 1957747793 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"6626362fc7c5eddf174c88e4"},"title":"Updated","description":"should update"},{"_id":{"$oid":"66263667c7c5eddf174c88e5"},"title":"Let''s Check another time","description":"Should work"}],"id":{"$numberLong":"0"},"ns":"task_manager.tasks"},"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 712174 - created: 1713784119 - reqTimestampMock: 2024-04-22T16:38:39.237446806+05:30 - resTimestampMock: 2024-04-22T16:38:39.238329738+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Mongo -name: mock-3 -spec: - metadata: - operation: '{ OpMsg flags: 65536, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }], checksum: 0 }' - type: config - requests: - - header: - length: 134 - requestId: 846930886 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 65536 - sections: - - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }' - checksum: 0 - read_delay: 2621927 - responses: - - header: - length: 313 - requestId: 244 - responseTo: 846930886 - Opcode: 2013 - message: - flagBits: 2 - sections: - - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1713784123771"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"18"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 10005242839 - created: 1713784123 - reqTimestampMock: 2024-04-22T16:38:33.766550283+05:30 - resTimestampMock: 2024-04-22T16:38:43.772009113+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Mongo -name: mock-4 -spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }], checksum: 0 }' - type: config - requests: - - header: - length: 52 - requestId: 1714636915 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }' - checksum: 0 - read_delay: 10012944393 - responses: - - header: - length: 313 - requestId: 245 - responseTo: 1714636915 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1713784123781"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"19"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 458361 - created: 1713784123 - reqTimestampMock: 2024-04-22T16:38:43.781318376+05:30 - resTimestampMock: 2024-04-22T16:38:43.781975276+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Mongo -name: mock-5 -spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }], checksum: 0 }' - type: config - requests: - - header: - length: 65 - requestId: 1957747793 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }' - checksum: 0 - read_delay: 10012662732 - responses: - - header: - length: 314 - requestId: 249 - responseTo: 1957747793 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1713784133794"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"19"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 430352 - created: 1713784133 - reqTimestampMock: 2024-04-22T16:38:53.794777057+05:30 - resTimestampMock: 2024-04-22T16:38:53.795333713+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Mongo -name: mock-6 -spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }, { SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"66264551a6e962a1cbd50429"},"title":"Hey, let''s Check","description":"It will work"} ] }], checksum: 0 }' - requests: - - header: - length: 207 - requestId: 596516649 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"insert":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }' - - '{ SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"66264551a6e962a1cbd50429"},"title":"Hey, let''s Check","description":"It will work"} ] }' - checksum: 0 - read_delay: 26577872780 - responses: - - header: - length: 45 - requestId: 256 - responseTo: 596516649 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 5437683 - created: 1713784145 - reqTimestampMock: 2024-04-22T16:39:05.816402038+05:30 - resTimestampMock: 2024-04-22T16:39:05.822001482+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Mongo -name: mock-7 -spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"update":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }, { SectionSingle identifier: updates , msgs: [ {"q":{"_id":{"$oid":"6626362fc7c5eddf174c88e4"}},"u":{"$set":{"title":"Updated again","description":"hey there"}},"multi":false,"upsert":false} ] }], checksum: 0 }' - requests: - - header: - length: 243 - requestId: 1102520059 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"update":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }' - - '{ SectionSingle identifier: updates , msgs: [ {"q":{"_id":{"$oid":"6626362fc7c5eddf174c88e4"}},"u":{"$set":{"title":"Updated again","description":"hey there"}},"multi":false,"upsert":false} ] }' - checksum: 0 - read_delay: 46361192429 - responses: - - header: - length: 60 - requestId: 273 - responseTo: 1102520059 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"nModified":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 5673350 - created: 1713784192 - reqTimestampMock: 2024-04-22T16:39:52.183391788+05:30 - resTimestampMock: 2024-04-22T16:39:52.189223944+05:30 ---- -version: api.keploy.io/v1beta1 -kind: Mongo -name: mock-8 -spec: - metadata: - operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"delete":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }, { SectionSingle identifier: deletes , msgs: [ {"q":{"_id":{"$oid":"66263667c7c5eddf174c88e5"}},"limit":{"$numberInt":"1"}} ] }], checksum: 0 }' - requests: - - header: - length: 166 - requestId: 1365180540 - responseTo: 0 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"delete":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }' - - '{ SectionSingle identifier: deletes , msgs: [ {"q":{"_id":{"$oid":"66263667c7c5eddf174c88e5"}},"limit":{"$numberInt":"1"}} ] }' - checksum: 0 - read_delay: 16427108137 - responses: - - header: - length: 45 - requestId: 286 - responseTo: 1365180540 - Opcode: 2013 - message: - flagBits: 0 - sections: - - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }' - checksum: 0 - read_delay: 1386879 - created: 1713784208 - reqTimestampMock: 2024-04-22T16:40:08.616520091+05:30 - resTimestampMock: 2024-04-22T16:40:08.61802554+05:30 diff --git a/flask-mongo/keploy/test-set-0/tests/test-1.yaml b/flask-mongo/keploy/test-set-0/tests/test-1.yaml deleted file mode 100644 index fae2cc0..0000000 --- a/flask-mongo/keploy/test-set-0/tests/test-1.yaml +++ /dev/null @@ -1,66 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-1 -spec: - metadata: {} - req: - method: GET - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Content-Length: "59" - Content-Type: application/json - Host: localhost:5000 - Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1 - User-Agent: PostmanRuntime/7.32.1 - body: '{"title": "Task 6","description": "Description for Task 6"}' - timestamp: 2024-04-22T16:38:39.232565209+05:30 - resp: - status_code: 200 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "267" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:08:39 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "tasks": [ - { - "description": "should update", - "id": "6626362fc7c5eddf174c88e4", - "title": "Updated" - }, - { - "description": "Should work", - "id": "66263667c7c5eddf174c88e5", - "title": "Let's Check another time" - } - ] - } - status_message: OK - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:38:41.245704918+05:30 - objects: [] - assertions: - noise: - header.Date: [] - created: 1713784121 -curl: |- - curl --request GET \ - --url http://localhost:5000/api/tasks \ - --header 'Host: localhost:5000' \ - --header 'User-Agent: PostmanRuntime/7.32.1' \ - --header 'Accept: */*' \ - --header 'Content-Type: application/json' \ - --header 'Connection: keep-alive' \ - --header 'Cache-Control: no-cache' \ - --header 'Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1' \ - --header 'Accept-Encoding: gzip, deflate, br' \ - --data '{"title": "Task 6","description": "Description for Task 6"}' diff --git a/flask-mongo/keploy/test-set-0/tests/test-2.yaml b/flask-mongo/keploy/test-set-0/tests/test-2.yaml deleted file mode 100644 index 640154f..0000000 --- a/flask-mongo/keploy/test-set-0/tests/test-2.yaml +++ /dev/null @@ -1,56 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-2 -spec: - metadata: {} - req: - method: POST - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Content-Length: "57" - Content-Type: application/json - Host: localhost:5000 - Postman-Token: 7aabbe61-38ec-4169-a4d8-31cb3546ca01 - User-Agent: PostmanRuntime/7.32.1 - body: '{"title":"Hey, let''s Check","description":"It will work"}' - timestamp: 2024-04-22T16:39:05.814517536+05:30 - resp: - status_code: 201 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "81" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:09:05 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "id": "66264551a6e962a1cbd50429", - "message": "Task created successfully" - } - status_message: Created - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:39:07.866639952+05:30 - objects: [] - assertions: - noise: - header.Date: [] - created: 1713784147 -curl: |- - curl --request POST \ - --url http://localhost:5000/api/tasks \ - --header 'Accept-Encoding: gzip, deflate, br' \ - --header 'Connection: keep-alive' \ - --header 'User-Agent: PostmanRuntime/7.32.1' \ - --header 'Host: localhost:5000' \ - --header 'Cache-Control: no-cache' \ - --header 'Accept: */*' \ - --header 'Postman-Token: 7aabbe61-38ec-4169-a4d8-31cb3546ca01' \ - --header 'Content-Type: application/json' \ - --data '{"title":"Hey, let's Check","description":"It will work"}' diff --git a/flask-mongo/keploy/test-set-0/tests/test-3.yaml b/flask-mongo/keploy/test-set-0/tests/test-3.yaml deleted file mode 100644 index 3844c87..0000000 --- a/flask-mongo/keploy/test-set-0/tests/test-3.yaml +++ /dev/null @@ -1,55 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-3 -spec: - metadata: {} - req: - method: PUT - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks/6626362fc7c5eddf174c88e4 - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Content-Length: "53" - Content-Type: application/json - Host: localhost:5000 - Postman-Token: 89d42b67-eafb-474e-ac5a-1df4982a9fe3 - User-Agent: PostmanRuntime/7.32.1 - body: '{"title": "Updated again","description": "hey there"}' - timestamp: 2024-04-22T16:39:52.181533473+05:30 - resp: - status_code: 200 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "45" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:09:52 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "message": "Task updated successfully" - } - status_message: OK - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:39:54.273657454+05:30 - objects: [] - assertions: - noise: - header.Date: [] - created: 1713784194 -curl: |- - curl --request PUT \ - --url http://localhost:5000/api/tasks/6626362fc7c5eddf174c88e4 \ - --header 'Accept: */*' \ - --header 'Content-Type: application/json' \ - --header 'User-Agent: PostmanRuntime/7.32.1' \ - --header 'Host: localhost:5000' \ - --header 'Accept-Encoding: gzip, deflate, br' \ - --header 'Cache-Control: no-cache' \ - --header 'Postman-Token: 89d42b67-eafb-474e-ac5a-1df4982a9fe3' \ - --header 'Connection: keep-alive' \ - --data '{"title": "Updated again","description": "hey there"}' diff --git a/flask-mongo/keploy/test-set-0/tests/test-4.yaml b/flask-mongo/keploy/test-set-0/tests/test-4.yaml deleted file mode 100644 index 9888fea..0000000 --- a/flask-mongo/keploy/test-set-0/tests/test-4.yaml +++ /dev/null @@ -1,51 +0,0 @@ -version: api.keploy.io/v1beta1 -kind: Http -name: test-4 -spec: - metadata: {} - req: - method: DELETE - proto_major: 1 - proto_minor: 1 - url: http://localhost:5000/api/tasks/66263667c7c5eddf174c88e5 - header: - Accept: '*/*' - Accept-Encoding: gzip, deflate, br - Cache-Control: no-cache - Connection: keep-alive - Host: localhost:5000 - Postman-Token: 0f3d6037-f57c-4fb3-be52-e6ffed1566e6 - User-Agent: PostmanRuntime/7.32.1 - body: "" - timestamp: 2024-04-22T16:40:08.615353613+05:30 - resp: - status_code: 200 - header: - Access-Control-Allow-Origin: '*' - Content-Length: "45" - Content-Type: application/json - Date: Mon, 22 Apr 2024 11:10:08 GMT - Server: Werkzeug/3.0.2 Python/3.10.12 - body: | - { - "message": "Task deleted successfully" - } - status_message: OK - proto_major: 0 - proto_minor: 0 - timestamp: 2024-04-22T16:40:10.646676187+05:30 - objects: [] - assertions: - noise: - header.Date: [] - created: 1713784210 -curl: | - curl --request DELETE \ - --url http://localhost:5000/api/tasks/66263667c7c5eddf174c88e5 \ - --header 'Accept-Encoding: gzip, deflate, br' \ - --header 'Connection: keep-alive' \ - --header 'User-Agent: PostmanRuntime/7.32.1' \ - --header 'Accept: */*' \ - --header 'Cache-Control: no-cache' \ - --header 'Postman-Token: 0f3d6037-f57c-4fb3-be52-e6ffed1566e6' \ - --header 'Host: localhost:5000' \ diff --git a/flask-mongo/requirements.txt b/flask-mongo/requirements.txt index 7a03746..cbc61f9 100644 --- a/flask-mongo/requirements.txt +++ b/flask-mongo/requirements.txt @@ -1,4 +1,42 @@ Flask pymongo==4.4.1 Flask-Cors==3.0.10 -Werkzeug==2.2.2 \ No newline at end of file +Werkzeug==2.2.2 +annotated-types==0.7.0 +anyio==4.4.0 +certifi==2024.7.4 +charset-normalizer==3.3.2 +click==8.1.7 +coverage==7.6.0 +dnspython==2.6.1 +email_validator==2.2.0 +fastapi==0.111.1 +fastapi-cli==0.0.4 +h11==0.14.0 +httpcore==1.0.5 +httptools==0.6.1 +httpx==0.27.0 +idna==3.7 +Jinja2==3.1.4 +keploy==2.0.0a39 +markdown-it-py==3.0.0 +MarkupSafe==2.1.5 +mdurl==0.1.2 +pydantic==2.8.2 +pydantic_core==2.20.1 +Pygments==2.18.0 +python-dotenv==1.0.1 +python-multipart==0.0.9 +PyYAML==6.0.1 +requests==2.32.3 +rich==13.7.1 +shellingham==1.5.4 +sniffio==1.3.1 +starlette==0.37.2 +typer==0.12.3 +typing_extensions==4.12.2 +urllib3==2.2.2 +uvicorn==0.30.3 +uvloop==0.19.0 +watchfiles==0.22.0 +websockets==12.0