def test_choice_equals(): choice_a = choices.Choice(value=123, label='123') choice_b = choices.Choice(value=123) choice_c = choices.Choice(value=456, label='123') assert not (choice_a == 'test') assert choice_a == 123 assert not choice_a == 456 assert choice_a == choice_a assert choice_a == choice_b assert choice_a != choice_c
class ContractStatesEnum(choices.Choices): Open = choices.Choice(10, _('open')) Payed = choices.Choice(20, _('payed')) Invoice_created = choices.Choice(30, _('Invoice created')) Invoice_sent = choices.Choice(40, _('Invoice sent')) Quote_created = choices.Choice(50, _('Quote created')) Quote_sent = choices.Choice(60, _('Quote sent')) PurchaseOrder_created = choices.Choice(70, _('Purchaseorder created')) Customer_cant_pay = choices.Choice(90, _('Unpayed')) Deleted = choices.Choice(100, _('Deleted'))
class ContractStatesLabelEnum(choices.Choices): Open = choices.Choice(10, 'danger') Payed = choices.Choice(20, 'default') Invoice_created = choices.Choice(30, 'warning') Invoice_sent = choices.Choice(40, 'warning') Quote_created = choices.Choice(50, 'primary') Quote_sent = choices.Choice(60, 'primary') PurchaseOrder_created = choices.Choice(70, 'success') Customer_cant_pay = choices.Choice(90, 'info') Deleted = choices.Choice(100, 'default')
class PostalAddressPurpose(choices.Choices): DeliveryAddress = choices.Choice('D', _('Delivery Address')) BillingAddress = choices.Choice('B', _('Billing Address')) ContactAddress = choices.Choice('C', _('Contact Address'))
class EmailAddressPurpose(choices.Choices): Private = choices.Choice('H', _('Private')) Business = choices.Choice('O', _('Business'))
class PhoneAddressPurpose(choices.Choices): Private = choices.Choice('H', _('Private')) Business = choices.Choice('O', _('Business')) MobilePrivate = choices.Choice('P', _('Mobile Private')) MobileBusiness = choices.Choice('B', _('Mobile Business'))
def test_choice_deconstruct(): choices.Choice().deconstruct() choices.Choice(value=123).deconstruct() choices.Choice(value=123, label='123').deconstruct()
class Gender(choices.Choices): Male = choices.Choice('m', _('Male')) Female = choices.Choice('f', _('Female')) Other = choices.Choice('o', _('Other'))
class Enum(choices.Choices): Foo = choices.Choice() Bar = choices.Choice() Spam = choices.Choice() Eggs = choices.Choice()
class Gender(choices.Choices): Male = choices.Choice('m') Female = choices.Choice('f') Other = choices.Choice('o')
class PostalAddressPrefix(choices.Choices): Company = choices.Choice('F', _('Company')) Mister = choices.Choice('H', _('Mr')) Misses = choices.Choice('W', _('Mrs')) Miss = choices.Choice('G', _('Ms'))