Esempio n. 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()
Esempio n. 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()
Esempio n. 3
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()
Esempio n. 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()
Esempio n. 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()
Esempio n. 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()
Esempio n. 7
0
 def _mockFeedCall(self, filename, albumId=None):
     feedUrl = pi.feedUrl(self.account.username, albumId)
     feed = self._getFeed(filename)
     self.cliMock.expects(p.once()).GetFeed(p.eq(feedUrl)).will(p.return_value(feed))
     return feedUrl
Esempio n. 8
0
 def _mockFeedCall(self, feedName, filename):
     feedUrl = 'http://gdata.youtube.com/feeds/users/%s/%s' % (
         self.account.username, feedName)
     feed = self._getFeed(filename)
     return self.cliMock.expects(p.once()).GetFeed(p.eq(feedUrl)).will(
         p.return_value(feed))