コード例 #1
0
    def testLongTitle(self):
        self._loadAccounts(2)
        e = Action()
        e.tw_account = 'first-valid-account'
        executor = getMultiAdapter((self.folder, e, DummyEvent(self.folder.longtitle)),
                                   IExecutable)

        self.assertEquals(True, executor())
        self.assertTrue(len(persistentTwitter.getMessage()) < 140)

        status_msg = IStatusMessage(self.request).showStatusMessages()[0].message
        self.assertTrue(u'Tweet sent: ' in status_msg)
コード例 #2
0
    def testDifferentHost(self):
        self._loadAccounts(2)
        e = Action()
        e.tw_account = 'first-valid-account'
        e.different_host = 'http://www.google.com'

        executor = getMultiAdapter((self.folder, e, DummyEvent(self.folder.doc1)),
                                   IExecutable)

        self.assertEquals(True, executor())

        status_msg = IStatusMessage(self.request).showStatusMessages()[0].message
        self.assertTrue(u'Tweet sent: Doc 1\n' in status_msg)
コード例 #3
0
    def testURLError(self):
        self._loadAccounts(2)
        e = Action()
        e.tw_account = 'first-valid-account'
        executor = getMultiAdapter((self.folder, e, DummyEvent(self.folder.urlerror)),
                                   IExecutable)

        self.assertEquals(True, executor())

        status_msg = IStatusMessage(self.request).showStatusMessages()[0].message
        self.assertEquals(status_msg,
                          (u'There was an error while sending the tweet: '
                            '<urlopen error URL Error>'))
コード例 #4
0
    def testLongTitle(self):
        self._loadAccounts(2)
        e = Action()
        e.tw_account = 'first-valid-account'
        executor = getMultiAdapter(
            (self.folder, e, DummyEvent(self.folder.longtitle)), IExecutable)

        self.assertEquals(True, executor())
        self.assertTrue(len(persistentTwitter.getMessage()) < 140)

        status_msg = IStatusMessage(
            self.request).showStatusMessages()[0].message
        self.assertTrue(u'Tweet sent: ' in status_msg)
コード例 #5
0
    def testDifferentHost(self):
        self._loadAccounts(2)
        e = Action()
        e.tw_account = 'first-valid-account'
        e.different_host = 'http://www.google.com'

        executor = getMultiAdapter(
            (self.folder, e, DummyEvent(self.folder.doc1)), IExecutable)

        self.assertEquals(True, executor())

        status_msg = IStatusMessage(
            self.request).showStatusMessages()[0].message
        self.assertTrue(u'Tweet sent: Doc 1\n' in status_msg)
コード例 #6
0
    def testURLError(self):
        self._loadAccounts(2)
        e = Action()
        e.tw_account = 'first-valid-account'
        executor = getMultiAdapter(
            (self.folder, e, DummyEvent(self.folder.urlerror)), IExecutable)

        self.assertEquals(True, executor())

        status_msg = IStatusMessage(
            self.request).showStatusMessages()[0].message
        self.assertEquals(status_msg,
                          (u'There was an error while sending the tweet: '
                           '<urlopen error URL Error>'))
コード例 #7
0
    def testFirstValidAccount(self):
        self._loadAccounts(2)
        e = Action()
        e.tw_account = 'first-valid-account'
        executor = getMultiAdapter(
            (self.folder, e, DummyEvent(self.folder.doc1)), IExecutable)

        self.assertEquals(True, executor())
        self.assertEquals(persistentTwitter.getCredentials(),
                          ('consumer_key1', 'consumer_secret1',
                           'access_token_key1', 'access_token_secret1'))

        self.assertTrue('Doc 1\n' in persistentTwitter.getMessage())

        status_msg = IStatusMessage(
            self.request).showStatusMessages()[0].message
        self.assertTrue(u'Tweet sent: Doc 1\n' in status_msg)
コード例 #8
0
    def testInvalidAccount(self):
        e = Action()
        e.tw_account = 'account'
        executor = getMultiAdapter((self.folder, e, DummyEvent(self.folder.error)),
                                   IExecutable)

        self.assertEquals(True, executor())

        self.assertEquals(persistentTwitter.getCredentials(),
                          ('', '', '', ''))

        self.assertTrue('' in persistentTwitter.getMessage())

        status_msg = IStatusMessage(self.request).showStatusMessages()[0].message
        self.assertEquals(status_msg,
                          (u"Could not publish to twitter, seems the account "
                            "account was removed from the list of authorized "
                            "accounts for this site."))
コード例 #9
0
    def testFirstValidAccount(self):
        self._loadAccounts(2)
        e = Action()
        e.tw_account = 'first-valid-account'
        executor = getMultiAdapter((self.folder, e, DummyEvent(self.folder.doc1)),
                                   IExecutable)

        self.assertEquals(True, executor())
        self.assertEquals(persistentTwitter.getCredentials(),
                          ('consumer_key1', 
                           'consumer_secret1', 
                           'access_token_key1', 
                           'access_token_secret1'))

        self.assertTrue('Doc 1\n' in persistentTwitter.getMessage())

        status_msg = IStatusMessage(self.request).showStatusMessages()[0].message
        self.assertTrue(u'Tweet sent: Doc 1\n' in status_msg)
コード例 #10
0
    def testInvalidAccount(self):
        e = Action()
        e.tw_account = 'account'
        executor = getMultiAdapter(
            (self.folder, e, DummyEvent(self.folder.error)), IExecutable)

        self.assertEquals(True, executor())

        self.assertEquals(persistentTwitter.getCredentials(), ('', '', '', ''))

        self.assertTrue('' in persistentTwitter.getMessage())

        status_msg = IStatusMessage(
            self.request).showStatusMessages()[0].message
        self.assertEquals(status_msg,
                          (u"Could not publish to twitter, seems the account "
                           "account was removed from the list of authorized "
                           "accounts for this site."))
コード例 #11
0
 def testExecute(self):
     e = Action()
     e.tw_account = 'first-valid-account'
     executor = getMultiAdapter((self.folder, e, DummyEvent(self.folder.doc1)),
                          IExecutable)
     self.assertEquals(True, executor())
コード例 #12
0
 def testExecute(self):
     e = Action()
     e.tw_account = 'first-valid-account'
     executor = getMultiAdapter(
         (self.folder, e, DummyEvent(self.folder.doc1)), IExecutable)
     self.assertEquals(True, executor())
コード例 #13
0
 def testInvokeEditView(self):
     element = getUtility(IRuleAction,
                          name='collective.twitter.tweet.TweetContent')
     e = Action()
     editview = getMultiAdapter((e, self.request), name=element.editview)
     self.failUnless(isinstance(editview, ActionEditForm))