(self)
| 1579 | INSTALLED_APPS=["migrations", "migrations2"], |
| 1580 | ) |
| 1581 | def test_prune_respect_app_label(self): |
| 1582 | recorder = MigrationRecorder(connection) |
| 1583 | recorder.record_applied("migrations", "0001_initial") |
| 1584 | recorder.record_applied("migrations", "0002_second") |
| 1585 | recorder.record_applied("migrations", "0001_squashed_0002") |
| 1586 | # Second app has squashed migrations with replaces. |
| 1587 | recorder.record_applied("migrations2", "0001_initial") |
| 1588 | recorder.record_applied("migrations2", "0002_second") |
| 1589 | recorder.record_applied("migrations2", "0001_squashed_0002") |
| 1590 | out = io.StringIO() |
| 1591 | try: |
| 1592 | call_command("migrate", "migrations", prune=True, stdout=out, no_color=True) |
| 1593 | self.assertEqual( |
| 1594 | out.getvalue(), |
| 1595 | "Pruning migrations:\n" |
| 1596 | " Pruning migrations.0001_initial OK\n" |
| 1597 | " Pruning migrations.0002_second OK\n", |
| 1598 | ) |
| 1599 | applied_migrations = [ |
| 1600 | migration |
| 1601 | for migration in recorder.applied_migrations() |
| 1602 | if migration[0] in ["migrations", "migrations2"] |
| 1603 | ] |
| 1604 | self.assertEqual( |
| 1605 | applied_migrations, |
| 1606 | [ |
| 1607 | ("migrations", "0001_squashed_0002"), |
| 1608 | ("migrations2", "0001_initial"), |
| 1609 | ("migrations2", "0002_second"), |
| 1610 | ("migrations2", "0001_squashed_0002"), |
| 1611 | ], |
| 1612 | ) |
| 1613 | finally: |
| 1614 | recorder.record_unapplied("migrations", "0001_initial") |
| 1615 | recorder.record_unapplied("migrations", "0001_second") |
| 1616 | recorder.record_unapplied("migrations", "0001_squashed_0002") |
| 1617 | recorder.record_unapplied("migrations2", "0001_initial") |
| 1618 | recorder.record_unapplied("migrations2", "0002_second") |
| 1619 | recorder.record_unapplied("migrations2", "0001_squashed_0002") |
| 1620 | |
| 1621 | @override_settings( |
| 1622 | INSTALLED_APPS=[ |
nothing calls this directly
no test coverage detected