Add test files
This commit is contained in:
138
tests/conftest.py
Normal file
138
tests/conftest.py
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
"""Pytest configuration and fixtures."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def project_root():
|
||||||
|
"""Get the project root directory."""
|
||||||
|
return Path(__file__).parent.parent
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def temp_dir(tmp_path):
|
||||||
|
"""Create a temporary directory for tests."""
|
||||||
|
return tmp_path
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def sample_openapi_content():
|
||||||
|
"""Sample OpenAPI specification content."""
|
||||||
|
return """
|
||||||
|
openapi: "3.0.0"
|
||||||
|
info:
|
||||||
|
title: Sample API
|
||||||
|
version: "1.0.0"
|
||||||
|
description: A sample API for testing
|
||||||
|
|
||||||
|
paths:
|
||||||
|
/users:
|
||||||
|
get:
|
||||||
|
summary: List users
|
||||||
|
description: Get a list of all users
|
||||||
|
operationId: listUsers
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Successful response
|
||||||
|
|
||||||
|
/users/{id}:
|
||||||
|
get:
|
||||||
|
summary: Get user by ID
|
||||||
|
operationId: getUser
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: User found
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def sample_readme_content():
|
||||||
|
"""Sample README content."""
|
||||||
|
return """# Project Title
|
||||||
|
|
||||||
|
This is a sample project.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Run `pip install` to install dependencies.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```python
|
||||||
|
from project import main
|
||||||
|
main()
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### `main()`
|
||||||
|
|
||||||
|
The main entry point of the application.
|
||||||
|
|
||||||
|
### `process_data(data)`
|
||||||
|
|
||||||
|
Process the given data.
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `data` (dict): The data to process
|
||||||
|
|
||||||
|
**Returns:**
|
||||||
|
- dict: Processed data
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def sample_python_content():
|
||||||
|
"""Sample Python code with docstrings."""
|
||||||
|
return '''"""Sample module for testing."""
|
||||||
|
|
||||||
|
def example_function(param1, param2):
|
||||||
|
"""Example function with parameters.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
param1: First parameter
|
||||||
|
param2: Second parameter
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Combined result
|
||||||
|
"""
|
||||||
|
return param1 + param2
|
||||||
|
|
||||||
|
|
||||||
|
class ExampleClass:
|
||||||
|
"""Example class for testing.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
value: The stored value
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, initial_value=0):
|
||||||
|
"""Initialize with a value.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
initial_value: Starting value
|
||||||
|
"""
|
||||||
|
self.value = initial_value
|
||||||
|
|
||||||
|
def get_value(self):
|
||||||
|
"""Get the current value.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The current value
|
||||||
|
"""
|
||||||
|
return self.value
|
||||||
|
'''
|
||||||
Reference in New Issue
Block a user