Changes between Version 1 and Version 2 of Ticket #28250, comment 9
- Timestamp:
- May 30, 2017, 3:20:12 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28250, comment 9
v1 v2 1 1 Ideally, an exception will still be raised if the initial migration that may be faked is in the same app as an applied migration that depends on it. So if `app1.0001` is not applied, but is an initial migration that may be faked, and `app1.0002` is recorder as applied, it will still be an error. The executor should never apply `app1.0002` without faking `app1.0001`, so that state should be unreachable under normal circumstances. 2 2 3 I believe you can check this with `if migration[0] != parent[0]`.3 You can check this with `if migration[0] != parent[0]`. 4 4 5 5 I've written the following test for your branch, which should go into `migrations.test_loader.LoaderTests`: … … 12 12 @modify_settings(INSTALLED_APPS={'append': 'migrations2'}) 13 13 @mock.patch.object(MigrationLoader, 'detect_soft_applied', return_value=(True, None)) 14 def test_check_consistent_history_fake_initial(self ):14 def test_check_consistent_history_fake_initial(self, mock_detect_soft_applied): 15 15 loader = MigrationLoader(connection) 16 16 recorder = MigrationRecorder(connection) … … 27 27 }}} 28 28 29 This also tests for the same-app scenario. I haven't checked if the test is actually correct, and my mocking skills aren't too sharp, but this should get you a long way.29 This also tests for the same-app scenario. ~~I haven't checked if the test is actually correct, and my mocking skills aren't too sharp, but this should get you a long way.~~ I've had a chance to run the test, and it seems to be correct. 30 30 31 31 Note that `detect_soft_applied` returns a 2-tuple of `(<is_applied>, <state_after_migration>)`, which is non-empty and thus truthy, so you need to check for the first item in the return value.