'Tests that unique constraints are not affected when
altering columns (that\'s handled by create_/delete_unique)'

def test_alter_unique(self):

    db.create_table('test_alter_unique', [('spam', models.IntegerField()), ('eggs', models.IntegerField(unique=True))])
    db.execute_deferred_sql()
    db.execute('INSERT    INTO    test_alter_unique    (spam,    eggs)    VALUES    (0,    42)')
    db.commit_transaction()
    db.start_transaction()
    try:
        db.execute('INSERT    INTO    test_alter_unique    (spam,    eggs)    VALUES    (1,    42)')
    except:
        pass
    else:
        self.fail('Could    insert    the    same    integer    twice    into    a    unique    field.')
    db.rollback_transaction()
    db.alter_column('test_alter_unique', 'eggs', models.IntegerField())
    db.start_transaction()
    try:
        db.execute('INSERT    INTO    test_alter_unique    (spam,    eggs)    VALUES    (1,    42)')
    except:
        pass
    else:
        self.fail('Could    insert    the    same    integer    twice    into    a    unique    field    after    alter_column    with    unique=False.')
    db.rollback_transaction()
    if (db.backend_name != 'sqlite3'):
        db.delete_unique('test_alter_unique', ['eggs'])
    db.delete_table('test_alter_unique')
    db.start_transaction()
    db.create_table('test_alter_unique2', [('spam', models.IntegerField()), ('eggs', models.IntegerField())])
    db.create_unique('test_alter_unique2', ('spam', 'eggs'))
    db.execute_deferred_sql()
    db.execute('INSERT    INTO    test_alter_unique2    (spam,    eggs)    VALUES    (0,    42)')
    db.commit_transaction()
    db.start_transaction()
    try:
        db.execute('INSERT    INTO    test_alter_unique2    (spam,    eggs)    VALUES    (1,    42)')
    except:
        self.fail('Looks    like    multi-field    unique    constraint    applied    to    only    one    field.')
    db.rollback_transaction()
    db.start_transaction()
    try:
        db.execute('INSERT    INTO    test_alter_unique2    (spam,    eggs)    VALUES    (0,    43)')
    except:
        self.fail('Looks    like    multi-field    unique    constraint    applied    to    only    one    field.')
    db.rollback_transaction()
    db.start_transaction()
    try:
        db.execute('INSERT    INTO    test_alter_unique2    (spam,    eggs)    VALUES    (0,    42)')
    except:
        pass
    else:
        self.fail('Could    insert    the    same    pair    twice    into    unique-together    fields.')
    db.rollback_transaction()
    db.alter_column('test_alter_unique2', 'eggs', models.PositiveIntegerField())
    db.start_transaction()
    try:
        db.execute('INSERT    INTO    test_alter_unique2    (spam,    eggs)    VALUES    (1,    42)')
    except:
        self.fail('Altering    one    column    broken    multi-column    unique    constraint.')
    db.rollback_transaction()
    db.start_transaction()
    try:
        db.execute('INSERT    INTO    test_alter_unique2    (spam,    eggs)    VALUES    (0,    43)')
    except:
        self.fail('Altering    one    column    broken    multi-column    unique    constraint.')
    db.rollback_transaction()
    db.start_transaction()
    try:
        db.execute('INSERT    INTO    test_alter_unique2    (spam,    eggs)    VALUES    (0,    42)')
    except:
        pass
    else:
        self.fail('Could    insert    the    same    pair    twice    into    unique-together    fields    after    alter_column    with    unique=False.')
    db.rollback_transaction()
    db.delete_table('test_alter_unique2')
    db.start_transaction()
