def test_choice_field(self): choices = ('first', 'second') f = ChoiceField('test', choices=choices) assert f.process_value('first') == 'first' assert f.process_value('second') == 'second' with pytest.raises(ValueError): assert f.process_value('third')
class GetIPAddressAction(BaseAction): '''Get current IP address''' itype = 'is.workflow.actions.getipaddress' keyword = 'get_ip_address' source = ChoiceField('WFIPAddressSourceOption', choices=('Local', 'Global')) address_type = ChoiceField('WFIPAddressTypeOption', choices=('IPv4', 'IPv6'))
class ChangeCaseAction(BaseAction): '''Change case''' itype = 'is.workflow.actions.text.changecase' keyword = 'change_case' case_type = ChoiceField('WFCaseType', choices=CASE_CHOICES)
class HashAction(BaseAction): '''Hash action''' itype = 'is.workflow.actions.hash' keyword = 'hash' hash_type = ChoiceField('WFHashType', choices=HASH_CHOICES, default=HASH_CHOICES[0])
class SetTorchAction(BaseAction): '''Set Torch''' itype = 'is.workflow.actions.flashlight' keyword = 'set_torch' mode = ChoiceField('WFFlashlightSetting', choices=('Off', 'On', 'Toggle'))
class GetDeviceDetailsAction(BaseAction): '''Get device details''' itype = 'is.workflow.actions.getdevicedetails' keyword = 'get_device_details' detail = ChoiceField('WFDeviceDetail', choices=DEVICE_DETAIL_CHOICES)
class GetTimeBetweenDates(BaseAction): '''Get time difference between dates''' itype = 'is.workflow.actions.gettimebetweendates' keyword = 'get_time_between_dates' units = ChoiceField('WFTimeUntilUnit', choices=DATE_DIFF_UNITS_CHOICES, default=DATE_DIFF_UNITS_CHOICES[0]) custom_date = Field('WFTimeUntilCustomDate', required=False)
class SpeakTextAction(BaseAction): '''Speak text''' itype = 'is.workflow.actions.speaktext' keyword = 'speak_text' language = ChoiceField('WFSpeakTextLanguage', choices=SPEAK_LANGUAGE_CHOICES) pitch = FloatField('WFSpeakTextPitch', default=0.95) rate = FloatField('WFSpeakTextRate', default=0.44) wait_until_finished = BooleanField('WFSpeakTextWait', default=True)
class IfAction(BaseAction): '''If''' itype = 'is.workflow.actions.conditional' keyword = 'if' condition = ChoiceField('WFCondition', choices=IF_CHOICES, capitalize=True) compare_with = Field('WFConditionalActionString') group_id = GroupIDField('GroupingIdentifier') default_fields = { 'WFControlFlowMode': 0, }
class SplitTextAction(BaseAction): '''Split text''' itype = 'is.workflow.actions.text.split' keyword = 'split_text' separator_type = ChoiceField( 'WFTextSeparator', choices=SPLIT_SEPARATOR_CHOICES, default=SPLIT_SEPARATOR_CHOICES[0], ) custom_separator = Field( 'WFTextCustomSeparator', help='Works only with "Custom" `separator_type`', required=False, )
def test_choice_field_with_capitalization(self): choices = ('First', ) f = ChoiceField('test', choices=choices, capitalize=True) assert f.process_value('first') == 'First'