當前位置: 首頁>>代碼示例>>Python>>正文


Python Workflow.start_update方法代碼示例

本文整理匯總了Python中workflow.workflow.Workflow.start_update方法的典型用法代碼示例。如果您正苦於以下問題:Python Workflow.start_update方法的具體用法?Python Workflow.start_update怎麽用?Python Workflow.start_update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在workflow.workflow.Workflow的用法示例。


在下文中一共展示了Workflow.start_update方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_update

# 需要導入模塊: from workflow.workflow import Workflow [as 別名]
# 或者: from workflow.workflow.Workflow import start_update [as 別名]
    def test_update(self):
        """Workflow update methods"""

        # Initialise with outdated version
        wf = Workflow(update_settings={
            'github_slug': 'deanishe/alfred-workflow-dummy',
            'version': 'v2.0',
            'frequency': 1,
        })

        # Check won't have completed yet
        self.assertFalse(wf.update_available)

        # wait for background update check
        self.assertTrue(is_running('__workflow_update_check'))
        while is_running('__workflow_update_check'):
            time.sleep(0.05)

        # There *is* a newer version in the repo
        self.assertTrue(wf.update_available)

        # Mock out subprocess and check the correct command is run
        c = WorkflowMock()
        with c:
            self.assertTrue(wf.start_update())
        # wf.logger.debug('start_update : {}'.format(c.cmd))
        self.assertEquals(c.cmd[0], '/usr/bin/python')
        self.assertEquals(c.cmd[2], '__workflow_update_install')

        # Grab the updated release data, then reset the cache
        update_info = wf.cached_data('__workflow_update_status')

        wf.reset()

        # Initialise with latest available release
        wf = Workflow(update_settings={
            'github_slug': 'deanishe/alfred-workflow-dummy',
            'version': update_info['version'],
        })

        # Wait for background update check
        self.assertTrue(is_running('__workflow_update_check'))
        while is_running('__workflow_update_check'):
            time.sleep(0.05)

        # Remove version is same as the one we passed to Workflow
        self.assertFalse(wf.update_available)
        self.assertFalse(wf.start_update())
開發者ID:lemanouche0221,項目名稱:alfred-workflow,代碼行數:50,代碼來源:test_workflow.py

示例2: WorkflowTests

# 需要導入模塊: from workflow.workflow import Workflow [as 別名]
# 或者: from workflow.workflow.Workflow import start_update [as 別名]

#.........這裏部分代碼省略.........

    def test_invalid_data_serializer(self):
        """Invalid data serializer"""
        data = {'key7': 'value7'}

        with self.assertRaises(ValueError):
            self.wf.store_data('test', data, 'spong')

    def test_delete_stored_data(self):
        """Delete stored data"""
        data = {'key7': 'value7'}

        paths = self._stored_data_paths('test', 'cpickle')

        self.wf.store_data('test', data)
        self.assertEqual(data, self.wf.stored_data('test'))
        self.wf.store_data('test', None)
        self.assertEqual(None, self.wf.stored_data('test'))

        for p in paths:
            self.assertFalse(os.path.exists(p))

    def test_update(self):
        """Workflow updating methods"""
        self.assertFalse(self.wf.update_available)
        self.wf = Workflow(update_info={
            'github_slug': 'fniephaus/alfred-pocket',
            'version': 'v0.0',
            'frequency': 1,
        })
        # wait for background update check
        time.sleep(2)
        self.assertTrue(self.wf.update_available)
        self.assertTrue(self.wf.start_update())
        update_info = self.wf.cached_data('__workflow_update_available')
        self.wf = Workflow(update_info={
            'github_slug': 'fniephaus/alfred-pocket',
            'version': update_info['version'],
        })
        # wait for background update check
        time.sleep(2)
        self.assertFalse(self.wf.update_available)
        self.assertFalse(self.wf.start_update())

    def test_keychain(self):
        """Save/get/delete password"""
        self.assertRaises(PasswordNotFound,
                          self.wf.delete_password, self.account)
        self.assertRaises(PasswordNotFound, self.wf.get_password, self.account)
        self.wf.save_password(self.account, self.password)
        self.assertEqual(self.wf.get_password(self.account), self.password)
        self.assertEqual(self.wf.get_password(self.account, BUNDLE_ID),
                         self.password)
        # try to set same password
        self.wf.save_password(self.account, self.password)
        self.assertEqual(self.wf.get_password(self.account), self.password)
        # try to set different password
        self.wf.save_password(self.account, self.password2)
        self.assertEqual(self.wf.get_password(self.account), self.password2)
        # bad call to _call_security
        with self.assertRaises(KeychainError):
            self.wf._call_security('pants', BUNDLE_ID, self.account)

    def test_run_fails(self):
        """Run fails"""
        def cb(wf):
開發者ID:smargh,項目名稱:alfred-workflow,代碼行數:70,代碼來源:test_workflow.py


注:本文中的workflow.workflow.Workflow.start_update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。