Repository navigation
Expand file tree
/
Copy pathsimulate.py
More file actions
53 lines (44 loc) · 1.45 KB
/
Copy pathsimulate.py
File metadata and controls
53 lines (44 loc) · 1.45 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
Simulate incoming WhatsApp messages for testing.
Run this while app.py is running in another terminal.
"""
import requests
WEBHOOK_URL = "http://127.0.0.1:5000/webhook"
def fake_message(phone, text):
payload = {
"object": "whatsapp_business_account",
"entry": [{
"id": "fake",
"changes": [{
"value": {
"messaging_product": "whatsapp",
"messages": [{
"from": phone,
"id": "fake_id",
"timestamp": "1234567890",
"text": {"body": text},
"type": "text"
}]
},
"field": "messages"
}]
}]
}
r = requests.post(WEBHOOK_URL, json=payload)
print(f"[{phone[-4:]}] sent '{text}' → server responded {r.status_code}")
ALICE = "919999999001"
BOB = "919999999002"
print("=== Registering both members ===")
fake_message(ALICE, "hi")
fake_message(BOB, "hi")
print("\n=== Alice splits 600 ===")
fake_message(ALICE, "/split 600")
print("\n=== Check balances (from Alice's perspective) ===")
fake_message(ALICE, "/balances")
print("\n=== Check balances (from Bob's perspective) ===")
fake_message(BOB, "/balances")
print("\n=== Alice splits again: 300 ===")
fake_message(ALICE, "/split 300")
print("\n=== Final balances ===")
fake_message(ALICE, "/balances")
fake_message(BOB, "/balances")