add test client
This commit is contained in:
parent
8dac06a050
commit
fd3d597712
35
test-client.py
Executable file
35
test-client.py
Executable file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from datetime import datetime
|
||||
import requests
|
||||
|
||||
|
||||
url = 'http://127.0.0.1:8000/billard/api/v1/location_data/'
|
||||
token = '7fdc4e8fbe2508b70f73c65c2d05475632e2388a'
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--on', action="store_true", help="on or of the switch")
|
||||
parser.add_argument('--date', default=datetime.now(), help="the tst to set")
|
||||
parser.add_argument('--desk', default=1, help="the desk number")
|
||||
args = parser.parse_args()
|
||||
payload = {
|
||||
'location_id': 'a7b47b4b-5b63-3b2f-8af0-4b185843f419',
|
||||
'table_no': args.desk,
|
||||
'tst': args.date.strftime('%Y-%m-%dT%H:%M:%S%Z')
|
||||
}
|
||||
if args.on:
|
||||
payload['on_off'] = 1
|
||||
else:
|
||||
payload['on_off'] = 0
|
||||
print(payload)
|
||||
headers = {'Authorization': 'Token ' + token, }
|
||||
r = requests.post(url=url,
|
||||
data=payload,
|
||||
headers=headers)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user