@@TheDevWorldbySergioLema I would love to see how to integrate running tests in the dockefile building the app. Also maybe a deepdive into best practices in Mock data, connections and how set up and tear down tests while keeping things running fast
I'm not sure about the Dockerfile with tests. I don't see the usage. About the best practices, I just published a new video, check it: ruclips.net/video/gi7O-aYq6mo/видео.html
Is it not necessary to create another test db to store the initial test data? I mean, in that way, the added data is being stored in the main db or separately? When db.create_all is executed (9:03), it replaces the existing db with real data? Thank you, nice video!
What I usually do, is creating different fixtures. * The first one (with a scope of session) will create the database tables, and delete all the tables at the end; * The second one (with a scope of test) will add some data to the database, and drop all the data at the end; This means that each unit test will have initial data and clean up. But the tables will remain for the entire session. You can see more details in this conftest: github.com/serlesen/backend-flask/blob/main/tests/conftest.py
For bigger tests, maybe it's better to create a separate fixture which reload the data. For small tests, it's better to avoid reloading every time the data, as it won't change from test to test.
2 года назад
Hi Sergio, I am very new at testing. I cannot event test for first time. I have a project started and have blueprint and app factory structure similar to yours, but I got ModuleNotFoundError: No module named "name_of_app_folder" every time. Any suggestion?
Be sure to import everything from the root package, include the tests module in the import part.
2 года назад
@@TheDevWorldbySergioLema I am doing From app.models import Users .... on the test file inside the tests folder located on the same level as app folder. Each folder as a package with its __init__ file inside. Any suggestion?
It's very hard to guess the file path, project structure and the imports. I recommend you to create a question in Stackoverflow (with all the details and pieces of code), copy the link here, and I will do my best to answer it as soon as possible.
Thank you. This is the best tutorial I've found. It's up to date and I think it covers all major components in just 17 minutes.
Thank you so much. I appreciate a lot your comment
Super great materials! Im so gratefull i found this channel! Thank you Sergio!!
Thank you. Don't hesitate to share it. Do you think there is some content I'm missing in the playlist about Python and Flask?
@@TheDevWorldbySergioLema
I would love to see how to integrate running tests in the dockefile building the app.
Also maybe a deepdive into best practices in Mock data, connections and how set up and tear down tests while keeping things running fast
I'm not sure about the Dockerfile with tests. I don't see the usage.
About the best practices, I just published a new video, check it: ruclips.net/video/gi7O-aYq6mo/видео.html
Is it not necessary to create another test db to store the initial test data? I mean, in that way, the added data is being stored in the main db or separately? When db.create_all is executed (9:03), it replaces the existing db with real data? Thank you, nice video!
What I usually do, is creating different fixtures.
* The first one (with a scope of session) will create the database tables, and delete all the tables at the end;
* The second one (with a scope of test) will add some data to the database, and drop all the data at the end;
This means that each unit test will have initial data and clean up. But the tables will remain for the entire session.
You can see more details in this conftest: github.com/serlesen/backend-flask/blob/main/tests/conftest.py
Smart thanks
Thanks to you for watching!
i tried this and got the error ' RuntimeError: Working outside of application context.'
From where are you running the tests?
If you don't run them from the root folder of your project, you may encounter this error.
Thank you very good video!
Thank you for watching!
Thank you it's very good.
I try my best 😅
hi sergio, I think it miss the scope's fixture for app_with_data, otherwise with bigger test it reload data and we lost id of confest.py objects in db
For bigger tests, maybe it's better to create a separate fixture which reload the data.
For small tests, it's better to avoid reloading every time the data, as it won't change from test to test.
Hi Sergio, I am very new at testing. I cannot event test for first time. I have a project started and have blueprint and app factory structure similar to yours, but I got ModuleNotFoundError: No module named "name_of_app_folder" every time. Any suggestion?
Be sure to import everything from the root package, include the tests module in the import part.
@@TheDevWorldbySergioLema I am doing From app.models import Users .... on the test file inside the tests folder located on the same level as app folder. Each folder as a package with its __init__ file inside. Any suggestion?
It's very hard to guess the file path, project structure and the imports. I recommend you to create a question in Stackoverflow (with all the details and pieces of code), copy the link here, and I will do my best to answer it as soon as possible.
this is good. do you have any git url where you have sample code?
Yes, you can find all the examples and more here, github.com/serlesen/backend-flask/tree/chapter_5