diff options
author | neodarz <neodarz@neodarz.net> | 2018-06-16 17:52:31 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-06-16 17:52:31 +0200 |
commit | 5bcc1ed9df4e7a6b8086cac3f25a466aee3bebcd (patch) | |
tree | f4e72ed3712a148a28a0c11323f1796f7499a336 /src/tests/test_api.py | |
parent | cf29b5d4324b03d826615cfbb7f7345c54da1762 (diff) | |
download | liberationCenter-5bcc1ed9df4e7a6b8086cac3f25a466aee3bebcd.tar.xz liberationCenter-5bcc1ed9df4e7a6b8086cac3f25a466aee3bebcd.zip |
Add first structure of the application
Diffstat (limited to '')
-rw-r--r-- | src/tests/test_api.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tests/test_api.py b/src/tests/test_api.py new file mode 100644 index 0000000..063f32f --- /dev/null +++ b/src/tests/test_api.py @@ -0,0 +1,22 @@ +import pytest, re + +from flask import session +from bson.json_util import dumps + +from pprint import pprint + +def test_api_get_all_users(client, app): + response = client.get('/api/users') + assert response.status_code == 200 + assert response.is_json + assert re.search('username', str(response.data)) + +@pytest.mark.parametrize(('username', 'message'), ( + ('', b'{"msg": "Username is required."}'), + ('neo', b'{"msg": "User neo is already registered."}'), + ('neodarz', b'{"msg": "done"}') +)) +def test_api_register(client, app, username, message): + response = client.post('/api/user/register', data='{"username": "'+username+'"}') + print(response.data) + assert message in response.data |