'Ensure that unique_with constraints are applied to fields.'

def test_unique_with(self):

    class Date(EmbeddedDocument, ):
        year = IntField(db_field='yr')
    class BlogPost(Document, ):
        title = StringField()
        date = EmbeddedDocumentField(Date)
        slug = StringField(unique_with='date.year')
    BlogPost.drop_collection()
    post1 = BlogPost(title='test1', date=Date(year=2009), slug='test')
    post1.save()
    post2 = BlogPost(title='test2', date=Date(year=2010), slug='test')
    post2.save()
    post3 = BlogPost(title='test3', date=Date(year=2010), slug='test')
    self.assertRaises(OperationError, post3.save)
