def test_test_xmlrpc_call(self): handler = XMLRPCHandler('api') app = Flask(__name__) handler.connect(app, '/api') handler.register(hello) assert (test_xmlrpc_call(app.test_client(), '/api', 'hello') == 'Hello, world!')
def test_connect(self): handler = XMLRPCHandler('api') app = Flask(__name__) handler.connect(app, '/api') if PY2: app_handler = app.view_functions[handler.endpoint_name].im_self else: app_handler = app.view_functions[handler.endpoint_name].__self__ assert app_handler is handler
def test_call(self): handler = XMLRPCHandler('api') app = Flask(__name__) handler.connect(app, '/api') handler.register(hello) data = dump_method_call('hello', 'Steve') client = app.test_client() rv = client.post('/api', data=data, content_type='text/xml') res = load_method_response(rv.data) assert res == 'Hello, Steve!'
else: session['logged_in'] = True flash('You were logged in') return redirect(url_for('show_entries')) return render_template('login.html', error=error) @app.route('/logout') def logout(): session.pop('logged_in', None) flash('You were logged out') return redirect(url_for('show_entries')) api = XMLRPCHandler('api') api.connect(app, '/api') flaskr = api.namespace('flaskr') @flaskr.register def new_post(username, password, title, text): if username != USERNAME or password != PASSWORD: raise Fault('bad_credentials', "The username and password are " "incorrect.") g.db.execute('insert into entries (title, text) values (?, ?)', [title, text]) g.db.commit() return True @flaskr.register