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
integration with factory-boy or other similar solution #78
Comments
Thanks a lot for the suggestion! However, I think that data creation is out of scope of this project. @pytest.mark.django_db
def test_my_app_migration0031(migrator, fakery):
"""Ensures that the some fields are deleted correctly."""
old_state = migrator.before(
('my_app', '0030_pre'),
)
my_model = old_state.apps.get_model(
'my_app', 'MyModel',
)
kwargs_to_delete = [
{'a': None},
{'b': 'in_progress'},
{'c': None},
{'d': ''},
{'e': ''},
{'f': None},
]
for kwargs in kwargs_to_delete:
fakery.m(my_model)(**kwargs)
assert my_model.objects.count() == len(kwargs_to_delete)
new_state = migrator.after(('my_app', '0031_some'))
my_model = new_state.apps.get_model(
'my_app', 'MyModel',
)
assert not my_model.objects.count() |
What's exactly |
Oh, sorry. It is a tool similar to |
Looks really good! I will give it a shot, even just for migrations tests. |
It seems like using factories would be pretty hard without either duplicating factories for each tested state, or getting a lot of strange errors because factories are always a mirror of the last database state. To me neither of those options seem worth it. |
That's true, it's possible, but implementation and maintenance will be much more complicated than the benefits, so I am closing this issue |
https://github.com/fcurella/django-fakery can be used, because it uses |
Many of existing Django projects use
factory-boy
or other similar solution to create models instances before actual tests, so it will be really handy to provide some integration with such tools to make migrations testing easier and less verbose thanModel.objects.create()
etc.The text was updated successfully, but these errors were encountered: