'Tests the AddField operation\'s state alteration
when preserve_default = False.'

def test_add_field_preserve_default(self):

    project_state = self.set_up_test_model('test_adflpd')
    operation = migrations.AddField('Pony', 'height', models.FloatField(null=True, default=4), preserve_default=False)
    new_state = project_state.clone()
    operation.state_forwards('test_adflpd', new_state)
    self.assertEqual(len(new_state.models[('test_adflpd', 'pony')].fields), 4)
    field = [f for (n, f) in new_state.models[('test_adflpd', 'pony')].fields if (n == 'height')][0]
    self.assertEqual(field.default, NOT_PROVIDED)
    project_state.apps.get_model('test_adflpd', 'pony').objects.create(weight=4)
    self.assertColumnNotExists('test_adflpd_pony', 'height')
    with connection.schema_editor() as editor:
        operation.database_forwards('test_adflpd', editor, project_state, new_state)
    self.assertColumnExists('test_adflpd_pony', 'height')
    definition = operation.deconstruct()
    self.assertEqual(definition[0], 'AddField')
    self.assertEqual(definition[1], [])
    self.assertEqual(sorted(definition[2]), ['field', 'model_name', 'name', 'preserve_default'])
