'Create a new record with a duplicate primary key
throws an exception'

def test_unique_and_primary_create(self):

    class User(Document, ):
        name = StringField(primary_key=True)
        password = StringField()
    User.drop_collection()
    User.objects.create(name='huangz', password='secret')
    with self.assertRaises(NotUniqueError):
        User.objects.create(name='huangz', password='secret2')
    self.assertEqual(User.objects.count(), 1)
    self.assertEqual(User.objects.get().password, 'secret')
