Questions tagged [flask-testing]

80 questions
0
votes
1 answer

FlaskTest FieldList form

I have forms: class EntryForm(CsrfDissableForm): id = HiddenField() name = StringField(...) ... class FooForm(FlaskForm): entries = FieldList(FormField(EntryForm)) new_name = StringField(...) ... In route: ... while…
pirr
  • 445
  • 1
  • 8
  • 15
0
votes
0 answers

SQLAlchemy accepts everything like different data types, empty strings, strings with bigger length

I am using Flask and Flask SQLAlchemy and Flask Test. I define an example model with a string column with max length of 100. I thought I should get an exception if I try to insert a string with a length bigger than 100. SQLAlchemy even allows me to…
Greeneco
  • 691
  • 2
  • 8
  • 23
0
votes
0 answers

how to specify headers in python Flask while testing Flask application using flask.app.test_client()?

We are testing a Python Flask application using flask.app.test_client like explained here Our application works with JWT tokens for authentication purpose, so all API call's must have the token specified. Is there way to provide JWT as header to…
0
votes
1 answer

how to write test cases for authenticated urls in flask

I am using flask with mongoengine and Login Manager for session maintaining. I want to write test cases for authenticated views. can any one help/suggestions regarding this.
duddu venkatesh
  • 136
  • 2
  • 13
0
votes
1 answer

flask testing configuration in config.py vs. base test class

I have a project where I defined a test configration in config.py, but I'm puzzled by the following: Many times there is a testing configuration for config.py being discussed in tutorials, like this one Actual testing with database is usually done…
Evgeny
  • 4,173
  • 2
  • 19
  • 39
0
votes
2 answers

Flask testing create_app is not returning the application?

I am working on setting up unit tests in my flask project right now. My test file is below: import flask_testing import unittest from flask import Flask from flask_testing import TestCase class MyTest(TestCase): def setUp(self): pass #…
Programmingjoe
  • 2,169
  • 2
  • 26
  • 46
0
votes
0 answers

Peewee Flask Test API in memory

I want to test my application API using Flask + Werkzeug + SQLite in memory. The application was configured using application factory pattern, like this: def create_app(config_name): application = Flask(__name__) …
Rangel
  • 11
  • 2
0
votes
1 answer

Flask testing keeps failing

So I have web app where if the user is logged in, he cannot sign up. Instead he is redirected and a message saying he cannot sign up is flashed. The problem is I can't test it for some reason. Here is the view @users_template.route('/signup',…
MAA
  • 1,294
  • 3
  • 18
  • 34
0
votes
2 answers

Why isn't my Flask application's global object deleted on app teardown?

I am writing an application with a global object that should live as long as the application as alive. Different endpoints should mutate the global object. Below is my server with an example mock-up object to be mutated on dummy endpoint…
erip
  • 16,374
  • 11
  • 66
  • 121
0
votes
1 answer

Flask test client refuse arobase in data?

I'm trying to set up tests in my Flask but for an unknown reason, Flask fails when I add a parameter with arobase. I followed the snippet here http://flask.pocoo.org/snippets/26/ and can make a successful request (it works), but when I try to do a…
Cyril N.
  • 38,875
  • 36
  • 142
  • 243
0
votes
1 answer

Flask testing database application context

How can I structure my flask project such that my models can be aware of if TESTING is enabled (and thereby use a testing database), without having them deal with or have any knowledge of app context. I'm developing this as an open source project so…
NFicano
  • 1,065
  • 1
  • 11
  • 26
0
votes
1 answer

How do I mock dependencies of the views module of my Flask application in flask-testing?

As a minimal example, my Flask application has a views module like from flask import render_template from something import some_service def home(): foo = some_service.do_thing('bar') return render_template('index.html', foo=foo) I've got…
brandones
  • 1,847
  • 2
  • 18
  • 36
0
votes
0 answers

Flask -Test TemplateNot found exception

I want to test some routes but when i run nosetests it writes error "TemplateNotFound: main.html" I have render_templates = False in my flask test Class. For example i want to test this endpoint @users.route('/test', methods=['GET','POST']) …
Beka Tomashvili
  • 2,171
  • 5
  • 21
  • 27
0
votes
1 answer

Can't upload file and data in same request in Flask test

Hi i'm trying to test and endpoint that will need a file and some values, when i upload only the file there is not problem, but when i add the values it throws: TypeError: 'str' does not support the buffer interface my code is like this: headers =…
Chris Gomez
  • 6,644
  • 4
  • 18
  • 39
0
votes
2 answers

how can test u=g.user in Flask

Lets say I have flask Application Now I want to test u=g.user.be_friend(user) which make a user friend with eachother if they werene't friend befor But I don't know how I can test g.user and most importantly g.user.be_friend would you please help…
LiLi
  • 301
  • 2
  • 7
  • 21