initial commit
Integration Test / integration-test (push) Waiting to run

This commit is contained in:
2025-07-29 16:17:23 -05:00
commit 8623db4c56
3 changed files with 184 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
name: Integration Test
on:
push:
branches:
- master
jobs:
integration-test:
runs-on: generic
container:
image: python:3
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
pip install pytest requests
- name: Run tests
run: |
pytest run_test.py
+120
View File
@@ -0,0 +1,120 @@
# Integration Test
An example integration test for the CleverBrag API health endpoint.
## Overview
This project contains integration tests that validate the functionality of the CleverBrag API's health endpoint. The tests ensure that the API is responding correctly and returning the expected health status.
## Features
- **Health Endpoint Testing**: Validates the `/v3/health` endpoint of the CleverBrag API
- **Automated CI/CD**: Continuous integration using Forgejo workflows
- **Python-based**: Uses pytest framework for testing
- **HTTP Request Testing**: Validates API responses and status codes
## Project Structure
```
.
├── README.md # This file
├── run_test.py # Main test file
└── .forgejo/
└── workflows/
└── integration-test.yaml # CI/CD workflow configuration
```
## Requirements
- Python 3.x
- pytest
- requests
## Installation
1. Clone the repository:
```bash
git clone <repository-url>
cd integration-test
```
2. Install dependencies:
```bash
pip install pytest requests
```
## Usage
### Running Tests Locally
You can run the tests in several ways:
1. **Using pytest** (recommended):
```bash
pytest run_test.py
```
2. **Running directly with Python**:
```bash
python run_test.py
```
3. **Verbose output**:
```bash
pytest run_test.py -v
```
### Test Details
The test suite includes:
- **`test_health_endpoint()`**: Tests the health endpoint at `https://api.cleverbrag.epsilon.cleverthis.com/v3/health`
- Verifies HTTP 200 status code
- Validates JSON response structure
- Checks that `results.message` equals "ok"
## CI/CD Integration
This project uses Forgejo for continuous integration. The workflow automatically:
1. Triggers on pushes to the `master` branch
2. Sets up a Python 3 environment
3. Installs required dependencies (`pytest` and `requests`)
4. Runs the test suite using pytest
### Workflow Configuration
The CI/CD pipeline is defined in `.forgejo/workflows/integration-test.yaml` and runs on a generic runner with a Python 3 container.
## API Endpoint
The tests target the following endpoint:
- **URL**: `https://api.cleverbrag.epsilon.cleverthis.com/v3/health`
- **Method**: GET
- **Expected Response**:
```json
{
"results": {
"message": "ok"
}
}
```
## Contributing
1. Fork the repository
2. Create a feature branch
3. Add or modify tests as needed
4. Ensure all tests pass locally
5. Submit a pull request
## License
This project is part of the CleverBrag API testing suite.
+40
View File
@@ -0,0 +1,40 @@
import pytest
import requests
def test_health_endpoint():
"""
Test the health endpoint to ensure it returns the expected response.
Makes an HTTP GET request to the health endpoint and validates:
- The request is successful (status code 200)
- The response is valid JSON
- The response contains results.message == "ok"
"""
url = "https://api.cleverbrag.epsilon.cleverthis.com/v3/health"
# Make the HTTP request
response = requests.get(url)
# Assert the request was successful
assert (
response.status_code == 200
), f"Expected status code 200, got {response.status_code}"
# Parse the JSON response
json_response = response.json()
# Validate the response structure and content
assert "results" in json_response, "Response should contain 'results' key"
assert (
"message" in json_response["results"]
), "Response results should contain 'message' key"
assert (
json_response["results"]["message"] == "ok"
), f"Expected message 'ok', got '{json_response['results']['message']}'"
if __name__ == "__main__":
# Allow running the test directly with python run_test.py
test_health_endpoint()
print("Health endpoint test passed!")