hmarr/mongoengine — Issue #334: unique=True doesn't after drop_collection
Author: sirkonst
Created: 2011-10-27 10:12:27+00:00
State: open

Test code:

```python

##### Init

class Account(Document):
name = StringField(unique=True)

connect(...)

##### Focus:

Account.drop_collection()

acc_1 = Account.objects.create(name='test')

try:
acc_1_dup = Account.objects.create(name='test')
except OperationError:
print 'Good'

# Now drop again
Account.drop_collection()

acc_2 = Account.objects.create(name='test')

try:
acc_2_dup = Account.objects.create(name='test')
except OperationError:
print 'Good'
else:
print 'Bad :-('

```