I'm working on writing functional tests for an web application I'm building. I'm fairly new to testing and trying to get to grips with best practices. The application has a moderate amount of complexity, and I'm trying to write a functional test for a process that is part of a bigger process.
The wider process:
user does A -> user does B (using the DB data generated from A) -> user does C (using the DB data generated from A and B)
The process I want to test:
user does B (using the DB data generated from A) -> generates the data required for C
An example scenario to illustrate:Let's use the following example: An app that generates email templates for the user
A : user has registered and entered their personal data
B : user logs in and generates a template email with their name, address in the right places
When I'm testing on my local PC, I'm using LiveServerTestCase to create the DB and run a server I can test against with Selenium, and in the setup of my functional test, I create the appropriate initial data using my model code.
When I'm testing on staging, I'm using my local PC to interact with the up-and-running live server on the staging server, and not the one generated using LiveServerTestCase.
My questions:
1) Is it good practice to set up initial data for functional tests using model code (given it's supposed to be a black box test)?
2) During the staging test, how would I populate the DB with the required data? The only way I can think of now is by using Fabric to launch `python manage.py shell` but I feel it might not be the best way