1👍
✅
Yes it’s a valid approach.
Each app would have its own factories.py
file with the factories for its own models. And if an app also depends on models from other apps you import them from the originating app to keep it DRY.
Example:
app1
|__ factories.py
app2
|__ factories.py
app3
|__ tests.py # Tests interaction of app3 with app1 and app2
|__ factories.py # Define factories for app3's models only
# and reuse factories from app1 and app2
# for their models
# app3/tests.py
from app1.factories import Model1
from app2.factories import Model2
from app3.factories import Model3
def test_feature_in_app3():
# do something with Model1, Model2 and Model3
Source:stackexchange.com