from shortcuts import Shortcut, FMT_SHORTCUT, actions


class TestMenuLoads:
    def test_loads_from_plist(self):
        plist = '<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>WFWorkflowActions</key> <array> <dict> <key>WFWorkflowActionIdentifier</key> <string>is.workflow.actions.choosefrommenu</string> <key>WFWorkflowActionParameters</key> <dict> <key>GroupingIdentifier</key> <string>76C3AEC3-29EF-4FC8-9744-1CF34D07CA54</string> <key>WFControlFlowMode</key> <integer>0</integer> <key>WFMenuItems</key> <array> <string>F</string> <string>S</string> <string>T</string> </array> </dict> </dict> <dict> <key>WFWorkflowActionIdentifier</key> <string>is.workflow.actions.choosefrommenu</string> <key>WFWorkflowActionParameters</key> <dict> <key>GroupingIdentifier</key> <string>76C3AEC3-29EF-4FC8-9744-1CF34D07CA54</string> <key>WFControlFlowMode</key> <integer>1</integer> <key>WFMenuItemTitle</key> <string>F</string> </dict> </dict> <dict> <key>WFWorkflowActionIdentifier</key> <string>is.workflow.actions.choosefrommenu</string> <key>WFWorkflowActionParameters</key> <dict> <key>GroupingIdentifier</key> <string>76C3AEC3-29EF-4FC8-9744-1CF34D07CA54</string> <key>WFControlFlowMode</key> <integer>1</integer> <key>WFMenuItemTitle</key> <string>S</string> </dict> </dict> <dict> <key>WFWorkflowActionIdentifier</key> <string>is.workflow.actions.choosefrommenu</string> <key>WFWorkflowActionParameters</key> <dict> <key>GroupingIdentifier</key> <string>76C3AEC3-29EF-4FC8-9744-1CF34D07CA54</string> <key>WFControlFlowMode</key> <integer>1</integer> <key>WFMenuItemTitle</key> <string>T</string> </dict> </dict> <dict> <key>WFWorkflowActionIdentifier</key> <string>is.workflow.actions.choosefrommenu</string> <key>WFWorkflowActionParameters</key> <dict> <key>GroupingIdentifier</key> <string>76C3AEC3-29EF-4FC8-9744-1CF34D07CA54</string> <key>WFControlFlowMode</key> <integer>2</integer> </dict> </dict> </array> <key>WFWorkflowClientRelease</key> <string>2.0</string> <key>WFWorkflowClientVersion</key> <string>700</string> <key>WFWorkflowIcon</key> <dict> <key>WFWorkflowIconGlyphNumber</key> <integer>59511</integer> <key>WFWorkflowIconImageData</key> <data> </data> <key>WFWorkflowIconStartColor</key> <integer>3679049983</integer> </dict> <key>WFWorkflowImportQuestions</key> <array/> <key>WFWorkflowInputContentItemClasses</key> <array> <string>WFAppStoreAppContentItem</string> <string>WFArticleContentItem</string> <string>WFContactContentItem</string> <string>WFDateContentItem</string> <string>WFEmailAddressContentItem</string> <string>WFGenericFileContentItem</string> <string>WFImageContentItem</string> <string>WFiTunesProductContentItem</string> <string>WFLocationContentItem</string> <string>WFDCMapsLinkContentItem</string> <string>WFAVAssetContentItem</string> <string>WFPDFContentItem</string> <string>WFPhoneNumberContentItem</string> <string>WFRichTextContentItem</string> <string>WFSafariWebPageContentItem</string> <string>WFStringContentItem</string> <string>WFURLContentItem</string> </array> <key>WFWorkflowTypes</key> <array> <string>NCWidget</string> <string>WatchKit</string> </array> </dict> </plist>'

        sc = Shortcut.loads(plist, file_format=FMT_SHORTCUT)

        assert isinstance(sc.actions[0], actions.MenuStartAction) is True
        assert isinstance(sc.actions[1], actions.MenuItemAction) is True
        assert isinstance(sc.actions[2], actions.MenuItemAction) is True
        assert isinstance(sc.actions[3], actions.MenuItemAction) is True
        assert isinstance(sc.actions[4], actions.MenuEndAction) is True
