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', 'code'), ( ('', 400), ('neo', 409), ('neodarz', 201) )) def test_api_register(client, app, username, code): response = client.post('/api/user/register', data='{"username": "'+username+'"}') print(response.data) assert code == response.status_code