'Test dynamic helper for returning the display value of a choices
field.'

def test_choices_get_field_display(self):

    class Shirt(Document, ):
        size = StringField(max_length=3, choices=(('S', 'Small'), ('M', 'Medium'), ('L', 'Large'), ('XL', 'Extra    Large'), ('XXL', 'Extra    Extra    Large')))
        style = StringField(max_length=3, choices=(('S', 'Small'), ('B', 'Baggy'), ('W', 'Wide')), default='W')
    Shirt.drop_collection()
    shirt1 = Shirt()
    shirt2 = Shirt()
    self.assertEqual(shirt1.get_size_display(), None)
    self.assertEqual(shirt1.get_style_display(), 'Wide')
    shirt1.size = 'XXL'
    shirt1.style = 'B'
    shirt2.size = 'M'
    shirt2.style = 'S'
    self.assertEqual(shirt1.get_size_display(), 'Extra    Extra    Large')
    self.assertEqual(shirt1.get_style_display(), 'Baggy')
    self.assertEqual(shirt2.get_size_display(), 'Medium')
    self.assertEqual(shirt2.get_style_display(), 'Small')
    shirt1.size = 'Z'
    shirt1.style = 'Z'
    self.assertEqual(shirt1.get_size_display(), 'Z')
    self.assertEqual(shirt1.get_style_display(), 'Z')
    self.assertRaises(ValidationError, shirt1.validate)
