Let me run it by my CTO. But I should be able to send over our migration test class. On Jun 12, 2015 11:58 AM, "Tim Graham" <[email protected]> wrote:
> Sure... what do you think of the API that Tom proposed? Did you have > something different in mind? > > On Friday, June 12, 2015 at 10:23:57 AM UTC-4, Sean Briceland wrote: >> >> I believe Tom is referring to testing their migration files in order to >> ensure DB is migrated accordingly. >> >> For example, at our company we test all of our source code & Migrations >> are code too! Most of the time we test rolling migrations forwards and >> backwards to ensure they will run without a hitch once deployed to >> production. >> >> For data migrations we use the MigrationLoader to generate models at a >> given state of the migration history. Then we can verify we our code within >> the migration mutates the data as desired. >> >> While Django Migrations are tested, stable, & kicka$$, they do not >> prevent developers from generating erroneous data migrations or even >> irreversible schema migrations. >> >> I jumped on this post because we now have a pretty beefy Django >> Application and as a result our Migration Tests take forever. Without >> getting into to much detail, I want to make sure that it would be okay to >> post here? or should I open a new thread? >> >> On Friday, May 8, 2015 at 12:36:48 PM UTC-4, Andrew Godwin wrote: >>> >>> Hi Tom, >>> >>> When you say "testing migrations", what do you mean exactly? The >>> migration framework itself is heavily unit-tested, so I presume you intend >>> to test things like custom RunPython function bodies and the like? >>> >>> Andrew >>> >>> On Thu, May 7, 2015 at 3:30 AM, Tom Linford <[email protected]> wrote: >>> >>>> At Robinhood, we've been using a custom in-house MigrationTestCase for >>>> testing migrations that we'd like to contribute, but want to check the API >>>> of it before contributing it. Here's the definition of the class: >>>> >>>> class MigrationTestCase(TransactionTestCase): >>>> """ >>>> app_label: name of app (ie. "users" or "polls") >>>> (start|dest)_migration_name: name of migration in app >>>> (e.g. "0001_initial") >>>> additional_dependencies: list of tuples of `(app_label, >>>> migration_name)`. >>>> Add any additional migrations here that need to be included in >>>> the >>>> generation of the model states. >>>> >>>> Usage: >>>> >>>> class TestCase(MigrationTestCase): >>>> app_label = ... >>>> start_migration_name = ... >>>> dest_migration_name = ... >>>> additional_dependencies = ... >>>> >>>> def setUp(self): >>>> # Create models with regular orm >>>> super(TestCase, self).setUp() >>>> # Create models with start orm. Access model with: >>>> # self.start_models["<app_label>"]["<model_name>"] >>>> # Note that model_name must be all lower case, you can just >>>> do: >>>> # <instance>._meta.model_name to get the model_name >>>> >>>> def test(self): >>>> # Still using start orm >>>> self.migrate_to_dest() >>>> # Now, you can access dest models with: >>>> # self.dest_models["<app_label>"]["<model_name>"] >>>> """ >>>> app_label = None >>>> start_migration_name = None >>>> dest_migration_name = None >>>> additional_dependencies = [] >>>> >>>> >>>> Let me know if this API is agreeable and I can make a PR for this >>>> feature. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Django developers (Contributions to Django itself)" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at http://groups.google.com/group/django-developers. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-developers/8818bf72-aa66-4351-9177-e6e0f6605386%40googlegroups.com >>>> <https://groups.google.com/d/msgid/django-developers/8818bf72-aa66-4351-9177-e6e0f6605386%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- > You received this message because you are subscribed to a topic in the > Google Groups "Django developers (Contributions to Django itself)" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-developers/181BkMhFUwo/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/e4aadb20-30ec-4968-8564-c6652dafeaf9%40googlegroups.com > <https://groups.google.com/d/msgid/django-developers/e4aadb20-30ec-4968-8564-c6652dafeaf9%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAPLXpYE_fV%3Djpa%2BzSD8QKteJ4Fh7r86mMQvY5cX08dFjYr%3D_gQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
