I currently is trying to implement Integration Test. CMMIW, after googling for a few hours I often find that the testing data must always be clean up and set up like seeding data for each test case so that there is no dirty data in the testing database to avoid flaky tests using setup and teardown function.
but I can’t find any approach for seeding data using SQLAlchemy, if you guys ever have to deal with this problem please share 🙂
I have several ideas for seeding database :
- Create SQL Script that contains SQL query for Insert and Delete and then execute raw query
- Create CSV file and loop through and insert manually
- Create manually every time we need the data
but I think it will be many hardcoded ID when testing, something like get_by_id is it will be a problem ? or is common in integration test since we always use the same data for testing?
so.. what is the best practice for seeding data for Integration Testing in Python?
Source: Python Questions