Test data management with fixtures and factories. Use when creating test data strategies, implementing data factories, managing fixtures, or seeding test databases.
View on GitHubyonatangross/orchestkit
orchestkit-complete
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/yonatangross/orchestkit/blob/main/./skills/test-data-management/SKILL.md -a claude-code --skill test-data-managementInstallation paths:
.claude/skills/test-data-management/# Test Data Management
Create and manage test data effectively.
## Factory Pattern (Python)
```python
from factory import Factory, Faker, SubFactory, LazyAttribute
from app.models import User, Analysis
class UserFactory(Factory):
class Meta:
model = User
email = Faker('email')
name = Faker('name')
created_at = Faker('date_time_this_year')
class AnalysisFactory(Factory):
class Meta:
model = Analysis
url = Faker('url')
status = 'pending'
user = SubFactory(UserFactory)
@LazyAttribute
def title(self):
return f"Analysis of {self.url}"
# Usage
user = UserFactory()
analysis = AnalysisFactory(user=user, status='completed')
```
## Factory Pattern (TypeScript)
```typescript
import { faker } from '@faker-js/faker';
interface User {
id: string;
email: string;
name: string;
}
const createUser = (overrides: Partial<User> = {}): User => ({
id: faker.string.uuid(),
email: faker.internet.email(),
name: faker.person.fullName(),
...overrides,
});
const createAnalysis = (overrides = {}) => ({
id: faker.string.uuid(),
url: faker.internet.url(),
status: 'pending',
userId: createUser().id,
...overrides,
});
// Usage
const user = createUser({ name: 'Test User' });
const analysis = createAnalysis({ userId: user.id, status: 'completed' });
```
## JSON Fixtures
```json
// fixtures/users.json
{
"admin": {
"id": "user-001",
"email": "admin@example.com",
"role": "admin"
},
"basic": {
"id": "user-002",
"email": "user@example.com",
"role": "user"
}
}
```
```python
import json
import pytest
@pytest.fixture
def users():
with open('fixtures/users.json') as f:
return json.load(f)
def test_admin_access(users):
admin = users['admin']
assert admin['role'] == 'admin'
```
## Database Seeding
```python
# seeds/test_data.py
async def seed_test_database(db: AsyncSession):
"""Seed database with test data."""
# Create users
users = [