def test_string_field_should_allow_creating_objects_with_values(color): # given from tests.app.models import ColorModel, Color enum_color = Color(color) # when instance = ColorModel.objects.create(color=color) # then assert instance.color.value == enum_color.value assert instance.color.display == enum_color.display
def test_should_allow_queryset_defer(color): # given from tests.app.models import ColorModel, Color enum_color = Color(color) ColorModel.objects.create(color=color) # when instance = ColorModel.objects.filter(color=color).defer('color').first() # then assert instance.color.value == enum_color.value assert instance.color.display == enum_color.display
def test_string_field_should_allow_assigning_values(color): # given from tests.app.models import ColorModel, Color enum_color = Color(color) # when instance = ColorModel() instance.color = color instance.save() # then assert instance.color.value == enum_color.value assert instance.color.display == enum_color.display instance2 = ColorModel.objects.first() # then assert instance2.color.value == enum_color.value assert instance2.color.display == enum_color.display