Skip to main content

mock requests: pre-cached per-URL; missing URLs fetched and cached automatically.

Project description

mock-requests

A mock for CAT API:

  • Uses packaged JSONs for common URLs
  • If a URL isn't cached, it fetches live once and caches to ~/.cache/mock_requests

Local usage

python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -U pip build
pip install -e ".[dev]"

## Bulk priming

- Prime many URLs into **user cache** (and optionally copy into package data):

```bash
# By default this will make real requests; disable with MOCK_REQUESTS_OFFLINE=1.
python scripts/bulk_prime.py --urls-file scripts/seed_urls.txt --to-package

Runtime behavior

Resolution order for a URL:

  1. Package data (mock_requests/data/*.json) — fastest
  2. User cache (~/.cache/mock_requests/*.json)
  3. Live fetch (unless MOCK_REQUESTS_OFFLINE=1), then save to user cache
  4. Else: return 404-like mock response

Safety knobs

  • Set MOCK_REQUESTS_OFFLINE=1 to disable live fetches (e.g., CI).
  • Set MOCK_REQUESTS_TIMEOUT=30 to adjust HTTP timeout seconds.
  • Set MOCK_REQUESTS_USER_CACHE_DIR to customize cache directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mock_requests_catapi-0.0.2.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mock_requests_catapi-0.0.2-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file mock_requests_catapi-0.0.2.tar.gz.

File metadata

  • Download URL: mock_requests_catapi-0.0.2.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for mock_requests_catapi-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ab34cf2cc2a9162c4164c56ef8af835b95df2915633413836fcf1b7252092d65
MD5 816dc30f79353a8a2dd0ccac278eef3b
BLAKE2b-256 86dedb2c22db68438627ab018f761e61a8640c33f5a3dcbe86659a0f7a6bf0c0

See more details on using hashes here.

File details

Details for the file mock_requests_catapi-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mock_requests_catapi-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 77ecfaa7e7ae7ac85c02257bead452cbd78a8eb7fb327f05b67c3f5ceffed9ea
MD5 c0071d1c7c76978a7467cb54f5cd6e9f
BLAKE2b-256 ef885b7a581879e9b071a5bc761b03023473cedc2251900e5e3161b698867067

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page