import json from flask import url_for from data import model from endpoints.appr.registry import appr_bp from test.fixtures import app, appconfig, database_uri, init_db_path, sqlitedb_file def test_invalid_login(app, client): app.register_blueprint(appr_bp, url_prefix='/cnr') url = url_for('appr.login') headers = {'Content-Type': 'application/json'} data = {'user': {'username': 'foo', 'password': 'bar'}} rv = client.open(url, method='POST', data=json.dumps(data), headers=headers) assert rv.status_code == 401 def test_valid_login(app, client): app.register_blueprint(appr_bp, url_prefix='/cnr') url = url_for('appr.login') headers = {'Content-Type': 'application/json'} data = {'user': {'username': 'devtable', 'password': 'password'}} rv = client.open(url, method='POST', data=json.dumps(data), headers=headers) assert rv.status_code == 200