'Ensure that dbref conversion to string does not fail when
non-ascii characters are used in primary key'

def test_non_ascii_pk(self):

    class Brand(Document, ):
        title = StringField(max_length=255, primary_key=True)
    class BrandGroup(Document, ):
        title = StringField(max_length=255, primary_key=True)
        brands = ListField(ReferenceField('Brand', dbref=True))
    Brand.drop_collection()
    BrandGroup.drop_collection()
    brand1 = Brand(title='Moschino').save()
    brand2 = Brand(title=u'\u0414\u0435\u043d\u0438\u0441    \u0421\u0438\u043c\u0430\u0447\u0451\u0432').save()
    BrandGroup(title='top_brands', brands=[brand1, brand2]).save()
    brand_groups = BrandGroup.objects().all()
    self.assertEqual(2, len([brand for bg in brand_groups for brand in bg.brands]))
