Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Roost-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# RoostGPT generated pytest code for API Testing

RoostGPT generats code in `tests` folder within given project path.
Dependency file i.e. `requirements-roost.txt` is also created in the given project path

Below are the sample steps to run the generated tests. Sample commands contains use of package manager i.e. `uv`. Alternatively python and pip can be used directly.
1. ( Optional ) Create virtual Env .
2. Install dependencies
```
uv venv // Create virtual Env
uv pip install -r requirements-roost.txt // Install all dependencies

```

Test configurations and test_data is loaded from config.yml. e.g. API HOST, auth, common path parameters of endpoint.
Either set defalt value in this config.yml file OR use ENV. e.g. export API_HOST="https://example.com/api/v2"

Once configuration values are set, use below commands to run the tests.
```
// Run generated tests
uv run pytest -m smoke // Run only smoke tests
uv run pytest -s tests/generated-test.py // Run specific test file
```

14 changes: 14 additions & 0 deletions requirements-roost.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

connexion
Flask
flask_testing
jsonschema
pytest
python_dateutil
PyYAML
referencing
Requests
setuptools
six
urllib3
xmltodict
105 changes: 105 additions & 0 deletions tests/AUTH_API/api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"openapi": "3.0.0",
"info": {
"title": "Auth API",
"version": "1.0.0"
},
"paths": {
"/api/auth/login": {
"post": {
"summary": "User login",
"operationId": "login",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LoginRequest"
}
}
}
},
"responses": {
"200": {
"description": "Successful login",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LoginResponse"
}
}
}
},
"400": {
"description": "Invalid credentials"
}
}
}
}
},
"components": {
"schemas": {
"LoginRequest": {
"type": "object",
"required": [
"email",
"password"
],
"properties": {
"email": {
"type": "string",
"format": "email",
"example": "user@example.com"
},
"password": {
"type": "string",
"format": "password",
"example": "P@ssw0rd"
}
}
},
"LoginResponse": {
"type": "object",
"properties": {
"token": {
"type": "string",
"example": "jwt-token-123"
},
"refreshToken": {
"type": "string",
"example": "refresh-token-123"
},
"user": {
"$ref": "#/components/schemas/User"
}
}
},
"User": {
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "12345"
},
"email": {
"type": "string",
"format": "email",
"example": "user@example.com"
},
"firstname": {
"type": "string",
"example": "John"
},
"role": {
"type": "string",
"example": "ADMIN"
},
"accountId": {
"type": "string",
"example": "acct-8749"
}
}
}
}
}
}
72 changes: 72 additions & 0 deletions tests/AUTH_API/api_auth_login.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[
{
"email": "user@example.com",
"password": "StrongPassw0rd!",
"statusCode": 200,
"scenario": "Successful responses: OK"
},
{
"email": "admin@contoso.io",
"password": "Adm1n#Secure#2025",
"statusCode": 200,
"scenario": "Successful responses: OK"
},
{
"password": "NoEmailButPass123!",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"email": "missing.password@example.com",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"email": "invalid-email",
"password": "ValidLikePass123!",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"email": "short.pass@example.com",
"password": "123",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"email": "unknown.user@nomail.zzz",
"password": "WrongPassword!234",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"email": "user@example.com",
"password": "' OR '1'='1",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"email": "super.long.username.with.many.parts.and.dots.and.plus+aliasing.for.testing.purposes.2025.12.04@very-long-subdomain.example-verylongdomain-name.co",
"password": "LongEmailPass123!",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"email": "john.doe+login@test-mail.org",
"password": "S3curePass!@#2025",
"statusCode": 200,
"scenario": "Successful responses: OK"
},
{
"email": "space.trailing@example.com ",
"password": "SpaceyPass123!",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
},
{
"email": "bad email@example.com",
"password": "PassWith Spaces123!",
"statusCode": 400,
"scenario": "Client error responses: Bad Request"
}
]
17 changes: 17 additions & 0 deletions tests/AUTH_API/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# This config.yml contains user provided data for api testing. Allows to define values here or use ENV to load values. e.g. ENV[API_HOST] = "https://exampl2.com"
# api:
# host: "${API_HOST:-https://example.com/api/v2}" # includes base path
# auth:
# api_key: "${API_KEY:-}"
# api_key_header: "${KEYNAME:-DefaultValue}" # openapi.spec.security.KEY_NAME
# basic_auth: "${username:-}:${password:-}"
# test_data:
# id: "${TEST_ID:-282739-1238371-219393-2833}" # Any test data key value pair e.g. GET /api/v1/cart/:id
# context-id: "${TEST_context-id:-}" # GET /api/v1/{context-id}/summary



api:
host: "${API_HOST:-AUTH_API_API_HOST,}"
test_data: {}
Loading