Skip to content
This repository was archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
-Added Choose From List scripting action and associated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Logsdon committed Nov 7, 2018
1 parent f0265b0 commit b99d5ef
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions shortcuts/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
SetItemNameAction,
ViewContentGraphAction,
WaitToReturnAction,
ChooseFromListAction,
)
from shortcuts.actions.text import (
ChangeCaseAction,
Expand Down
10 changes: 9 additions & 1 deletion shortcuts/actions/scripting.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from shortcuts.actions.base import BaseAction, BooleanField, ChoiceField, Field, FloatField, GroupIDField, IntegerField


class NothingAction(BaseAction):
'''Nothing'''
itype = 'is.workflow.actions.nothing'
Expand Down Expand Up @@ -38,6 +37,15 @@ class ContinueInShortcutAppAction(BaseAction):
keyword = 'continue_in_shortcut_app'


class ChooseFromListAction(BaseAction):
'''Choose from list'''
itype = 'is.workflow.actions.choosefromlist'
keyword = 'choose_from_list'
prompt = Field('WFChooseFromListActionPrompt', required=False)
select_multiple = BooleanField('WFChooseFromListActionSelectMultiple', required=False)
select_all_initially = BooleanField('WFChooseFromListActionSelectAll', required=False)


class DelayAction(BaseAction):
'''Delay'''
itype = 'is.workflow.actions.delay'
Expand Down
30 changes: 30 additions & 0 deletions tests/actions/scripting/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
HashAction,
GetMyShortcutsAction,
RunShortcutAction,
ChooseFromListAction
)
from shortcuts.actions.scripting import HASH_CHOICES
from shortcuts import Shortcut, FMT_SHORTCUT
Expand Down Expand Up @@ -202,6 +203,35 @@ class TestGetMyShortcutsAction(SimpleBaseDumpsLoadsTest):
'''


class TestChooseFromListAction(SimpleBaseDumpsLoadsTest):
action_class = ChooseFromListAction
itype = 'is.workflow.actions.choosefromlist'
dump_data = {'select_multiple': False, 'select_all_initially': False}
dump_params = {'WFChooseFromListActionSelectMultiple': False, 'WFChooseFromListActionSelectAll': False}
toml = '''
[[action]]
type = "choose_from_list"
prompt = "test"
'''
exp_toml_params = {'prompt': 'test'}
action_xml = '''
<dict>
<key>WFWorkflowActionIdentifier</key>
<string>is.workflow.actions.choosefromlist</string>
<key>WFWorkflowActionParameters</key>
<dict>
<key>WFChooseFromListActionPrompt</key>
<string>test</string>
<key>WFChooseFromListActionSelectAll</key>
<true/>
<key>WFChooseFromListActionSelectMultiple</key>
<true/>
</dict>
</dict>
'''
exp_xml_params = {'select_all_initially': True, 'select_multiple': True, 'prompt': 'test'}


class TestRunShortcut(SimpleBaseDumpsLoadsTest):
action_class = RunShortcutAction
itype = 'is.workflow.actions.runworkflow'
Expand Down

0 comments on commit b99d5ef

Please sign in to comment.