Skip to main content

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

Project description

mock-requests-restcountries

A mock for REST Countries (v3.1):

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

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_rc/*.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_restcountries-0.4.0.tar.gz (52.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_restcountries-0.4.0-py3-none-any.whl (55.1 kB view details)

Uploaded Python 3

File details

Details for the file mock_requests_restcountries-0.4.0.tar.gz.

File metadata

File hashes

Hashes for mock_requests_restcountries-0.4.0.tar.gz
Algorithm Hash digest
SHA256 737ea797e75d3a27fe7c1535f718b154b67e1571ec03087a463118b778b3c78a
MD5 40439232b044d43e32f8481071f83d5b
BLAKE2b-256 9488b73e0b56fd69b7ce80dde9ae6ebf31f20b9f85b07816a98b004581f8417f

See more details on using hashes here.

File details

Details for the file mock_requests_restcountries-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mock_requests_restcountries-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 696c87f36971b37bfb5874e822210686b71bb08af1b371ba80ea09df57b1d370
MD5 59d6b23467df217e91adb3421954e8cc
BLAKE2b-256 9f571633dda61fad77fc6f236395ed0026091188748b360e4f0c2bb8141faf97

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