当前位置: 首页>>代码示例>>Python>>正文


Python Workflow.send_feedback方法代码示例

本文整理汇总了Python中workflow.workflow.Workflow.send_feedback方法的典型用法代码示例。如果您正苦于以下问题:Python Workflow.send_feedback方法的具体用法?Python Workflow.send_feedback怎么用?Python Workflow.send_feedback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在workflow.workflow.Workflow的用法示例。


在下文中一共展示了Workflow.send_feedback方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: WorkflowTests

# 需要导入模块: from workflow.workflow import Workflow [as 别名]
# 或者: from workflow.workflow.Workflow import send_feedback [as 别名]
class WorkflowTests(unittest.TestCase):

    def setUp(self):
        self.libs = [os.path.join(os.path.dirname(__file__), 'lib')]
        self.wf = Workflow(libraries=self.libs)
        self.account = 'this-is-my-test-account'
        self.password = 'this-is-my-safe-password'
        self.password2 = 'this-is-my-other-safe-password'
        self.search_items = [
            ('Test Item One', MATCH_STARTSWITH),
            ('test item two', MATCH_STARTSWITH),
            ('TwoExtraSpecialTests', MATCH_CAPITALS),
            ('this-is-a-test', MATCH_ATOM),
            ('the extra special trials', MATCH_INITIALS_STARTSWITH),
            ('not the extra special trials', MATCH_INITIALS_CONTAIN),
            ('intestinal fortitude', MATCH_SUBSTRING),
            ('the splits', MATCH_ALLCHARS),
            ('nomatch', 0),
        ]

    def tearDown(self):
        self.wf.clear_cache()
        self.wf.clear_settings()
        try:
            self.wf.delete_password(self.account)
        except PasswordNotFound:
            pass
        for dirpath in (self.wf.cachedir, self.wf.datadir):
            if os.path.exists(dirpath):
                shutil.rmtree(dirpath)

    def test_item_creation(self):
        """XML generation"""
        self.wf.add_item('title', 'subtitle', 'arg',
                         autocomplete='autocomplete',
                         valid=True, uid='uid', icon='icon.png',
                         icontype='fileicon',
                         type='file')
        stdout = sys.stdout
        sio = StringIO()
        sys.stdout = sio
        self.wf.send_feedback()
        sys.stdout = stdout
        output = sio.getvalue()
        sio.close()
        # pprint(output)
        root = ET.fromstring(output)
        item = list(root)[0]
        self.assertEqual(item.attrib['uid'], 'uid')
        self.assertEqual(item.attrib['autocomplete'], 'autocomplete')
        self.assertEqual(item.attrib['valid'], 'yes')
        self.assertEqual(item.attrib['uid'], 'uid')
        title, subtitle, arg, icon = list(item)
        self.assertEqual(title.text, 'title')
        self.assertEqual(title.tag, 'title')
        self.assertEqual(subtitle.text, 'subtitle')
        self.assertEqual(subtitle.tag, 'subtitle')
        self.assertEqual(arg.text, 'arg')
        self.assertEqual(arg.tag, 'arg')
        self.assertEqual(icon.text, 'icon.png')
        self.assertEqual(icon.tag, 'icon')
        self.assertEqual(icon.attrib['type'], 'fileicon')

    def test_item_creation_no_optionals(self):
        """XML generation (no optionals)"""
        self.wf.add_item('title',
                         valid=False)
        stdout = sys.stdout
        sio = StringIO()
        sys.stdout = sio
        self.wf.send_feedback()
        sys.stdout = stdout
        output = sio.getvalue()
        sio.close()
        # pprint(output)
        root = ET.fromstring(output)
        item = list(root)[0]
        for key in ['uid', 'arg', 'autocomplete']:
            self.assertFalse(key in item.attrib)
        self.assertEqual(item.attrib['valid'], 'no')
        title, subtitle = list(item)
        self.assertEqual(title.text, 'title')
        self.assertEqual(title.tag, 'title')
        self.assertEqual(subtitle.text, None)
        tags = [elem.tag for elem in list(item)]
        for tag in ['icon', 'arg']:
            self.assert_(tag not in tags)

    def test_additional_libs(self):
        """Additional libraries"""
        for path in self.libs:
            self.assert_(path in sys.path)
        self.assertEqual(sys.path[0:len(self.libs)], self.libs)
        import youcanimportme

    def test_info_plist(self):
        """info.plist"""
        self.assertEqual(self.wf.name, WORKFLOW_NAME)
        self.assertEqual(self.wf.bundleid, BUNDLE_ID)

#.........这里部分代码省略.........
开发者ID:hellohano,项目名称:alfred-workflow,代码行数:103,代码来源:test_workflow.py

示例2: WorkflowTests

# 需要导入模块: from workflow.workflow import Workflow [as 别名]
# 或者: from workflow.workflow.Workflow import send_feedback [as 别名]
class WorkflowTests(unittest.TestCase):
    def setUp(self):
        self.libs = [os.path.join(os.path.dirname(__file__), "lib")]
        self.wf = Workflow(libraries=self.libs)
        self.account = "this-is-my-test-account"
        self.password = "this-is-my-safe-password"
        self.password2 = "this-is-my-other-safe-password"
        self.search_items = [
            ("Test Item One", MATCH_STARTSWITH),
            ("test item two", MATCH_STARTSWITH),
            ("TwoExtraSpecialTests", MATCH_CAPITALS),
            ("this-is-a-test", MATCH_ATOM),
            ("the extra special trials", MATCH_INITIALS_STARTSWITH),
            ("not the extra special trials", MATCH_INITIALS_CONTAIN),
            ("intestinal fortitude", MATCH_SUBSTRING),
            ("the splits", MATCH_ALLCHARS),
            ("nomatch", 0),
        ]

        self.search_items_diacritics = [
            # search key, query
            ("Änderungen vorbehalten", "av"),
            ("Änderungen", "anderungen"),
            ("überwiegend bewolkt", "ub"),
            ("überwiegend", "uberwiegend"),
            ("Öffnungszeiten an Feiertagen", "offnungszeiten"),
            ("Öffnungszeiten an Feiertagen", "oaf"),
            ("Fußpilz", "fuss"),
            ("salé", "sale"),
        ]

    def tearDown(self):
        self.wf.clear_cache()
        self.wf.clear_settings()
        try:
            self.wf.delete_password(self.account)
        except PasswordNotFound:
            pass
        for dirpath in (self.wf.cachedir, self.wf.datadir):
            if os.path.exists(dirpath):
                shutil.rmtree(dirpath)

    def test_item_creation(self):
        """XML generation"""
        self.wf.add_item(
            "title",
            "subtitle",
            "arg",
            autocomplete="autocomplete",
            valid=True,
            uid="uid",
            icon="icon.png",
            icontype="fileicon",
            type="file",
        )
        stdout = sys.stdout
        sio = StringIO()
        sys.stdout = sio
        self.wf.send_feedback()
        sys.stdout = stdout
        output = sio.getvalue()
        sio.close()
        # pprint(output)
        root = ET.fromstring(output)
        item = list(root)[0]
        self.assertEqual(item.attrib["uid"], "uid")
        self.assertEqual(item.attrib["autocomplete"], "autocomplete")
        self.assertEqual(item.attrib["valid"], "yes")
        self.assertEqual(item.attrib["uid"], "uid")
        title, subtitle, arg, icon = list(item)
        self.assertEqual(title.text, "title")
        self.assertEqual(title.tag, "title")
        self.assertEqual(subtitle.text, "subtitle")
        self.assertEqual(subtitle.tag, "subtitle")
        self.assertEqual(arg.text, "arg")
        self.assertEqual(arg.tag, "arg")
        self.assertEqual(icon.text, "icon.png")
        self.assertEqual(icon.tag, "icon")
        self.assertEqual(icon.attrib["type"], "fileicon")

    def test_item_creation_no_optionals(self):
        """XML generation (no optionals)"""
        self.wf.add_item("title", valid=False)
        stdout = sys.stdout
        sio = StringIO()
        sys.stdout = sio
        self.wf.send_feedback()
        sys.stdout = stdout
        output = sio.getvalue()
        sio.close()
        # pprint(output)
        root = ET.fromstring(output)
        item = list(root)[0]
        for key in ["uid", "arg", "autocomplete"]:
            self.assertFalse(key in item.attrib)
        self.assertEqual(item.attrib["valid"], "no")
        title, subtitle = list(item)
        self.assertEqual(title.text, "title")
        self.assertEqual(title.tag, "title")
        self.assertEqual(subtitle.text, None)
#.........这里部分代码省略.........
开发者ID:JT5D,项目名称:Alfred-Popclip-Sublime,代码行数:103,代码来源:test_workflow.py

示例3: WorkflowTests

# 需要导入模块: from workflow.workflow import Workflow [as 别名]
# 或者: from workflow.workflow.Workflow import send_feedback [as 别名]
class WorkflowTests(unittest.TestCase):

    def setUp(self):
        self.libs = [os.path.join(os.path.dirname(__file__), 'lib')]
        self.wf = Workflow(libraries=self.libs)
        self.account = 'this-is-my-test-account'
        self.password = 'this-is-my-safe-password'
        self.password2 = 'this-is-my-other-safe-password'
        self.search_items = [
            ('Test Item One', MATCH_STARTSWITH),
            ('test item two', MATCH_STARTSWITH),
            ('TwoExtraSpecialTests', MATCH_CAPITALS),
            ('this-is-a-test', MATCH_ATOM),
            ('the extra special trials', MATCH_INITIALS_STARTSWITH),
            ('not the extra special trials', MATCH_INITIALS_CONTAIN),
            ('intestinal fortitude', MATCH_SUBSTRING),
            ('the splits', MATCH_ALLCHARS),
            ('nomatch', 0),
        ]

        self.search_items_diacritics = [
            # search key, query
            ('Änderungen vorbehalten', 'av'),
            ('Änderungen', 'anderungen'),
            ('überwiegend bewolkt', 'ub'),
            ('überwiegend', 'uberwiegend'),
            ('Öffnungszeiten an Feiertagen', 'offnungszeiten'),
            ('Öffnungszeiten an Feiertagen', 'oaf'),
            ('Fußpilz', 'fuss'),
            ('salé', 'sale')
        ]

        self.env_data = {
            'alfred_preferences':
            os.path.expanduser('~/Dropbox/Alfred/Alfred.alfredpreferences'),
            'alfred_preferences_localhash':
            b'adbd4f66bc3ae8493832af61a41ee609b20d8705',
            'alfred_theme': b'alfred.theme.yosemite',
            'alfred_theme_background': b'rgba(255,255,255,0.98)',
            'alfred_theme_subtext': b'3',
            'alfred_version': b'2.4',
            'alfred_version_build': b'277',
            'alfred_workflow_bundleid': b'com.alfredapp.david.googlesuggest',
            'alfred_workflow_cache':
            os.path.expanduser('~/Library/Caches/com.runningwithcrayons.'
                               'Alfred-2/Workflow Data/com.alfredapp.david'
                               '.googlesuggest'),
            'alfred_workflow_data':
            os.path.expanduser('~/Library/Application Support/Alfred 2/'
                               'Workflow Data/com.alfredapp.david.'
                               'googlesuggest'),
            'alfred_workflow_name': b'Google Suggest',
            'alfred_workflow_uid':
            b'user.workflow.B0AC54EC-601C-479A-9428-01F9FD732959',
        }

    def tearDown(self):
        self.wf.reset()
        try:
            self.wf.delete_password(self.account)
        except PasswordNotFound:
            pass

        for dirpath in (self.wf.cachedir, self.wf.datadir):
            if os.path.exists(dirpath):
                shutil.rmtree(dirpath)

        for key in self.env_data:
            if key in os.environ:
                del os.environ[key]

    def test_item_creation(self):
        """XML generation"""
        self.wf.add_item('title', 'subtitle', arg='arg',
                         autocomplete='autocomplete',
                         valid=True, uid='uid', icon='icon.png',
                         icontype='fileicon',
                         type='file', largetext='largetext',
                         copytext='copytext')
        stdout = sys.stdout
        sio = StringIO()
        sys.stdout = sio
        self.wf.send_feedback()
        sys.stdout = stdout
        output = sio.getvalue()
        sio.close()
        from pprint import pprint
        pprint(output)

        root = ET.fromstring(output)
        item = list(root)[0]

        self.assertEqual(item.attrib['uid'], 'uid')
        self.assertEqual(item.attrib['autocomplete'], 'autocomplete')
        self.assertEqual(item.attrib['valid'], 'yes')
        self.assertEqual(item.attrib['uid'], 'uid')

        title, subtitle, arg, icon, largetext, copytext = list(item)

        self.assertEqual(title.text, 'title')
#.........这里部分代码省略.........
开发者ID:bunnyswe,项目名称:alfred-workflow,代码行数:103,代码来源:test_workflow.py


注:本文中的workflow.workflow.Workflow.send_feedback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。