'Ensure that uniqueness constraints are applied to fields on embedded documents.'

def test_unique_embedded_document(self):

    class SubDocument(EmbeddedDocument, ):
        year = IntField(db_field='yr')
        slug = StringField(unique=True)
    class BlogPost(Document, ):
        title = StringField()
        sub = EmbeddedDocumentField(SubDocument)
    BlogPost.drop_collection()
    post1 = BlogPost(title='test1', sub=SubDocument(year=2009, slug='test'))
    post1.save()
    post2 = BlogPost(title='test2', sub=SubDocument(year=2010, slug='another-slug'))
    post2.save()
    post3 = BlogPost(title='test3', sub=SubDocument(year=2010, slug='test'))
    self.assertRaises(NotUniqueError, post3.save)
