diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc75446 --- /dev/null +++ b/.gitignore @@ -0,0 +1,55 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# Virtual Environment +venv/ +ENV/ +env/ +.venv + +# Pytest +.pytest_cache/ +.coverage +htmlcov/ +.tox/ +*.log + +# Reports +reports/ +*.html + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ +.DS_Store + +# Environment Variables +.env +.env.local + +# Temp files +*.tmp +*.bak \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..24cab40 --- /dev/null +++ b/README.md @@ -0,0 +1,87 @@ +# API Test Automation with Python + +A comprehensive API testing framework using Python, pytest, and the Requests library. + +## Project Overview + +This project provides automated tests for various REST APIs including: +- **Fakerest API** - Activity management endpoints +- **GoRest API** - User authentication and data operations +- **Bookings API** - Hotel booking management +- **ReqRes API** - User creation and update operations + +## Tech Stack + +- **Python** - Programming language +- **pytest** - Testing framework +- **requests** - HTTP library for API calls + +## Project Structure + +``` +API_Test_Automation_Python/ +├── python_api_testing/ # Main API test implementations +│ ├── faker_rest_api_collection/ +│ ├── go_rest_api_collection/ +│ ├── bookings_api_collection/ +│ └── reqres_api_collection/ +├── tests/ # Test files +├── postman/ # Postman collections for reference +├── utils/ # Utility functions +├── conftest.py # pytest configuration +├── pytest.ini # pytest settings +└── requirements.txt # Python dependencies +``` + +## Prerequisites + +- Python 3.7+ +- pip + +## Installation + +1. Create a virtual environment: + ```bash + python -m venv venv + ``` + +2. Activate the virtual environment: + - Windows: `venv\Scripts\activate` + - Unix/MacOS: `source venv/bin/activate` + +3. Install dependencies: + ```bash + pip install -r requirements.txt + ``` + +## Running Tests + +Run all tests: +```bash +pytest +``` + +Run specific test file: +```bash +pytest tests/test_get_activities.py +``` + +Run with HTML report: +```bash +pytest --html=reports/report.html +``` + +## Configuration + +Test configuration is in `pytest.ini`: +- Max failures before stopping: 2 +- Verbose output enabled +- HTML report generation + +## Reports + +Test reports are generated in the `reports/` directory with timestamps. + +## License + +MIT License \ No newline at end of file diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..66c28e2 --- /dev/null +++ b/conftest.py @@ -0,0 +1,16 @@ +import pytest +from datetime import datetime + + +@pytest.hookimpl(tryfirst=True) +def pytest_configure(config): + import os + report_dir = os.path.join(os.path.dirname(__file__), "reports") + now = datetime.now().strftime("%d-%m-%y-%H_%M_%S") + config.option.htmlpath = f"{report_dir}/reports_{now}.html" + + +def setup_teardom(scope="session", autouse=True): + print("Starting...") + yield + print("Ending...") diff --git a/postman/GoRest.in.postman_collection.json b/postman/GoRest.in.postman_collection.json new file mode 100644 index 0000000..373deab --- /dev/null +++ b/postman/GoRest.in.postman_collection.json @@ -0,0 +1 @@ +{"info":{"_postman_id":"9f3a1c2d-4b5e-6f7a-8b9c-0d1e2f3a4b5c","name":"GoRest.in — Mock REST API","description":"Free mock REST API for QA & SDET students. Drop-in replacement for gorest.co.in.\n\nBase URL: https://gorest.in/public/v2/users\n\nBuilt by Naveen AutomationLabs — https://www.youtube.com/@naveenAutomationLabs\n\nHow to use:\n- GET requests: no token needed\n- POST/PUT/PATCH/DELETE: any Bearer token works (e.g. demo-token)\n- Use 'blocked-token' to trigger 403 intentionally\n- Append .xml to any URL for XML responses","schema":"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},"variable":[{"key":"baseUrl","value":"https://gorest.in/public/v2","type":"string"},{"key":"token","value":"demo-token","type":"string"},{"key":"userId","value":"1001","type":"string"}],"item":[{"name":"Users","item":[{"name":"GET All Users","request":{"method":"GET","header":[],"url":{"raw":"https://gorest.in/public/v2/users","host":["gorest.in"],"path":["public","v2","users"]},"description":"Returns a paginated list of all users. No token required.\n\nSupports query params: ?name= ?email= ?gender= ?status= ?page= ?per_page="},"response":[]},{"name":"GET All Users — Paginated","request":{"method":"GET","header":[],"url":{"raw":"https://gorest.in/public/v2/users?page=1&per_page=10","host":["gorest.in"],"path":["public","v2","users"],"query":[{"key":"page","value":"1"},{"key":"per_page","value":"10"}]},"description":"Paginated request. Default per_page is 10, max is 100."},"response":[]},{"name":"GET All Users — Filter by Status","request":{"method":"GET","header":[],"url":{"raw":"https://gorest.in/public/v2/users?status=active","host":["gorest.in"],"path":["public","v2","users"],"query":[{"key":"status","value":"active"}]},"description":"Filter users by status. Values: active | inactive"},"response":[]},{"name":"GET All Users — Filter by Gender","request":{"method":"GET","header":[],"url":{"raw":"https://gorest.in/public/v2/users?gender=male","host":["gorest.in"],"path":["public","v2","users"],"query":[{"key":"gender","value":"male"}]},"description":"Filter users by gender. Values: male | female"},"response":[]},{"name":"GET All Users — XML Response","request":{"method":"GET","header":[{"key":"Accept","value":"application/xml","type":"text"}],"url":{"raw":"https://gorest.in/public/v2/users","host":["gorest.in"],"path":["public","v2","users"]},"description":"Returns users in XML format using Accept header.\n\nAlternatively, use URL suffix: GET {{baseUrl}}/users.xml"},"response":[]},{"name":"GET All Users — XML via URL Suffix","request":{"method":"GET","header":[],"url":{"raw":"https://gorest.in/public/v2/users.xml","host":["gorest.in"],"path":["public","v2","users.xml"]},"description":"Returns all users in XML by appending .xml to the URL."},"response":[]},{"name":"GET Single User by ID","request":{"method":"GET","header":[],"url":{"raw":"https://gorest.in/public/v2/users/{{userId}}","host":["gorest.in"],"path":["public","v2","users","{{userId}}"]},"description":"Fetch a single user by ID. No token required.\n\nReturns 404 if ID does not exist."},"response":[]},{"name":"GET Single User — XML","request":{"method":"GET","header":[],"url":{"raw":"https://gorest.in/public/v2/users/{{userId}}.xml","host":["gorest.in"],"path":["public","v2","users","{{userId}}.xml"]},"description":"Returns a single user in XML format via URL suffix."},"response":[]},{"name":"POST Create User","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Authorization","value":"Bearer {{token}}","type":"text"}],"body":{"mode":"raw","raw":"{\n \"name\": \"Naveen Kumar\",\n \"email\": \"naveen.kumar@example.com\",\n \"gender\": \"male\",\n \"status\": \"active\"\n}","options":{"raw":{"language":"json"}}},"url":{"raw":"https://gorest.in/public/v2/users","host":["gorest.in"],"path":["public","v2","users"]},"description":"Creates a new user. Token required.\n\nRequired fields:\n- name (string)\n- email (string, unique)\n- gender (male | female)\n- status (active | inactive)\n\nReturns 201 on success, 422 on validation failure."},"response":[]},{"name":"PUT Full Update User","request":{"method":"PUT","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Authorization","value":"Bearer {{token}}","type":"text"}],"body":{"mode":"raw","raw":"{\n \"name\": \"Naveen Kumar Updated\",\n \"email\": \"naveen.updated@example.com\",\n \"gender\": \"male\",\n \"status\": \"inactive\"\n}","options":{"raw":{"language":"json"}}},"url":{"raw":"https://gorest.in/public/v2/users/{{userId}}","host":["gorest.in"],"path":["public","v2","users","{{userId}}"]},"description":"Full replace of a user record. All fields required. Token required.\n\nReturns 200 on success, 404 if user not found, 422 on validation failure."},"response":[]},{"name":"PATCH Partial Update User","request":{"method":"PATCH","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Authorization","value":"Bearer {{token}}","type":"text"}],"body":{"mode":"raw","raw":"{\n \"status\": \"inactive\"\n}","options":{"raw":{"language":"json"}}},"url":{"raw":"https://gorest.in/public/v2/users/{{userId}}","host":["gorest.in"],"path":["public","v2","users","{{userId}}"]},"description":"Partial update — only send the fields you want to change. Token required.\n\nReturns 200 on success, 404 if user not found."},"response":[]},{"name":"DELETE User","request":{"method":"DELETE","header":[{"key":"Authorization","value":"Bearer {{token}}","type":"text"}],"url":{"raw":"https://gorest.in/public/v2/users/{{userId}}","host":["gorest.in"],"path":["public","v2","users","{{userId}}"]},"description":"Permanently deletes a user. Token required.\n\nReturns 204 No Content on success, 404 if user not found."},"response":[]}]},{"name":"Status Code Scenarios","item":[{"name":"401 — Missing Token","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n \"name\": \"Test\",\n \"email\": \"t@test.com\",\n \"gender\": \"male\",\n \"status\": \"active\"\n}","options":{"raw":{"language":"json"}}},"url":{"raw":"https://gorest.in/public/v2/users","host":["gorest.in"],"path":["public","v2","users"]},"description":"No Authorization header → 401 Unauthorized"},"response":[]},{"name":"403 — Blocked Token","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Authorization","value":"Bearer blocked-token","type":"text"}],"body":{"mode":"raw","raw":"{\n \"name\": \"Test\",\n \"email\": \"t@test.com\",\n \"gender\": \"male\",\n \"status\": \"active\"\n}","options":{"raw":{"language":"json"}}},"url":{"raw":"https://gorest.in/public/v2/users","host":["gorest.in"],"path":["public","v2","users"]},"description":"Using 'blocked-token' deliberately returns 403 Forbidden — useful for testing forbidden error handling."},"response":[]},{"name":"404 — User Not Found","request":{"method":"GET","header":[],"url":{"raw":"https://gorest.in/public/v2/users/99999","host":["gorest.in"],"path":["public","v2","users","99999"]},"description":"Non-existent user ID → 404 Not Found"},"response":[]},{"name":"405 — Method Not Allowed","request":{"method":"DELETE","header":[{"key":"Authorization","value":"Bearer {{token}}","type":"text"}],"url":{"raw":"https://gorest.in/public/v2/users","host":["gorest.in"],"path":["public","v2","users"]},"description":"DELETE on collection endpoint (no ID) → 405 Method Not Allowed"},"response":[]},{"name":"415 — Missing Content-Type","request":{"method":"POST","header":[{"key":"Authorization","value":"Bearer {{token}}","type":"text"}],"body":{"mode":"raw","raw":"{\n \"name\": \"Test\",\n \"email\": \"t@test.com\",\n \"gender\": \"male\",\n \"status\": \"active\"\n}"},"url":{"raw":"https://gorest.in/public/v2/users","host":["gorest.in"],"path":["public","v2","users"]},"description":"POST without Content-Type: application/json → 415 Unsupported Media Type"},"response":[]},{"name":"422 — Validation Failed","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Authorization","value":"Bearer {{token}}","type":"text"}],"body":{"mode":"raw","raw":"{\n \"name\": \"\",\n \"email\": \"not-an-email\",\n \"gender\": \"unknown\",\n \"status\": \"active\"\n}","options":{"raw":{"language":"json"}}},"url":{"raw":"https://gorest.in/public/v2/users","host":["gorest.in"],"path":["public","v2","users"]},"description":"Invalid field values → 422 Validation Failed with field-level errors"},"response":[]},{"name":"304 — Not Modified (ETag)","request":{"method":"GET","header":[{"key":"If-None-Match","value":"fetch-first-then-paste-etag-here","type":"text"}],"url":{"raw":"https://gorest.in/public/v2/users","host":["gorest.in"],"path":["public","v2","users"]},"description":"Step 1: Make a normal GET /users and copy the ETag response header value.\nStep 2: Paste it as the If-None-Match header value here.\nStep 3: Run — returns 304 Not Modified (empty body)."},"response":[]}]}]} \ No newline at end of file diff --git a/postman/People.postman_collection.json b/postman/People.postman_collection.json new file mode 100644 index 0000000..60a869d --- /dev/null +++ b/postman/People.postman_collection.json @@ -0,0 +1,471 @@ +{ + "info": { + "_postman_id": "f31276b2-8792-4315-9146-f8daea2f2606", + "name": "People", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Read all", + "event": [ + { + "listen": "test", + "script": { + "id": "9609f0ea-4c37-4ad8-90bf-09ae8a80811d", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Read all has kent person\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData[0].fname).to.eql(\"Kent\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{host}}/api/people", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "people" + ] + }, + "description": "- Returns a list of people present in the db with their first name, last name, id and a timestamp on when they were created" + }, + "response": [ + { + "name": "Read all Success", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{host}}/api/people", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "people" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Content-Length", + "value": "482" + }, + { + "key": "Server", + "value": "Werkzeug/1.0.1 Python/3.8.3" + }, + { + "key": "Date", + "value": "Tue, 04 Aug 2020 16:25:21 GMT" + } + ], + "cookie": [], + "body": "[\n {\n \"fname\": \"Kent\",\n \"lname\": \"Brockman\",\n \"person_id\": 2,\n \"timestamp\": \"2020-08-03T02:15:14.681916\"\n },\n {\n \"fname\": \"Bunny\",\n \"lname\": \"Easter\",\n \"person_id\": 3,\n \"timestamp\": \"2020-08-03T02:15:14.682212\"\n },\n {\n \"fname\": \"Doug\",\n \"lname\": \"Farrell\",\n \"person_id\": 1,\n \"timestamp\": \"2020-08-03T02:15:14.680698\"\n },\n {\n \"fname\": \"Alberto\",\n \"lname\": \"Sv\",\n \"person_id\": 4,\n \"timestamp\": \"2020-08-04T15:36:02.522448\"\n }\n]" + } + ] + }, + { + "name": "Read one", + "event": [ + { + "listen": "test", + "script": { + "id": "fd66a4ee-afe8-425f-9b29-8d2043fd70e5", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{host}}/api/people/1", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "people", + "1" + ] + }, + "description": "Returns person in the db with person_id in the path params" + }, + "response": [ + { + "name": "Read one success", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{host}}/api/people/1", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "people", + "1" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Content-Length", + "value": "107" + }, + { + "key": "Server", + "value": "Werkzeug/1.0.1 Python/3.8.3" + }, + { + "key": "Date", + "value": "Tue, 04 Aug 2020 16:28:54 GMT" + } + ], + "cookie": [], + "body": "{\n \"fname\": \"Doug\",\n \"lname\": \"Farrell\",\n \"person_id\": 1,\n \"timestamp\": \"2020-08-03T02:15:14.680698\"\n}" + } + ] + }, + { + "name": "Create", + "event": [ + { + "listen": "test", + "script": { + "id": "284ebb4b-d461-47f7-96d9-bf1d12de4621", + "exec": [ + "pm.test(\"Status code is 204\", function () {", + " pm.response.to.have.status(204);", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{ \n \"fname\": \"TAU\", \n \"lname\": \"User\" \n }" + }, + "url": { + "raw": "{{host}}/api/people", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "people" + ] + }, + "description": "Adds a person to the db" + }, + "response": [ + { + "name": "Create Success", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{ \n \"fname\": \"TAU\", \n \"lname\": \"User\" \n }" + }, + "url": { + "raw": "{{host}}/api/people", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "people" + ] + } + }, + "status": "NO CONTENT", + "code": 204, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Server", + "value": "Werkzeug/1.0.1 Python/3.8.3" + }, + { + "key": "Date", + "value": "Tue, 04 Aug 2020 16:31:35 GMT" + } + ], + "cookie": [], + "body": null + } + ] + }, + { + "name": "Delete", + "event": [ + { + "listen": "test", + "script": { + "id": "6037ff70-acb0-41a2-b9e1-86b14bd6ff7a", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "text/html" + } + ], + "url": { + "raw": "{{host}}/api/people/4", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "people", + "4" + ] + }, + "description": "Removes a person from the db" + }, + "response": [ + { + "name": "Delete success", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "text/html" + } + ], + "url": { + "raw": "{{host}}/api/people/4", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "people", + "4" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "html", + "header": [ + { + "key": "Content-Type", + "value": "text/html; charset=utf-8" + }, + { + "key": "Content-Length", + "value": "37" + }, + { + "key": "Server", + "value": "Werkzeug/1.0.1 Python/3.8.3" + }, + { + "key": "Date", + "value": "Tue, 04 Aug 2020 15:28:18 GMT" + } + ], + "cookie": [], + "body": "Person with id 4 successfully deleted" + } + ] + }, + { + "name": "Update", + "event": [ + { + "listen": "test", + "script": { + "id": "1c39e6b3-a998-4148-b8f9-b7fa7645423b", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{ \n \"fname\": \"Kento\", \n \"lname\": \"Brockod\" \n }" + }, + "url": { + "raw": "{{host}}/api/people/2", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "people", + "2" + ] + }, + "description": "Updates first, last name of a person by person_id (in path params)" + }, + "response": [ + { + "name": "Update success", + "originalRequest": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{ \n \"fname\": \"Kento\", \n \"lname\": \"Brockod\" \n }" + }, + "url": { + "raw": "{{host}}/api/people/2", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "people", + "2" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Content-Length", + "value": "108" + }, + { + "key": "Server", + "value": "Werkzeug/1.0.1 Python/3.8.3" + }, + { + "key": "Date", + "value": "Tue, 04 Aug 2020 16:36:55 GMT" + } + ], + "cookie": [], + "body": "{\n \"fname\": \"Kento\",\n \"lname\": \"Brockod\",\n \"person_id\": 2,\n \"timestamp\": \"2020-08-04T16:36:55.672790\"\n}" + } + ] + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/postman/covid.postman_collection.json b/postman/covid.postman_collection.json new file mode 100644 index 0000000..35f3970 --- /dev/null +++ b/postman/covid.postman_collection.json @@ -0,0 +1,30 @@ +{ + "info": { + "_postman_id": "7ee38247-7d2d-43b9-ad0e-a1a83db7e5f8", + "name": "Covid tracker", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Get summary", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/api/v1/summary/latest", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "v1", + "summary", + "latest" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file diff --git a/postman/covid.postman_environment.json b/postman/covid.postman_environment.json new file mode 100644 index 0000000..d228250 --- /dev/null +++ b/postman/covid.postman_environment.json @@ -0,0 +1,14 @@ +{ + "id": "4704796a-1f22-4f18-8602-6aa6878e03c2", + "name": "covid", + "values": [ + { + "key": "host", + "value": "https://postman-twitter.herokuapp.com", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2020-12-16T02:04:22.548Z", + "_postman_exported_using": "Postman/7.36.0" +} \ No newline at end of file diff --git a/postman/fakerestapiazure_collection.json b/postman/fakerestapiazure_collection.json new file mode 100644 index 0000000..64750cb --- /dev/null +++ b/postman/fakerestapiazure_collection.json @@ -0,0 +1,1146 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "FakeRESTApi.Web V1", + "version": "v1" + }, + "paths": { + "/api/v1/Activities": { + "get": { + "tags": [ + "Activities" + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Activity" + } + } + }, + "application/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Activity" + } + } + }, + "text/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Activity" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "Activities" + ], + "requestBody": { + "content": { + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + }, + "application/*+json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + }, + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + } + } + } + } + } + }, + "/api/v1/Activities/{id}": { + "get": { + "tags": [ + "Activities" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + }, + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + } + } + } + } + }, + "put": { + "tags": [ + "Activities" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "requestBody": { + "content": { + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + }, + "application/*+json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + }, + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Activity" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Activities" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/api/v1/Authors": { + "get": { + "tags": [ + "Authors" + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Author" + } + } + }, + "application/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Author" + } + } + }, + "text/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Author" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "Authors" + ], + "requestBody": { + "content": { + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + }, + "application/*+json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + }, + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + } + } + } + } + } + }, + "/api/v1/Authors/authors/books/{idBook}": { + "get": { + "tags": [ + "Authors" + ], + "parameters": [ + { + "name": "idBook", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Author" + } + } + }, + "application/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Author" + } + } + }, + "text/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Author" + } + } + } + } + } + } + } + }, + "/api/v1/Authors/{id}": { + "get": { + "tags": [ + "Authors" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + }, + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + } + } + } + } + }, + "put": { + "tags": [ + "Authors" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "requestBody": { + "content": { + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + }, + "application/*+json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + }, + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Author" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Authors" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/api/v1/Books": { + "get": { + "tags": [ + "Books" + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "Books" + ], + "requestBody": { + "content": { + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Book" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Book" + } + }, + "application/*+json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Book" + } + } + } + }, + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/api/v1/Books/{id}": { + "get": { + "tags": [ + "Books" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Book" + } + }, + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Book" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + }, + "put": { + "tags": [ + "Books" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "requestBody": { + "content": { + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Book" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Book" + } + }, + "application/*+json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/Book" + } + } + } + }, + "responses": { + "200": { + "description": "Success" + } + } + }, + "delete": { + "tags": [ + "Books" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/api/v1/CoverPhotos": { + "get": { + "tags": [ + "CoverPhotos" + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + }, + "application/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + }, + "text/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "CoverPhotos" + ], + "requestBody": { + "content": { + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + }, + "application/*+json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + }, + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + } + } + } + } + }, + "/api/v1/CoverPhotos/books/covers/{idBook}": { + "get": { + "tags": [ + "CoverPhotos" + ], + "parameters": [ + { + "name": "idBook", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + }, + "application/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + }, + "text/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + } + } + } + } + } + }, + "/api/v1/CoverPhotos/{id}": { + "get": { + "tags": [ + "CoverPhotos" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + }, + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + } + } + } + }, + "put": { + "tags": [ + "CoverPhotos" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "requestBody": { + "content": { + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + }, + "application/*+json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + }, + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/CoverPhoto" + } + } + } + } + } + }, + "delete": { + "tags": [ + "CoverPhotos" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/api/v1/Users": { + "get": { + "tags": [ + "Users" + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + }, + "application/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + }, + "text/json; v=1.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "Users" + ], + "requestBody": { + "content": { + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/*+json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "responses": { + "200": { + "description": "Success" + } + } + } + }, + "/api/v1/Users/{id}": { + "get": { + "tags": [ + "Users" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + }, + "put": { + "tags": [ + "Users" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "requestBody": { + "content": { + "application/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "text/json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/*+json; v=1.0": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "responses": { + "200": { + "description": "Success" + } + } + }, + "delete": { + "tags": [ + "Users" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "Success" + } + } + } + } + }, + "components": { + "schemas": { + "Activity": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "title": { + "type": "string", + "nullable": true + }, + "dueDate": { + "type": "string", + "format": "date-time" + }, + "completed": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "Author": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "idBook": { + "type": "integer", + "format": "int32" + }, + "firstName": { + "type": "string", + "nullable": true + }, + "lastName": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "Book": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "title": { + "type": "string", + "nullable": true + }, + "description": { + "type": "string", + "nullable": true + }, + "pageCount": { + "type": "integer", + "format": "int32" + }, + "excerpt": { + "type": "string", + "nullable": true + }, + "publishDate": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false + }, + "CoverPhoto": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "idBook": { + "type": "integer", + "format": "int32" + }, + "url": { + "type": "string", + "format": "uri", + "nullable": true + } + }, + "additionalProperties": false + }, + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "userName": { + "type": "string", + "nullable": true + }, + "password": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/postman/people.postman_environment.json b/postman/people.postman_environment.json new file mode 100644 index 0000000..dfee80b --- /dev/null +++ b/postman/people.postman_environment.json @@ -0,0 +1,14 @@ +{ + "id": "ef17a0b8-6f96-41fc-95f3-31d8eb7ddf13", + "name": "people", + "values": [ + { + "key": "host", + "value": "http://0.0.0.0:5000/", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2020-08-04T16:38:26.863Z", + "_postman_exported_using": "Postman/7.29.1" +} \ No newline at end of file diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..0c3a084 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --maxfail=2 --disable-warnings -v --html=reports/reports.html \ No newline at end of file diff --git a/Bookings_API/DeleteBookingsByID.py b/python_api_testing/bookings_api_collection/DeleteBookingsByID.py similarity index 100% rename from Bookings_API/DeleteBookingsByID.py rename to python_api_testing/bookings_api_collection/DeleteBookingsByID.py diff --git a/Bookings_API/GetBookings.py b/python_api_testing/bookings_api_collection/GetBookings.py similarity index 100% rename from Bookings_API/GetBookings.py rename to python_api_testing/bookings_api_collection/GetBookings.py diff --git a/Bookings_API/GetBookingsByID.py b/python_api_testing/bookings_api_collection/GetBookingsByID.py similarity index 100% rename from Bookings_API/GetBookingsByID.py rename to python_api_testing/bookings_api_collection/GetBookingsByID.py diff --git a/Bookings_API/PostBooking.py b/python_api_testing/bookings_api_collection/PostBooking.py similarity index 100% rename from Bookings_API/PostBooking.py rename to python_api_testing/bookings_api_collection/PostBooking.py diff --git a/python_api_testing/faker_rest_api_collection/GetActivities.py b/python_api_testing/faker_rest_api_collection/GetActivities.py new file mode 100644 index 0000000..fd61303 --- /dev/null +++ b/python_api_testing/faker_rest_api_collection/GetActivities.py @@ -0,0 +1,7 @@ +import requests + +response = requests.get(url="https://fakerestapi.azurewebsites.net/api/v1/Activities") + +print("Response Body: ", response.content) +print("\n") +print("Response Status Code: ", response.status_code) diff --git a/python_api_testing/faker_rest_api_collection/GetActivitiesById.py b/python_api_testing/faker_rest_api_collection/GetActivitiesById.py new file mode 100644 index 0000000..63ac168 --- /dev/null +++ b/python_api_testing/faker_rest_api_collection/GetActivitiesById.py @@ -0,0 +1,15 @@ +import requests + + +header = {"Accept": "text/plain; v=1.0"} + +response = requests.get( + url="https://fakerestapi.azurewebsites.net/api/v1/Activities/7", headers=header +) + +print("Response Body: \n", response.content) +print("\n") +print("Response Status Code: ", response.status_code) + + +assert response.status_code == 200 diff --git a/python_api_testing/faker_rest_api_collection/PostActivities.py b/python_api_testing/faker_rest_api_collection/PostActivities.py new file mode 100644 index 0000000..8b4d690 --- /dev/null +++ b/python_api_testing/faker_rest_api_collection/PostActivities.py @@ -0,0 +1,32 @@ +import requests + + +activities_url = "https://fakerestapi.azurewebsites.net/api/v1/Activities" + +request_header = { + "Accept": "text/plain; v=1.0", + "Content-Type": "application/json; v=1.0", +} + +# Request Body +request_payload = { + "id": 34, + "title": "Srinivas API Testing", + "dueDate": "2026-07-12T01:57:59.199Z", + "completed": True, +} + +response = requests.post( + url=activities_url, + headers=request_header, + json=request_payload, +) + +print(response.status_code) +print(response.json()) + +response_body = response.json() +print(response_body["id"]) + +assert response.status_code == 200 +assert response_body["id"] == 34 diff --git a/python_api_testing/faker_rest_api_collection/PutActivitiesById.py b/python_api_testing/faker_rest_api_collection/PutActivitiesById.py new file mode 100644 index 0000000..aa2fd86 --- /dev/null +++ b/python_api_testing/faker_rest_api_collection/PutActivitiesById.py @@ -0,0 +1,37 @@ +import requests + +activities_url = "https://fakerestapi.azurewebsites.net/api/v1/Activities/18" + +request_header = { + "Accept": "text/plain; v=1.0", + "Content-Type": "application/json; v=1.0", +} + +get_Request = requests.get( + url="https://fakerestapi.azurewebsites.net/api/v1/Activities/18", + headers=request_header, +) + +print("Get Request Response: ", get_Request.json()) + + +request_payload = { + "id": 41, + "title": "Srini_Updating_18_41", + "dueDate": "2026-07-12T02:29:57.240Z", + "completed": False, +} + +print("PUT Request Body: ", request_payload) + + +response = requests.put( + url=activities_url, headers=request_header, json=request_payload +) + +print("PUT Response Status Code: ", response.status_code) +print("PUT Response Body: ", response.json()) +print("PUT Response Body-Id: ", response.json()["id"]) + +assert response.status_code == 200 +assert response.json()["id"] == 41 diff --git a/python_api_testing/go_rest_api_collection/PostUsersAuth.py b/python_api_testing/go_rest_api_collection/PostUsersAuth.py new file mode 100644 index 0000000..b055281 --- /dev/null +++ b/python_api_testing/go_rest_api_collection/PostUsersAuth.py @@ -0,0 +1,36 @@ +import requests + +request_url = "https://gorest.in/public/v2/users" + +request_header = { + "Content-Type": "application/json", + "Authorization": "Bearer demo-token", +} + +request_payload = { + "name": "Srini Rao", + "email": "srini.rao9@example.com", + "gender": "male", + "status": "active", +} + +print("POST Request Body: ", request_payload) + +response = requests.post(url=request_url, headers=request_header, json=request_payload) + +print("POST Response Status Code: ", response.status_code) +print("POST Response Body: ", response.json()) + +assert response.status_code == 201 +assert response.json()["name"] == "Srini Rao" + + +get_request_url = "https://gorest.in/public/v2/users" + +# print(get_request_url + "/" + str(response.json()["id"])) + +get_request_by_id = get_request_url + "/" + str(response.json()["id"]) + +get_response_by_id = requests.get(get_request_by_id) + +print("GET Response By ID: ", get_response_by_id.json()) diff --git a/python_api_testing/go_rest_api_collection/PostUsersPassingDataFromJsonFile.py b/python_api_testing/go_rest_api_collection/PostUsersPassingDataFromJsonFile.py new file mode 100644 index 0000000..e6cc307 --- /dev/null +++ b/python_api_testing/go_rest_api_collection/PostUsersPassingDataFromJsonFile.py @@ -0,0 +1,32 @@ +import requests +import json + +base_url = "https://gorest.in/public" + +request_header = { + "Content-Type": "application/json", + "Authorization": "Bearer demo-token", +} + +json_file = open("./Users.json") +json_payload = json.load(json_file) + + +print("POST Request Body: ", json_payload) + + +# response = requests.post( +# url=base_url + "/v2/users", headers=request_header, json=json_payload +# ) + + +# If we are using json, no need to use dumps. But if we are having csv, we need to dumps. +response = requests.post( + url=base_url + "/v2/users", headers=request_header, data=json.dumps(json_payload) +) + +# print(type(response.json())) + + +print("Response Body: ", response.json()) +print("Response Status: ", response.status_code) diff --git a/python_api_testing/go_rest_api_collection/Users.json b/python_api_testing/go_rest_api_collection/Users.json new file mode 100644 index 0000000..44194c7 --- /dev/null +++ b/python_api_testing/go_rest_api_collection/Users.json @@ -0,0 +1,6 @@ +{ + "name": "Srini Rao", + "email": "srini.rao16@example.com", + "gender": "male", + "status": "active" +} \ No newline at end of file diff --git a/ReqRes_API/CreateUsers.py b/python_api_testing/reqres_api_collection/CreateUsers.py similarity index 100% rename from ReqRes_API/CreateUsers.py rename to python_api_testing/reqres_api_collection/CreateUsers.py diff --git a/ReqRes_API/UpdateUsers.py b/python_api_testing/reqres_api_collection/UpdateUsers.py similarity index 100% rename from ReqRes_API/UpdateUsers.py rename to python_api_testing/reqres_api_collection/UpdateUsers.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c465792 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,647 @@ +a2a-sdk==1.1.0 +accelerate==1.14.0 +ag-ui-protocol==0.1.19 +ag2==0.13.4 +agent-lifecycle-toolkit==0.10.1 +aioboto3==15.5.0 +aiobotocore==2.25.1 +aiofile==3.11.1 +aiofiles==24.1.0 +aiohappyeyeballs==2.6.2 +aiohttp==3.14.1 +aiohttp-retry==2.9.1 +aioitertools==0.13.0 +aiolimiter==1.2.1 +aiosignal==1.4.0 +aiosmtpd==1.4.6 +aiosqlite==0.22.1 +alembic==1.18.4 +annotated-doc==0.0.4 +annotated-types==0.7.0 +anthropic==0.109.1 +antlr4-python3-runtime==4.9.3 +anyio==4.13.0 +apify_client==3.0.2 +APScheduler==3.11.2 +argcomplete==3.6.3 +arize-phoenix-otel==0.16.1 +asgiref==3.11.1 +assemblyai==0.35.1 +astrapy==2.2.1 +asttokens==3.0.1 +asyncer==0.0.17 +asyncpg==0.31.0 +atlassian-python-api==3.41.16 +atpublic==7.0.0 +attrs==26.1.0 +Authlib==1.7.2 +babel==2.18.0 +backoff==2.2.1 +bce-python-sdk==0.9.72 +bcrypt==4.0.1 +beartype==0.22.9 +beautifulsoup4==4.12.3 +bert-score==0.3.13 +bidict==0.23.1 +black==26.5.1 +blinker==1.9.0 +boto3==1.40.61 +boto3-stubs==1.43.29 +botocore==1.40.61 +botocore-stubs==1.43.14 +Bottleneck==1.6.0 +brotli==1.2.0 +browsergym-core==0.13.0 +build==1.5.0 +cachetools==7.1.4 +caio==0.9.25 +cassandra-driver==3.30.0 +cassio==0.1.10 +certifi==2026.5.20 +cffi==2.0.0 +chardet==7.4.3 +charset-normalizer==3.4.7 +choreographer==1.3.0 +chromadb==1.5.9 +cleanlab-tlm==1.1.39 +clevercsv==0.8.5 +click==8.4.1 +clickhouse-connect==0.7.19 +cloudpickle==3.1.2 +cohere==5.21.1 +colorama==0.4.6 +coloredlogs==15.0.1 +colorlog==6.10.1 +comm==0.2.3 +composio==0.9.2 +composio-client==1.40.0 +composio-langchain==0.9.2 +contourpy==1.3.3 +coolname==5.0.0 +couchbase==4.6.1 +cramjam==2.11.0 +crc32c==2.8 +cryptography==48.0.1 +cuga==0.2.28 +cuga-oak-health==1.3.0 +cuid==0.4 +cycler==0.12.1 +cyclopts==4.18.0 +datamodel-code-generator==0.63.0 +datasets==4.8.5 +ddgs==9.14.4 +debugpy==1.8.20 +decorator==5.3.1 +defusedxml==0.7.1 +Deprecated==1.3.1 +deprecation==2.1.0 +detect-installer==0.1.0 +dill==0.4.1 +diskcache==5.6.3 +distlib==0.4.3 +distro==1.9.0 +dnspython==2.8.0 +docker==7.1.0 +docling==2.102.1 +docling-core==2.82.0 +docling-ibm-models==3.13.3 +docling-parse==6.2.0 +docling-slim==2.102.1 +docstring_parser==0.18.0 +docutils==0.23 +duckdb==1.5.3 +durationpy==0.10 +dydantic==0.0.8 +dynaconf==3.2.13 +easyocr==1.7.2 +elastic-transport==8.17.1 +elasticsearch==8.19.3 +elevenlabs==1.59.0 +email-validator==2.3.0 +emoji==2.15.0 +et_xmlfile==2.0.0 +evaluate==0.4.6 +Events==0.5 +exceptiongroup==1.3.1 +executing==2.2.1 +faiss-cpu==1.9.0.post1 +fake-useragent==2.2.0 +Faker==40.23.0 +Farama-Notifications==0.0.6 +fast-depends==3.0.8 +fastapi==0.136.3 +fastapi-cli==0.0.24 +fastapi-cloud-cli==0.20.0 +fastapi-pagination==0.15.14 +fastar==0.11.0 +fastavro==1.12.2 +fastembed==0.8.0 +fastmcp==3.4.2 +fastmcp-slim==3.4.2 +fastparquet==2024.11.0 +fastuuid==0.14.0 +filelock==3.29.3 +filetype==1.2.0 +firecrawl-py==1.17.0 +Flask==3.1.3 +flask-cors==6.0.5 +flatbuffers==25.12.19 +fonttools==4.63.0 +frozendict==2.4.7 +frozenlist==1.8.0 +fsspec==2026.2.0 +future==1.0.0 +gassist==0.0.1 +gdown==6.1.0 +genson==1.3.0 +geomet==1.1.0 +gitdb==4.0.12 +GitPython==3.1.50 +google-api-core==2.31.0 +google-api-python-client==2.197.0 +google-auth==2.54.0 +google-auth-httplib2==0.4.0 +google-auth-oauthlib==1.4.0 +google-cloud-aiplatform==1.157.0 +google-cloud-bigquery==3.41.0 +google-cloud-core==2.6.0 +google-cloud-modelarmor==0.7.0 +google-cloud-resource-manager==1.17.0 +google-cloud-storage==3.12.0 +google-cloud-vectorsearch==0.11.0 +google-crc32c==1.8.0 +google-genai==1.75.0 +google-resumable-media==2.10.0 +google_search_results==2.4.2 +googleapis-common-protos==1.75.0 +grandalf==0.8 +graph-retriever==0.8.0 +greenlet==3.5.1 +griffelib==2.0.2 +groq==0.37.1 +grpc-google-iam-v1==0.14.4 +grpcio==1.78.0 +grpcio-status==1.78.0 +gunicorn==26.0.0 +gymnasium==1.3.0 +h11==0.16.0 +h2==4.3.0 +hf-xet==1.5.1 +hpack==4.1.0 +html5lib==1.1 +httpcore==1.0.9 +httplib2==0.31.2 +httptools==0.8.0 +httpx==0.28.1 +httpx-sse==0.4.3 +huggingface_hub==1.19.0 +humanfriendly==10.0 +hvac==2.4.0 +hyperframe==6.1.0 +ibm-cloud-sdk-core==3.24.4 +ibm-cos-sdk==2.14.3 +ibm-cos-sdk-core==2.14.3 +ibm-cos-sdk-s3transfer==2.14.3 +ibm-watsonx-orchestrate-clients==2.8.1 +ibm-watsonx-orchestrate-core==2.8.1 +ibm_db==3.2.9 +ibm_watsonx_ai==1.5.13 +idna==3.18 +ifaddr==0.2.0 +ijson==3.5.0 +ImageIO==2.37.3 +immutabledict==4.3.1 +impit==0.12.0 +importlib_metadata==8.9.0 +importlib_resources==7.1.0 +inflect==7.5.0 +inflection==0.5.1 +iniconfig==2.3.0 +ipykernel==7.2.0 +ipython==9.13.0 +ipython_pygments_lexers==1.1.1 +isort==8.0.1 +itsdangerous==2.2.0 +jaraco.classes==3.4.0 +jaraco.context==6.1.2 +jaraco.functools==4.5.0 +jedi==0.20.0 +jigsawstack==0.2.7 +Jinja2==3.1.6 +jiter==0.15.0 +jmespath==1.0.1 +joblib==1.5.3 +joserfc==1.7.1 +json-rpc==1.15.0 +json_repair==0.30.3 +jsonlines==4.0.0 +jsonpatch==1.33 +jsonpointer==3.1.1 +jsonquerylang==1.1.1 +jsonref==1.1.0 +jsonschema==4.26.0 +jsonschema-path==0.5.0 +jsonschema-specifications==2025.9.1 +jupyter_client==8.8.0 +jupyter_core==5.9.1 +kaleido==1.3.0 +keyring==25.7.0 +kiwisolver==1.5.0 +kubernetes==31.0.0 +langchain==1.2.18 +langchain-anthropic==1.3.5 +langchain-astradb==1.0.0 +langchain-aws==1.1.0 +langchain-chroma==0.2.6 +langchain-classic==1.0.8 +langchain-cohere==0.5.1 +langchain-community==0.4.2 +langchain-core==1.4.7 +langchain-docling==2.0.0 +langchain-elasticsearch==1.0.0 +langchain-experimental==0.4.2 +langchain-google-calendar-tools==0.0.1 +langchain-google-community==3.0.5 +langchain-google-genai==4.1.3 +langchain-google-vertexai==3.2.4 +langchain-graph-retriever==0.8.0 +langchain-groq==1.1.3 +langchain-huggingface==1.2.2 +langchain-ibm==1.1.0 +langchain-litellm==0.6.6 +langchain-mcp-adapters==0.1.14 +langchain-milvus==0.3.3 +langchain-mistralai==1.1.5 +langchain-mongodb==0.11.0 +langchain-nvidia-ai-endpoints==1.0.4 +langchain-ollama==0.3.10 +langchain-openai==1.3.2 +langchain-perplexity==1.4.0 +langchain-pinecone==0.2.13 +langchain-protocol==0.0.17 +langchain-qdrant==1.1.0 +langchain-sambanova==1.0.0 +langchain-text-splitters==1.1.2 +langchain-unstructured==1.0.1 +langchain-weaviate==0.0.6 +langchainhub==0.1.21 +langflow==1.10.0 +langflow-base==0.10.0 +langflow-sdk==0.2.0 +langfuse==3.15.0 +langgraph==1.1.10 +langgraph-checkpoint==4.1.1 +langgraph-prebuilt==1.0.13 +langgraph-sdk==0.3.15 +langsmith==0.8.15 +langwatch==0.10.2 +lark==1.2.2 +latex2mathml==3.81.0 +lazy-loader==0.5 +lfx==1.10.0 +lfx-arxiv==0.1.1 +lfx-docling==0.1.1 +lfx-duckduckgo==0.1.1 +lfx-ibm==0.1.1 +limits==5.8.0 +litellm==1.88.1 +llm-sandbox==0.3.39 +logistro==2.0.1 +loguru==0.7.3 +lomond==0.3.3 +lxml==6.1.1 +lxml_html_clean==0.4.5 +lz4==4.4.5 +magika==0.6.2 +mail-parser==4.4.0 +Mako==1.3.12 +Markdown==3.10.2 +markdown-it-py==4.2.0 +markdown2==2.5.5 +markdownify==1.2.2 +markitdown==0.1.6 +marko==2.2.3 +MarkupSafe==3.0.2 +matplotlib==3.11.0 +matplotlib-inline==0.2.2 +mcp==1.27.2 +mdurl==0.1.2 +mem0ai==2.0.6 +metal_sdk==2.5.1 +metaphor-python==0.1.23 +mmh3==5.2.1 +more-itertools==11.1.0 +mpire==2.10.2 +mpmath==1.3.0 +multidict==6.7.1 +multiprocess==0.70.19 +multitasking==0.0.13 +mypy-boto3-bedrock-runtime==1.43.17 +mypy_extensions==1.1.0 +nanoid==2.0.0 +narwhals==2.22.1 +needle-python==0.6.0 +nest-asyncio==1.6.0 +networkx==3.6.1 +nicegui==3.13.0 +ninja==1.13.0 +nltk==3.9.4 +nodeenv==1.10.0 +numexpr==2.14.1 +numpy==2.4.6 +oauthlib==3.3.1 +ollama==0.6.2 +omegaconf==2.3.1 +onnxruntime==1.23.2 +openai==2.41.1 +openapi-pydantic==0.5.1 +opencv-python==4.13.0.92 +opencv-python-headless==4.13.0.92 +OpenDsStar==1.0.26 +openinference-instrumentation==0.1.53 +openinference-instrumentation-haystack==0.1.34 +openinference-instrumentation-langchain==0.1.66 +openinference-instrumentation-openai==0.1.52 +openinference-semantic-conventions==0.1.30 +openlayer==0.29.1 +openpyxl==3.1.5 +opensearch-py==2.8.0 +opentelemetry-api==1.42.1 +opentelemetry-exporter-otlp==1.42.1 +opentelemetry-exporter-otlp-proto-common==1.42.1 +opentelemetry-exporter-otlp-proto-grpc==1.42.1 +opentelemetry-exporter-otlp-proto-http==1.42.1 +opentelemetry-exporter-prometheus==0.63b1 +opentelemetry-instrumentation==0.63b1 +opentelemetry-instrumentation-agno==0.61.0 +opentelemetry-instrumentation-alephalpha==0.61.0 +opentelemetry-instrumentation-anthropic==0.61.0 +opentelemetry-instrumentation-asgi==0.63b1 +opentelemetry-instrumentation-bedrock==0.61.0 +opentelemetry-instrumentation-chromadb==0.61.0 +opentelemetry-instrumentation-cohere==0.61.0 +opentelemetry-instrumentation-crewai==0.61.0 +opentelemetry-instrumentation-fastapi==0.63b1 +opentelemetry-instrumentation-google-generativeai==0.61.0 +opentelemetry-instrumentation-groq==0.61.0 +opentelemetry-instrumentation-haystack==0.61.0 +opentelemetry-instrumentation-lancedb==0.61.0 +opentelemetry-instrumentation-langchain==0.61.0 +opentelemetry-instrumentation-llamaindex==0.61.0 +opentelemetry-instrumentation-logging==0.63b1 +opentelemetry-instrumentation-marqo==0.61.0 +opentelemetry-instrumentation-mcp==0.61.0 +opentelemetry-instrumentation-milvus==0.60.0 +opentelemetry-instrumentation-mistralai==0.61.0 +opentelemetry-instrumentation-ollama==0.61.0 +opentelemetry-instrumentation-openai==0.61.0 +opentelemetry-instrumentation-openai-agents==0.61.0 +opentelemetry-instrumentation-pinecone==0.60.0 +opentelemetry-instrumentation-qdrant==0.61.0 +opentelemetry-instrumentation-redis==0.63b1 +opentelemetry-instrumentation-replicate==0.61.0 +opentelemetry-instrumentation-requests==0.63b1 +opentelemetry-instrumentation-sagemaker==0.61.0 +opentelemetry-instrumentation-sqlalchemy==0.63b1 +opentelemetry-instrumentation-threading==0.63b1 +opentelemetry-instrumentation-together==0.61.0 +opentelemetry-instrumentation-transformers==0.61.0 +opentelemetry-instrumentation-urllib3==0.63b1 +opentelemetry-instrumentation-vertexai==0.61.0 +opentelemetry-instrumentation-voyageai==0.61.0 +opentelemetry-instrumentation-watsonx==0.61.0 +opentelemetry-instrumentation-weaviate==0.61.0 +opentelemetry-instrumentation-writer==0.61.0 +opentelemetry-proto==1.42.1 +opentelemetry-sdk==1.42.1 +opentelemetry-semantic-conventions==0.63b1 +opentelemetry-semantic-conventions-ai==0.5.1 +opentelemetry-util-http==0.63b1 +opik==2.0.62 +orjson==3.11.9 +ormsgpack==1.12.2 +overrides==7.7.0 +packaging==26.2 +pandas==2.3.3 +pandas-stubs==3.0.3.260530 +parso==0.8.7 +passlib==1.7.4 +pathable==0.6.0 +pathspec==1.1.1 +peewee==4.0.7 +perplexityai==0.38.0 +pgvector==0.4.2 +pillow==12.2.0 +pinecone==7.3.0 +pinecone-plugin-assistant==1.8.0 +pinecone-plugin-interface==0.0.7 +pipenv==2026.6.2 +pksuid==1.1.2 +platformdirs==4.9.6 +playwright==1.60.0 +plotly==6.8.0 +pluggy==1.6.0 +podman==5.8.0 +polyfactory==3.3.0 +portalocker==3.2.0 +postgrest==2.31.0 +posthog==7.18.3 +primp==1.3.1 +prometheus_client==0.25.0 +prompt_toolkit==3.0.52 +propcache==0.5.2 +proto-plus==1.28.0 +protobuf==6.33.6 +psutil==7.2.2 +psycopg==3.3.4 +psycopg-binary==3.3.4 +pure_eval==0.2.3 +py==1.11.0 +py-key-value-aio==0.4.5 +py_rust_stemmers==0.1.8 +pyarrow==23.0.1 +pyasn1==0.6.3 +pyasn1_modules==0.4.2 +pybase62==0.4.3 +pybase64==1.4.3 +pyclipper==1.4.0 +pycparser==3.0 +pycryptodome==3.23.0 +pydantic==2.13.4 +pydantic-extra-types==2.11.1 +pydantic-settings==2.14.1 +pydantic-yaml==1.6.0 +pydantic_core==2.46.4 +pyee==13.0.1 +Pygments==2.20.0 +PyJWT==2.13.0 +pylatexenc==2.10 +pymilvus==2.6.15 +pymilvus.model==0.3.2 +pymongo==4.17.0 +pymongo-search-utils==0.3.0 +pyparsing==3.3.2 +pypdf==6.13.2 +pypdfium2==5.9.0 +pyperclip==1.11.0 +PyPika==0.51.1 +pyproject_hooks==1.2.0 +pyreadline3==3.5.6 +pyright==1.1.410 +Pysher==1.0.8 +PySocks==1.7.1 +pytest==9.1.1 +pytest-asyncio==1.4.0 +pytest-html==4.2.0 +pytest-json-report==1.5.0 +pytest-metadata==3.1.1 +python-bidi==0.6.10 +python-dateutil==2.9.0.post0 +python-discovery==1.4.4 +python-docx==1.2.0 +python-dotenv==1.2.2 +python-engineio==4.13.2 +python-liquid==2.2.0 +python-multipart==0.0.32 +python-pptx==1.0.2 +python-socketio==5.16.2 +pytokens==0.4.1 +pytube==15.0.0 +pytz==2026.2 +pywin32==312 +pywin32-ctypes==0.2.3 +PyYAML==6.0.3 +pyzmq==27.1.0 +qdrant-client==1.18.0 +qianfan==0.3.5 +ragworkbench==0.1.3 +RapidFuzz==3.14.5 +rapidocr==3.8.3 +realtime==2.31.0 +redis==7.4.1 +referencing==0.37.0 +regex==2026.5.9 +requests==2.34.2 +requests-oauthlib==2.0.0 +requests-toolbelt==1.0.0 +retry==0.9.2 +rich==13.9.4 +rich-rst==2.0.1 +rich-toolkit==0.20.1 +rignore==0.7.6 +rpds-py==2026.5.1 +rtree==1.4.1 +ruamel.yaml==0.18.17 +ruamel.yaml.clib==0.2.15 +s3transfer==0.14.0 +safetensors==0.8.0 +sambanova==1.9.0 +scikit-image==0.26.0 +scikit-learn==1.9.0 +scipy==1.17.1 +scrapegraph-py==2.1.0 +semchunk==3.2.5 +semver==2.13.0 +sentence-transformers==5.5.1 +sentry-sdk==2.62.0 +setuptools==80.10.2 +shapely==2.1.2 +shellingham==1.5.4 +simple-websocket==1.1.0 +simplejson==4.1.1 +simsimd==6.5.16 +six==1.17.0 +slowapi==0.1.10 +smmap==5.0.3 +smolagents==1.26.0 +sniffio==1.3.1 +socksio==1.0.0 +soupsieve==2.8.4 +spider_client==0.1.88 +SQLAlchemy==2.0.50 +sqlite-vec==0.1.9 +sqlmodel==0.0.38 +sse-starlette==3.4.4 +sseclient-py==1.8.0 +stack-data==0.6.3 +starlette==1.3.1 +storage3==2.31.0 +StrEnum==0.4.15 +structlog==25.5.0 +supabase==2.31.0 +supabase-auth==2.31.0 +supabase-functions==2.31.0 +sympy==1.14.0 +tabulate==0.10.0 +tavily-python==0.7.26 +tenacity==8.5.0 +termcolor==3.3.0 +threadpoolctl==3.6.0 +tifffile==2026.6.1 +tiktoken==0.13.0 +tinycss2==1.5.1 +tokenizers==0.22.2 +toml==0.10.2 +tomli==2.2.1 +toolguard==0.2.19 +torch==2.12.0 +torchvision==0.27.0 +tornado==6.5.5 +tqdm==4.68.2 +traceloop-sdk==0.61.0 +traitlets==5.15.0 +transformers==5.12.0 +tree-sitter==0.25.2 +tree-sitter-c==0.24.2 +tree-sitter-javascript==0.25.0 +tree-sitter-python==0.25.0 +tree-sitter-typescript==0.23.2 +trustcall==0.0.39 +twelvelabs==0.4.11 +typeguard==4.5.2 +typer==0.21.2 +typer-slim==0.21.2 +types-awscrt==0.34.1 +types-PyYAML==6.0.12.20260518 +types-requests==2.33.0.20260518 +types-s3transfer==0.16.0 +typing-inspection==0.4.2 +typing_extensions==4.15.0 +tzdata==2026.2 +tzlocal==5.3.1 +uncalled-for==0.3.2 +uncurl==0.0.11 +unitxt==1.26.10 +unstructured-client==0.42.12 +upstash-vector==0.6.0 +uritemplate==4.2.0 +urllib3==2.7.0 +uuid6==2025.0.1 +uuid_utils==0.16.0 +uvicorn==0.49.0 +validators==0.35.0 +virtualenv==21.6.1 +vlmrun==0.6.3 +vlmrun-hub==0.1.34 +watchfiles==1.2.0 +wcwidth==0.7.0 +weaviate-client==4.21.3 +webencodings==0.5.1 +websocket-client==1.9.0 +websockets==15.0.1 +Werkzeug==3.1.8 +wheel==0.47.0 +wikipedia==1.4.0 +win32_setctime==1.2.0 +wolframalpha==5.1.3 +wrapt==1.17.3 +wsproto==1.3.2 +xlsxwriter==3.2.9 +xmltodict==1.0.4 +xxhash==3.7.0 +yarl==1.24.2 +yfinance==0.2.50 +youtube-transcript-api==1.2.4 +zep-python==2.0.2 +zipp==4.1.0 +zstandard==0.25.0 diff --git a/tests/fakerestapi/test_get_activities.py b/tests/fakerestapi/test_get_activities.py new file mode 100644 index 0000000..c374c1f --- /dev/null +++ b/tests/fakerestapi/test_get_activities.py @@ -0,0 +1,18 @@ +import pytest +import requests + + +def test_getrequest_validation(): + """ + Response Status Code Validation. + """ + header = {"Accept": "text/plain; v=1.0"} + base_url = "https://fakerestapi.azurewebsites.net" + + response = requests.get( + url=str(base_url + "/api/v1/Activities"), headers=header, timeout=5000 + ) + + assert response.status_code == 200 + data = response.json() + assert data[0]["id"] == 1 diff --git a/tests/fakerestapi/test_get_activities_1.py b/tests/fakerestapi/test_get_activities_1.py new file mode 100644 index 0000000..612d596 --- /dev/null +++ b/tests/fakerestapi/test_get_activities_1.py @@ -0,0 +1,14 @@ +import pytest +from utils.api_client import APIClient + + +@pytest.fixture(scope="module") +def api_client(): + return APIClient() + + +def test_get_activities_validation(api_client): + response = api_client.get("api/v1/Activities") + print(response.json()) + assert response.status_code == 201 + assert len(response.json()) > 0 diff --git a/utils/api_client.py b/utils/api_client.py new file mode 100644 index 0000000..a3e10b9 --- /dev/null +++ b/utils/api_client.py @@ -0,0 +1,13 @@ +import requests + + +class APIClient: + BASE_URL = "https://fakerestapi.azurewebsites.net/" + + def __init__(self): + self.header = {"accept": "text/plain; v=1.0"} + + def get(self, endpoint): + get_url = f"{self.BASE_URL}/{endpoint}" + response = requests.get(url=get_url, headers=self.header, timeout=5000) + return response