Changes between Version 6 and Version 7 of Ticket #31416, comment 16
- Timestamp:
- Apr 18, 2020, 5:12:48 AM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31416, comment 16
v6 v7 2 2 > Nan Liu, this test doesn't cover the issue, because it's not related with migrations. We have here inline models so migrations are not involved, it doesn't fail. New tests should be added to `tests/migrations`, you can find there similar tests. 3 3 4 I'm not sure whether I should put tests in `test_autoencoder` or `test_operations` since the issue is related to adjusting autoencoder as well as operations swapping. My intuition tells me that I should add some tests in `test_ operations.py` since we want to swap operations so that field removals of bases can take place before newly added sub-models can be created, but I just thought it would be always good to ask here. much appreciated!4 I'm not sure whether I should put tests in `test_autoencoder` or `test_operations` since the issue is related to adjusting autoencoder as well as operations swapping. My intuition tells me that I should add some tests in `test_autoencoder.py`. 5 5 6 And for this test, i need to do two separate migrations in `app`, then how can i do it in unit tests since `self.get_change` will only have one migration when i do `self.get_change([Readable], [Readable_with_no_fields, Book, Magazine])`. When I do local testings, two separate migrations(one is to create `Readable` with fields `title` and `name`, second one is to remove fields from `Readable` and add these two fields into inheriting models like `Book`, `Magazine`), will solve the issue. But if i do `self.get_change([Readable], [Readable_with_no_fields, Book, Magazine])`, the test case tells me that models are created before base fields are removed, which is different from what i have on local testings.6 When I do local testings, two separate migrations(one is to create `Readable` with fields `title` and `name`, second one is to remove fields from `Readable` and add these two fields into inheriting models like `Book`, `Magazine`), will solve the issue. But if i do `self.get_change([Readable], [Readable_with_no_fields, Book, Magazine])`, the test case tells me that models are created before base fields are removed, which is different from what I have on local testings according to the console message. 7 7 8 It seems to me that there is probably something that reorders the order of the action operations before it prints out action operations executed in the console. In this case, it should've been `["RemoveField", "RemoveField", "CreateModel", "CreateModel"]`, but currently it is `["CreateModel", "CreateModel", "RemoveField", "RemoveField"]`. But the program is still able to solve the issue. How am i supposed to write test cases for that? 8 {{{ 9 Migrations for 'test': 10 test/migrations/0002_auto_20200418_1007.py 11 - Remove field name from readable 12 - Remove field title from readable 13 - Create model Book 14 - Create model Magazine 15 }}} 16 17 It seems to me that there is probably something that reorders the order of the action operations before it prints out action operations executed in the console. In this case, it should've been `["RemoveField", "RemoveField", "CreateModel", "CreateModel"]`, but currently it is `["CreateModel", "CreateModel", "RemoveField", "RemoveField"]`. But the program is still able to solve the issue when `makemigrations`. How am i supposed to write test cases for that? 9 18 10 19 [https://github.com/django/django/blob/master/django/core/management/commands/makemigrations.py#L164-L169] in `makemigrations.py` makes the order correct. But i guess the order isn't adjusted before this.