Flask Web App Testing
Hello!
I am reaching out to the Dataiku user community in regards to the web apps in Dataiku DSS. Does anyone know where I should be writing my test code and calling it as well? For instance, if I wanted to use pytest for testing my flask app.
https://flask.palletsprojects.com/en/1.1.x/testing/
Thank you for your help!
Best,
Adam
Best Answer
-
Sarina Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 317 Dataiker
Hey Adam,
One option for testing your flask app using a test framework would be to:
- Convert your web app to a plugin for development testing. You can do this by clicking on Actions | Convert to Plugin from your Webapp.
- You can then set up a code editor like Atom or Sublime to develop and run test code for the plugin. There is an Academy course that you can register for that walks through this setup with the intention of creating test files: Plugin Development .
The plugin can also be integrated with GitHub as described here: Git integration in the plugin editor. You would need to either download the plugin or push it to Git and work from there to run any created test code.
Alternatively, if you have access to your DSS server, you can grab your python file and run your test code against the python Webapp code. If you do this, you should not store your test files within your data directory, and instead pull your python code out for testing. Your python Webapp code lives in
DATA_DIR/config/projects/{PROJECT_NAME}/web_apps/{WEBAPP_ID}/backend.py
Thanks,
Sarina
Answers
-
Thank you!