|
1 | 1 | [ |
2 | 2 | { |
3 | | - "name": "flask_api", |
4 | | - "prompt": "Create a modular Flask REST API with health endpoint and clean structure", |
5 | | - "requirements": ["flask", "pytest"], |
6 | | - "hidden_tests": ["from flask import Flask", "def test_health_endpoint"] |
7 | | - }, |
8 | | - { |
9 | | - "name": "cli_tool", |
10 | | - "prompt": "Create a Python CLI task manager using argparse", |
11 | | - "requirements": ["pytest"], |
12 | | - "hidden_tests": ["import argparse", "if __name__ == '__main__'"] |
13 | | - }, |
14 | | - { |
15 | | - "name": "websocket_server", |
16 | | - "prompt": "Create an async websocket echo server in Python", |
17 | | - "requirements": ["pytest", "pytest-asyncio"], |
18 | | - "hidden_tests": ["import asyncio", "import websockets"] |
19 | | - }, |
20 | | - { |
21 | | - "name": "data_processor", |
22 | | - "prompt": "Create a Python data processing pipeline that reads CSV, transforms data, and outputs JSON", |
23 | | - "requirements": ["pytest"], |
24 | | - "hidden_tests": ["import csv", "import json"] |
25 | | - }, |
26 | | - { |
27 | | - "name": "math_library", |
28 | | - "prompt": "Create a Python math utility library with functions for statistics, algebra, and geometry", |
| 3 | + "name": "cli_task_manager", |
| 4 | + "prompt": "Create a Python CLI task manager using argparse. Commands: add TASK, list, complete ID, delete ID. Tasks persist to a JSON file called tasks.json. The main entry point must be in main.py with if __name__ == '__main__' block. Each task has id, description, done fields.", |
29 | 5 | "requirements": ["pytest"], |
30 | | - "hidden_tests": ["def test_", "import math"] |
| 6 | + "hidden_test_files": { |
| 7 | + "test_hidden_cli.py": "import subprocess\nimport json\nimport os\n\n\ndef setup_module():\n if os.path.exists('tasks.json'):\n os.remove('tasks.json')\n\n\ndef teardown_module():\n if os.path.exists('tasks.json'):\n os.remove('tasks.json')\n\n\ndef test_add_creates_task():\n result = subprocess.run(['python', 'main.py', 'add', 'test task'], capture_output=True, text=True)\n assert result.returncode == 0, f'add failed: {result.stderr}'\n assert os.path.exists('tasks.json'), 'tasks.json not created'\n with open('tasks.json') as f:\n tasks = json.load(f)\n assert len(tasks) == 1\n assert tasks[0]['description'] == 'test task'\n\n\ndef test_list_shows_tasks():\n subprocess.run(['python', 'main.py', 'add', 'visible task'], capture_output=True)\n result = subprocess.run(['python', 'main.py', 'list'], capture_output=True, text=True)\n assert result.returncode == 0\n assert 'visible task' in result.stdout\n\n\ndef test_complete_marks_done():\n subprocess.run(['python', 'main.py', 'add', 'finish me'], capture_output=True)\n result = subprocess.run(['python', 'main.py', 'complete', '1'], capture_output=True, text=True)\n assert result.returncode == 0\n with open('tasks.json') as f:\n tasks = json.load(f)\n assert any(t['id'] == 1 and t.get('done') for t in tasks)\n\n\ndef test_delete_removes_task():\n subprocess.run(['python', 'main.py', 'add', 'delete me'], capture_output=True)\n result = subprocess.run(['python', 'main.py', 'delete', '1'], capture_output=True, text=True)\n assert result.returncode == 0\n with open('tasks.json') as f:\n tasks = json.load(f)\n assert not any(t['id'] == 1 for t in tasks)\n" |
| 8 | + } |
31 | 9 | }, |
32 | 10 | { |
33 | | - "name": "file_indexer", |
34 | | - "prompt": "Create a Python file indexer that walks directories, computes file hashes, and outputs a JSON index", |
35 | | - "requirements": ["pytest"], |
36 | | - "hidden_tests": ["import hashlib", "os.walk"] |
37 | | - }, |
38 | | - { |
39 | | - "name": "config_parser", |
40 | | - "prompt": "Create a Python configuration parser that reads YAML/JSON/INI formats and validates schemas", |
41 | | - "requirements": ["pytest", "pyyaml"], |
42 | | - "hidden_tests": ["import yaml", "import json"] |
43 | | - }, |
44 | | - { |
45 | | - "name": "rate_limiter", |
46 | | - "prompt": "Create a Python rate limiter implementation with token bucket or sliding window algorithm", |
47 | | - "requirements": ["pytest"], |
48 | | - "hidden_tests": ["class RateLimiter", "def test_rate_limit"] |
49 | | - }, |
50 | | - { |
51 | | - "name": "caching_layer", |
52 | | - "prompt": "Create a Python caching library with TTL support, LRU eviction, and decorator interface", |
53 | | - "requirements": ["pytest"], |
54 | | - "hidden_tests": ["functools.lru_cache", "class Cache"] |
| 11 | + "name": "async_web_scraper", |
| 12 | + "prompt": "Create an async Python web scraper in main.py. Must have an async function fetch_url(url, session) that fetches a single URL and returns the response text. Must have an async function scrape_all(urls) that fetches multiple URLs concurrently using asyncio.gather or similar, limits to max 3 concurrent requests via asyncio.Semaphore, retries failed requests once, and returns a list of (url, success, text_or_error) tuples. Must have a main() entry point that accepts a comma-separated list of URLs from sys.argv and prints results as JSON: [{url, success, length, error}]. Include proper error handling for network failures and timeouts.", |
| 13 | + "requirements": ["pytest", "pytest-asyncio", "aiohttp"], |
| 14 | + "hidden_test_files": { |
| 15 | + "test_hidden_scraper.py": "import subprocess\nimport json\nimport sys\n\n\ndef test_scraper_imports():\n import importlib\n spec = importlib.util.find_spec('main')\n assert spec is not None, 'main.py not importable'\n\n\ndef test_main_entry_point():\n result = subprocess.run(\n [sys.executable, 'main.py', 'https://example.com'],\n capture_output=True, text=True, timeout=15\n )\n assert result.returncode == 0, f'main failed: {result.stderr}'\n output = json.loads(result.stdout)\n assert isinstance(output, list)\n assert len(output) == 1\n entry = output[0]\n assert 'url' in entry\n assert 'success' in entry\n assert 'length' in entry\n\n\ndef test_scraper_handles_bad_url():\n result = subprocess.run(\n [sys.executable, 'main.py', 'https://nonexistent.example.test'],\n capture_output=True, text=True, timeout=15\n )\n output = json.loads(result.stdout)\n entry = output[0]\n assert not entry['success'], 'should fail for bad URL'\n assert 'error' in entry\n\n\ndef test_scraper_concurrent_flag():\n source = open('main.py').read()\n assert 'asyncio.gather' in source or 'asyncio.wait' in source or 'asyncio.TaskGroup' in source, 'no concurrent fetching'\n assert 'asyncio.Semaphore' in source or 'asyncio.BoundedSemaphore' in source, 'no rate limiting'\n" |
| 16 | + } |
55 | 17 | }, |
56 | 18 | { |
57 | | - "name": "log_analyzer", |
58 | | - "prompt": "Create a Python log file analyzer that parses timestamps, counts levels, and generates reports", |
| 19 | + "name": "data_pipeline", |
| 20 | + "prompt": "Create a Python data pipeline in main.py. Must have a function read_csv(path) that reads a CSV file (handle both comma and header row) and returns a list of dicts. Must have a function filter_data(data, key, value) that filters rows where data[key] == value. Must have a function aggregate(data, group_key, agg_key, agg_func) that groups by group_key and applies agg_func ('sum', 'avg', 'count') to agg_key. Must have a function write_json(data, path) that writes the processed data as JSON. Must have a main() that accepts input CSV path from sys.argv, reads, filters where status=active, aggregates by department summing salary, and writes to {input}_report.json. Include error handling for missing files.", |
59 | 21 | "requirements": ["pytest"], |
60 | | - "hidden_tests": ["import re", "def test_parse"] |
| 22 | + "hidden_test_files": { |
| 23 | + "test_hidden_pipeline.py": "import subprocess\nimport json\nimport os\nimport tempfile\n\n\ndef test_read_csv():\n from main import read_csv\n with tempfile.NamedTemporaryFile(mode='w', suffix='.csv', delete=False) as f:\n f.write('name,age,city\\nAlice,30,NYC\\nBob,25,LA\\n')\n path = f.name\n data = read_csv(path)\n os.unlink(path)\n assert len(data) == 2\n assert data[0]['name'] == 'Alice'\n\n\ndef test_filter_data():\n from main import filter_data\n data = [{'name': 'Alice', 'status': 'active'}, {'name': 'Bob', 'status': 'inactive'}]\n result = filter_data(data, 'status', 'active')\n assert len(result) == 1\n assert result[0]['name'] == 'Alice'\n\n\ndef test_aggregate_sum():\n from main import aggregate\n data = [{'dept': 'eng', 'salary': 100}, {'dept': 'eng', 'salary': 200}, {'dept': 'hr', 'salary': 150}]\n result = aggregate(data, 'dept', 'salary', 'sum')\n assert result['eng'] == 300\n assert result['hr'] == 150\n\n\ndef test_aggregate_avg():\n from main import aggregate\n data = [{'dept': 'eng', 'salary': 100}, {'dept': 'eng', 'salary': 200}]\n result = aggregate(data, 'dept', 'salary', 'avg')\n assert result['eng'] == 150\n\n\ndef test_main_pipeline():\n with tempfile.NamedTemporaryFile(mode='w', suffix='.csv', delete=False) as f:\n f.write('name,department,salary,status\\nAlice,Engineering,100000,active\\nBob,Engineering,120000,active\\nCharlie,HR,80000,inactive\\n')\n input_path = f.name\n output_path = input_path.replace('.csv', '_report.json')\n result = subprocess.run(['python', 'main.py', input_path], capture_output=True, text=True, timeout=10)\n os.unlink(input_path)\n assert result.returncode == 0, f'pipeline failed: {result.stderr}'\n assert os.path.exists(output_path), f'report not created at {output_path}'\n with open(output_path) as f:\n report = json.load(f)\n os.unlink(output_path)\n assert isinstance(report, dict)\n" |
| 24 | + } |
61 | 25 | } |
62 | 26 | ] |
0 commit comments