示例#1
0
    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')
示例#2
0
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'))
示例#3
0
class ChangeCaseAction(BaseAction):
    '''Change case'''

    itype = 'is.workflow.actions.text.changecase'
    keyword = 'change_case'

    case_type = ChoiceField('WFCaseType', choices=CASE_CHOICES)
示例#4
0
class HashAction(BaseAction):
    '''Hash action'''

    itype = 'is.workflow.actions.hash'
    keyword = 'hash'

    hash_type = ChoiceField('WFHashType', choices=HASH_CHOICES, default=HASH_CHOICES[0])
示例#5
0
class SetTorchAction(BaseAction):
    '''Set Torch'''

    itype = 'is.workflow.actions.flashlight'
    keyword = 'set_torch'

    mode = ChoiceField('WFFlashlightSetting', choices=('Off', 'On', 'Toggle'))
示例#6
0
class GetDeviceDetailsAction(BaseAction):
    '''Get device details'''

    itype = 'is.workflow.actions.getdevicedetails'
    keyword = 'get_device_details'

    detail = ChoiceField('WFDeviceDetail', choices=DEVICE_DETAIL_CHOICES)
示例#7
0
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)
示例#8
0
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)
示例#9
0
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,
    }
示例#10
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,
    )
示例#11
0
    def test_choice_field_with_capitalization(self):
        choices = ('First', )
        f = ChoiceField('test', choices=choices, capitalize=True)

        assert f.process_value('first') == 'First'