'Ensure that the uniqueness constraints are applied to fields in
embedded documents, even when the embedded documents in in a
list field.'

def test_unique_embedded_document_in_list(self):

    class SubDocument(EmbeddedDocument, ):
        year = IntField(db_field='yr')
        slug = StringField(unique=True)
    class BlogPost(Document, ):
        title = StringField()
        subs = ListField(EmbeddedDocumentField(SubDocument))
    BlogPost.drop_collection()
    post1 = BlogPost(title='test1', subs=[SubDocument(year=2009, slug='conflict'), SubDocument(year=2009, slug='conflict')])
    post1.save()
    post2 = BlogPost(title='test2', subs=[SubDocument(year=2014, slug='conflict')])
    self.assertRaises(NotUniqueError, post2.save)
