code structure:
$ tree .
.
├── mock_app_running.py
└── chatbot
└── webhook.py
without mock:
$ python mock_app_running.py
...
#### another terminal ####
$ curl -H 'Content-Type: application/json' -X POST localhost:7056/receive -d '{"pi":3.14,"name":"f"}'
{
"data": "HTTPConnectionPool(host='127.0.0.1', port=4444): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7d95c9aa10>: Failed to establish a new connection: [Errno 111] Connection refused'))",
"status": "failure"
}
mock webhook handler:
$ MOCK=1 python mock_app_running.py
***[DEBUG] mock webhook handler
...
#### another terminal ####
$ curl -H 'Content-Type: application/json' -X POST localhost:7056/receive -d '{"pi":3.14,"name":"f"}'
{
"data": {
"name": "f",
"pi": 3.14
},
"status": "success"
}
mock send method