import json import pytest from flask import url_for from data import model from endpoints.test.fixtures import app, appconfig, database_uri, init_db_path, sqlitedb_file from endpoints.appr.registry import appr_bp 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