Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ if __name__ == "__main__":
The [`examples/`](examples) directory contains end-to-end scripts for the
common flows. A few starting points:

- [Read public REST endpoints](examples/get_info.py)
- [Stream order books and account state over websocket](examples/ws.py)
- [Create / modify / cancel an order over HTTP](examples/create_modify_cancel_order_http.py)
- [Create / modify / cancel an order over websocket](examples/create_modify_cancel_order_ws.py)
- [Read public REST endpoints](examples/market-data/get_info.py)
- [Stream order books and account state over websocket](examples/websocket/ws.py)
- [Create / modify / cancel an order over HTTP](examples/orders/create_modify_cancel_order_http.py)
- [Create / modify / cancel an order over websocket](examples/orders/create_modify_cancel_order_ws.py)
- [System setup (API key, signer)](examples/system_setup.py)

See [`examples/README.md`](examples/README.md) for the full annotated list.
Expand Down
29 changes: 29 additions & 0 deletions test/test_readme_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Keep the hand-maintained README example links usable after moves."""
from pathlib import Path
import re
import unittest
from urllib.parse import unquote, urlsplit


class TestReadmeExamples(unittest.TestCase):
def test_example_links_resolve_in_checkout(self):
root = Path(__file__).resolve().parents[1]
readme = (root / "README.md").read_text(encoding="utf-8")
section = readme.split("## Examples", 1)[1].split(
"<!-- AUTOGEN:API_ENDPOINTS -->", 1
)[0]
targets = re.findall(r"\[[^\]]*\]\(([^)]+)\)", section)
self.assertTrue(targets, "README example links must not disappear")
for target in targets:
parsed = urlsplit(target)
if parsed.scheme or parsed.netloc or not parsed.path:
continue
with self.subTest(target=target):
self.assertTrue(
(root / unquote(parsed.path)).exists(),
"README example target is missing: " + target,
)


if __name__ == "__main__":
unittest.main()