The fake Slack server is implemented in fake_slack.py as a standalone module
with its own CLI entry point (slack-fake-server). It generates a Workspace
object from a seed, then serves API responses via FakeSlackHandler (a
BaseHTTPRequestHandler subclass).
Architecture
fake_slack.py
|
+-- WorkspaceParams (dataclass: seed, counts, activity_ratio, rate_limits)
|
+-- Workspace (pre-generated data)
| +-- users: list[dict] (generated from name/role pools)
| +-- channels: list[dict] (generated from channel definitions)
| +-- threads: dict[(ch, ts)] -> list[dict] (generated from templates)
| +-- get_users_page() (paginated)
| +-- get_channels_page() (paginated, type-filtered)
| +-- get_thread_messages() (paginated, oldest-filtered)
| +-- get_channel_history() (paginated, oldest/latest-filtered)
|
+-- RateLimiter (sliding-window per endpoint)
| +-- check(path) -> (allowed, retry_after)
|
+-- FakeSlackHandler (BaseHTTPRequestHandler)
| +-- GET /api/conversations.replies
| +-- GET /api/conversations.history
| +-- GET /api/users.list
| +-- GET /api/conversations.list
| +-- POST /api/chat.postMessage
|
+-- run_server() -> HTTPServer
+-- main() (CLI entry point with argparse)
Data Models
WorkspaceParams
Field
Type
Default
Description
seed
int
42
Random seed for deterministic generation
num_users
int
20
Number of workspace members
num_channels
int
13
Number of channels
num_threads
int
30
Number of conversation threads
min_messages_per_thread
int
3
Minimum messages per thread
max_messages_per_thread
int
12
Maximum messages per thread
activity_ratio
float
0.6
Fraction of users who actively participate
rate_limits
bool
False
Enable Slack-compatible rate limiting
Endpoint rate limits
Endpoint
Requests per minute
conversations.replies
50
conversations.history
50
chat.postMessage
50
users.list
20
conversations.list
20
API Contracts
The server exposes Slack-compatible JSON responses:
Behavior: Creates a new message in the specified channel (or thread if thread_ts is given), appends it to the workspace's in-memory thread data, and returns the full message dict with a generated ts