File size: 797 Bytes
8830fa5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Seed the spliteasy backend with 3 users and 1 group."""
import sys
import requests

BASE = "http://127.0.0.1:5001"


def post(path, payload):
    r = requests.post(f"{BASE}{path}", json=payload, timeout=10)
    if r.status_code >= 400:
        print(f"[seed] POST {path} -> {r.status_code} {r.text}", file=sys.stderr)
        sys.exit(1)
    return r.json()


def main():
    users = [
        {"name": "Alice", "email": "alice@x.io"},
        {"name": "Bob", "email": "bob@x.io"},
        {"name": "Carol", "email": "carol@x.io"},
    ]
    user_ids = [post("/api/users", u)["id"] for u in users]
    group = post("/api/groups", {"name": "Tahoe Trip", "member_ids": user_ids})
    print(f"[seed] created group id={group['id']} with members={user_ids}")


if __name__ == "__main__":
    main()