Here is details1. Typical project structure2. Blueprints3. Database4. Forms & Validation5. Management Commands6. Assets-management7. Replacement of django.contrib.admin8. Debugging9. Unit tests and Behavior tests
Management CommandsWrite external scripts with current project context
Flask-Script1. Create manage.py script within your project directory and put(which is quite similar to Djangos manage.py):from flaskext.script import Managerfrom app import appmanager = Manager(app)@manager.commanddef hello(): print "hello"if __name__ == "__main__": manager.run()
Flask-Scriptmaxk$ python manage.py shell Runs a Python shell insideFlask application context. hello runserver Runs the Flask developmentserver i.e. app.run()maxk$ python manage.py hellohello
Flask-ScriptWith Flask-Script you able to:• Write custom management commands• Use existing ones like in flask-assets• Getting users input• Use command line optionsAll of abilities above already automated with Flask-Script andits really easy-to-use.
JS/CSS minification and so onFlask-Assets based on Webassets. To integrate weneed some work to do:1. Install Flask-Assets2. Initialize Flask-Assets environment3. Add Assets Bundles4. Configure compressors/minifiers etc. to optimize our assets5. Generate bundles with management command
Testing: Unit & BehaviorTo test templates, views etc we need to have request contextBefore execution:self.app.test_request_context().push()After execution:self.app.test_request_context().pop()
Behavior Testes with LettuceExample feature and scenario:Feature: Auth Scenario: Sign In as featured expert When I go to "auth.login" view Then I see that response code is 200 And Theres form with following fields: | form__username | | form__password | Fill the field "form__username" with "featured"
lettuce-webLettuce-web is a library which very close to headless testingusing twill. lettuce-web doesnt require browser. You canwrite your features using lettuce-web predefined steps. More here: https://github.com/joymax/lettuce-web