-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start to use factories to generate test data #554
Conversation
c35cbf7
to
e71a069
Compare
e71a069
to
736556b
Compare
736556b
to
7f5dd92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this!
Since migrating the static data to this will require some efforts, what are the next steps? Merge this and live with the 2 ways, and migrate later?
Potentially. I don't know if this is a viable solution, but we could make it a point in PR review to say, "Did you modify a test"? If so, replace any static fixture data with a factory." |
double_opt_in = False | ||
has_opted_out_of_email = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to modify this for active/inactive contacts? (I think active contacts should have double_opt_in
to True)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we will have to override this default for different test cases -- either we keep this as is and override double_opt_in
where applicable, or vice versa.
We could also create additional factories with different defaults for different test cases.
b561dfb
to
b331d5b
Compare
We use static data as test data throughout our tests. Some observations I've made about this data and the tests that use them:
In this PR, we would introduce the use of test factories with Factory Boy and pytest-factoryboy. I've done minimal setup in this PR to demonstrate a proof of concept. This involved adding a
scoped_session
for database tests as well as making two example factories and using them in two example tests.If we like this pattern, we can use it going forward with the goal of making existing tests easier to understand and new tests easier to write.