# Created 2019-09-11 by NGnius import requests # this is mainly smoke-testing since # writing complete and proper unit testing for a single-file server is out of scope # /release test print('Testing /release') raw_token = input('token password: ') release_resp = requests.post('http://localhost:9080/release', json={'token':raw_token, 'version':'v42.0.0a', 'platform':'fake-i386', 'url':'https://google.com'}) print(release_resp.json()) assert release_resp.status_code == 200 print('Release Ok') # /database test print('Testing /database') database_resp = requests.get('http://localhost:9080/database') assert database_resp.status_code == 200 print('Database Ok') # /update test print('Testing /update existing platform') update_resp = requests.post('http://localhost:9080/update', json={'version':'v0.42.0a', 'platform':'fake-i386'}) print(update_resp.json()) assert update_resp.status_code == 200 assert update_resp.json()['url'] == 'https://google.com' print('Testing /update missing platform') update_resp = requests.post('http://localhost:9080/update', json={'version':'v0.42.0a', 'platform':'fake-amd64'}) print(update_resp.json()) assert update_resp.status_code == 404 assert update_resp.json()['url'] == '' print('Update Ok') print('Testing /update DNT') update_resp = requests.post('http://localhost:9080/update', json={'version':'v0.42.0a', 'platform':'fake-i386'}, headers={"DNT": "1"}) print(update_resp.json()) assert update_resp.status_code == 200 assert update_resp.json()['url'] == 'https://google.com' print('Update Ok')