示例#1
0
 def test_updateAccount_withExistentDefaultGroup(self):
     a = Account(username='******')
     a.last_updated = datetime.now()
     cacheApiMock = p.Mock()
     cacheApiMock.expects(p.once()).method('itemExists') \
         .will(p.return_value(True))
     twitter_agent.updateAccount(a, cacheApiMock)
     cacheApiMock.verify()
示例#2
0
 def test_updateAccount(self):
     a = Account(username='******', last_updated=None)
     cacheApiMock = p.Mock()
     cacheApiMock.expects(p.once()).addGroup(p.eq(None), \
                                                 name=p.eq('Twitter'), is_null_group=p.eq(True))
     cacheApiMock.expects(p.once()).method('itemExists') \
         .will(p.return_value(True))
     twitter_agent.updateAccount(a, cacheApiMock)
     cacheApiMock.verify()
示例#3
0
    def test_updateAccount_NewAccount(self):
        self.expectations = [('http://del.icio.us/conito?setcount=100&page=1',
                              'conitoX10'),
                             ('http://del.icio.us/conito?setcount=100&page=2',
                              'conitoX10-page2')]

        cacheApi = mock.Mock()
        cacheApi.expects(mock.once()).addGroup(mock.eq(None),
                                               name=mock.eq('Delicious'),
                                               is_null_group=mock.eq(True))
        cacheApi.expects(mock.exactly(20)).method('addItem')
        cacheApi.expects(mock.exactly(20)).method('bindItem2Group')

        groups = dl.updateAccount(self.account, cacheApi)
        cacheApi.verify()
示例#4
0
    def test_updateAccount_OldAccount(self):
        self.expectations = [
            ('http://del.icio.us/conito?setcount=100&page=1', 'conitoX10'),
        ]

        cacheApi = mock.Mock()
        cacheApi.expects(mock.once()).groupItems(mock.eq(None)).will(
            mock.return_value(['d2b95de9147b861039f85db169e28322']))
        cacheApi.expects(mock.exactly(6)).method('addItem')
        cacheApi.expects(mock.exactly(6)).method('bindItem2Group')

        self.account.last_updated = datetime(2007, 5, 1)
        dl.updateAccount(self.account, cacheApi)

        cacheApi.verify()
示例#5
0
 def test_parseEntry(self):
     entry = {'id': u'http://twitter.com/manuelaristaran/statuses/465479172',
              'link': u'http://twitter.com/manuelaristaran/statuses/465479172',
              'summary': u'manuelaristaran: Primer d\xeda en los nuevos HQ de Popego. Classy.',
              'title': u'manuelaristaran: Primer d\xeda en los nuevos HQ de Popego. Classy.',
              'updated': u'Mon, 03 Dec 2007 14:24:28 +0000',
              'updated_parsed': (2007, 12, 3, 14, 24, 28, 0, 337, 0)}
     ext_id = entry['id']
     cacheApiMock = p.Mock()
     cacheApiMock.expects(p.once()).itemExists(p.eq(ext_id)) \
         .will(p.return_value(False))
     cacheApiMock.expects(p.once()).method('addItem')
     cacheApiMock.expects(p.once()).method('bindItem2Group')
     quote = twitter_agent._parseEntry(entry, cacheApiMock)
     cacheApiMock.verify()
示例#6
0
    def test_updateAccount_NewAccount(self):
        self._mockFeedCall('playlists', 'playlists-empty')
        self._mockFeedCall('favorites', 'favorites')
        self._mockFeedCall('favorites?start-index=26', 'favorites')
        self._mockFeedCall('uploads', 'favorites')
        self._mockFeedCall('uploads?start-index=26', 'favorites')

        cacheApi = p.Mock()
        cacheApi.expects(p.exactly(2)).method('addGroup')
        cacheApi.expects(p.exactly(100)).method('itemExists').will(
            p.return_value(False))
        cacheApi.expects(p.exactly(100)).method('addItem')
        cacheApi.expects(p.exactly(100)).method('bindItem2Group')

        yt.updateAccount(self.account, cacheApi)

        cacheApi.verify()
        self.cliMock.verify()
示例#7
0
    def test_updateAccount_OldAccount(self):
        self._mockFeedCall('playlists', 'playlists-empty')
        self._mockFeedCall('favorites', 'favorites')
        self._mockFeedCall('favorites?start-index=26', 'favorites')
        self._mockFeedCall('uploads', 'favorites')
        self._mockFeedCall('uploads?start-index=26', 'favorites')

        self.account.last_updated = datetime.datetime(2007, 5, 1)

        cacheApi = p.Mock()
        cacheApi.expects(p.exactly(2)).method('groupItems').will(
            p.return_value(['http://www.youtube.com/watch?v=i_QABS88nDc']))

        cacheApi.expects(p.exactly(2)).method('removeItemFromGroup')
        cacheApi.expects(p.exactly(100)).method('itemExists').will(
            p.return_value(False))
        cacheApi.expects(p.exactly(100)).method('addItem')
        cacheApi.expects(p.exactly(100)).method('bindItem2Group')

        yt.updateAccount(self.account, cacheApi)

        cacheApi.verify()
        self.cliMock.verify()
示例#8
0
 def setUp(self):
     self.account = Account(username='******')
     self.cliMock = p.Mock()
     self.originalCli = pi.cli
     pi.cli = self.cliMock
示例#9
0
 def setUp(self):
     super(self.__class__, self).setUp()
     self.account = Account(username='******')
     self.cliMock = p.Mock()
     self.originalCli = yt.cli
     yt.cli = self.cliMock