Skip to content

Commit a2684ee

Browse files
committed
docs: improve documentation across all configuration files
- Add detailed CI/CD workflow documentation - Enhance config.yaml with comprehensive comments - Add schemas/README.md with JSON schema documentation - Add data/README.md with test data documentation - Improve setup.sh script documentation
1 parent b6544d7 commit a2684ee

6 files changed

Lines changed: 175 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
# API Test Automation Framework - CI/CD Pipeline
2+
# This workflow automates testing, security scanning, and documentation deployment
3+
# for the API Test Automation Framework.
4+
#
5+
# Triggers:
6+
# - Push to main/develop/fix/feature branches
7+
# - Pull requests to main
8+
# - Daily at 6 AM UTC (Scheduled health check)
9+
# - Manual trigger (workflow_dispatch)
10+
#
11+
# Jobs:
12+
# 1. test: Runs test suite across Python versions
13+
# 2. security-scan: Performs security analysis
14+
# 3. performance-test: Runs performance tests
15+
# 4. deploy-docs: Deploys documentation to GitHub Pages
16+
# 5. notify: Sends notifications on failure
17+
#
18+
# Environment Setup:
19+
# - Uses Python matrix strategy (3.10, 3.11, 3.12)
20+
# - Caches pip dependencies
21+
# - Sets up Java for Allure reporting
22+
123
name: API Test Automation CI/CD
224

325
'on':
@@ -6,9 +28,9 @@ name: API Test Automation CI/CD
628
pull_request:
729
branches: [ main ]
830
schedule:
9-
# Run tests daily at 6 AM UTC
31+
# Run tests daily at 6 AM UTC for health check
1032
- cron: '0 6 * * *'
11-
workflow_dispatch:
33+
workflow_dispatch: # Allows manual trigger
1234

1335
# Add concurrency control to prevent resource conflicts
1436
concurrency:

config/config.yaml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
1-
# config.yaml
1+
# config.yaml - Framework Configuration
22
# -----------------------------------------------------------------------------
3-
# Configuration file for environment settings and global test behavior.
4-
# This file controls which environment is active, API endpoints, authentication,
5-
# request timeouts, retry logic, and default HTTP headers for all API tests.
3+
# Main configuration file for the API Test Automation Framework.
4+
#
5+
# Configuration Categories:
6+
# 1. Environment Selection
7+
# - Controls which environment (dev/staging) is active
8+
# - Defines environment-specific settings
9+
#
10+
# 2. API Settings
11+
# - Base URLs for different environments
12+
# - Authentication tokens and credentials
13+
# - Default request timeouts
14+
#
15+
# 3. Test Behavior
16+
# - Retry logic for flaky tests
17+
# - Default HTTP headers
18+
# - Logging levels
19+
#
20+
# 4. Performance Settings
21+
# - Request timeouts
22+
# - Rate limiting
23+
# - Concurrent request limits
24+
#
25+
# Usage:
26+
# The framework automatically loads this configuration via utils.api_utils.load_config()
27+
# Override settings using environment variables where needed
628
# -----------------------------------------------------------------------------
729

830
# Select which environment to use: dev or staging

data/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Test Data Documentation
2+
3+
This directory contains test data used by the API Test Automation Framework.
4+
5+
## Data Files
6+
7+
### 1. post_user_payloads.json
8+
Contains test data for user creation tests (POST /api/users):
9+
- Valid user data with different combinations
10+
- Edge cases for validation
11+
- Various job titles and user names
12+
13+
### 2. large_payload.json
14+
Test data for performance and boundary testing:
15+
- Large data payload (>1MB)
16+
- Complex nested structures
17+
- Used for testing API handling of large requests
18+
19+
## Data Structure
20+
Each test data file follows a specific structure for consistent testing:
21+
```json
22+
[
23+
{
24+
"name": "test user name",
25+
"job": "test job title",
26+
"expectedStatus": 201,
27+
"description": "Test case description"
28+
}
29+
]
30+
```
31+
32+
## Usage
33+
The test data is loaded and used in parameterized tests:
34+
```python
35+
import json
36+
def load_test_data():
37+
with open("data/post_user_payloads.json") as f:
38+
return json.load(f)
39+
40+
@pytest.mark.parametrize("payload", load_test_data())
41+
def test_create_user(payload):
42+
# Test implementation
43+
```
44+
45+
## Maintenance
46+
- Keep data files under 5MB
47+
- Use meaningful test data that represents real-world scenarios
48+
- Include both positive and negative test cases
49+
- Document special test cases or edge conditions

schemas/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# API Schema Documentation
2+
3+
This directory contains JSON Schema definitions for validating API responses from the ReqRes API.
4+
5+
## Schema Files
6+
7+
### 1. user_list_schema.json
8+
- **Endpoint**: GET /api/users?page={page}
9+
- **Purpose**: Validates paginated user list responses
10+
- **Key Properties**:
11+
- page: Current page number
12+
- per_page: Items per page
13+
- total: Total number of users
14+
- data: Array of user objects
15+
- support: Support information
16+
17+
### 2. single_user_schema.json
18+
- **Endpoint**: GET /api/users/{id}
19+
- **Purpose**: Validates single user responses
20+
- **Key Properties**:
21+
- data: Single user object
22+
- support: Support information
23+
24+
### 3. create_user_schema.json
25+
- **Endpoint**: POST /api/users
26+
- **Purpose**: Validates user creation response
27+
- **Key Properties**:
28+
- name: User's name
29+
- job: User's job
30+
- id: Generated user ID
31+
- createdAt: Creation timestamp
32+
33+
## Schema Validation
34+
All schemas are JSON Schema Draft-07 compliant and are used in the test suite for response validation. They ensure that:
35+
- Required fields are present
36+
- Field types are correct
37+
- Data structures are consistent
38+
- Additional properties are handled appropriately
39+
40+
## Usage Example
41+
```python
42+
from jsonschema import validate
43+
from utils.api_utils import load_schema
44+
45+
# Load schema
46+
schema = load_schema('user_list_schema.json')
47+
48+
# Validate response
49+
validate(instance=response.json(), schema=schema)
50+
```

schemas/user_list_schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{
2+
// User List Response Schema
3+
// This schema validates the response from GET /api/users endpoint
4+
// It defines the structure for paginated user list responses
5+
// Version: 1.0.0
6+
// Last Updated: 2025-07-11
7+
// Endpoint: GET /api/users?page={page}
28
"$schema": "http://json-schema.org/draft-07/schema#",
39
"title": "UserListResponse",
10+
"description": "Schema for paginated user list response from ReqRes API",
411
"type": "object",
512
"required": ["page", "per_page", "total", "total_pages", "data", "support"],
613
"properties": {

setup.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
#!/bin/bash
22

3-
# setup.sh - Setup script for API Test Automation Framework
4-
# This script sets up the virtual environment and installs dependencies
3+
# setup.sh - Environment Setup Script
4+
# -----------------------------------------------------------------------------
5+
# This script automates the setup process for the API Test Automation Framework.
6+
# It performs the following tasks:
7+
# 1. Validates Python installation
8+
# 2. Creates/activates virtual environment (.venv)
9+
# 3. Installs project dependencies
10+
# 4. Sets up Allure reporting
11+
# 5. Validates schema and data files
12+
#
13+
# Usage:
14+
# ./setup.sh # Standard setup
15+
# ./setup.sh --force # Force reinstall of dependencies
16+
#
17+
# Requirements:
18+
# - Python 3.10 or higher
19+
# - pip package manager
20+
# - bash-compatible shell
21+
# -----------------------------------------------------------------------------
522

623
set -e
724

0 commit comments

Comments
 (0)