[Django] #24759: MigrationTestCase

14 views
Skip to first unread message

Django

unread,
May 6, 2015, 9:44:04 PM5/6/15
to django-...@googlegroups.com
#24759: MigrationTestCase
-----------------------------------+------------------------
Reporter: tomlinford | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: 1.8
Severity: Normal | Keywords: migrations
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------
At Robinhood, we've been using a custom in-house `MigrationTestCase` 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24759>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 6, 2015, 10:07:59 PM5/6/15
to django-...@googlegroups.com
#24759: MigrationTestCase
-----------------------------------+--------------------------------------

Reporter: tomlinford | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: 1.8
Severity: Normal | Resolution:

Keywords: migrations | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

The DevelopersMailingList is a better place to propose and get feedback on
features like this.

--
Ticket URL: <https://code.djangoproject.com/ticket/24759#comment:1>

Django

unread,
May 8, 2015, 7:11:15 AM5/8/15
to django-...@googlegroups.com
#24759: Add or document a way to test data migrations
-----------------------------------+------------------------------------

Reporter: tomlinford | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: 1.8
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


Comment:

[https://groups.google.com/d/topic/django-
developers/181BkMhFUwo/discussion django-developers thread]

Accepting on the basis of some way to test data migrations.

--
Ticket URL: <https://code.djangoproject.com/ticket/24759#comment:2>

Django

unread,
Apr 23, 2026, 10:17:39 AMApr 23
to django-...@googlegroups.com
#24759: Add or document a way to test data migrations
-------------------------------------+-------------------------------------
Reporter: Tom Linford | Owner: Hwayoung
| Cha
Type: New feature | Status: assigned
Component: Testing framework | Version: 1.8
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hwayoung Cha):

* owner: nobody => Hwayoung Cha
* status: new => assigned

Comment:

I'm organizing a contribution workshop. I've selected this ticket for our
members to work on during the upcoming event.
Please let me know if there are any specific considerations:)
--
Ticket URL: <https://code.djangoproject.com/ticket/24759#comment:3>
Reply all
Reply to author
Forward
0 new messages