def test_send_share(self):
        from d51.django.auth.facebook import utils, models

        user = User.objects.create(
            username=_.random_string
        )
        user.facebook = models.FacebookID()
        user.facebook.uid = _.random
        self.mox.StubOutWithMock(utils, 'get_facebook_api')

        alternate = Alternate()
        alternate.url = _.random_string

        share = Share()
        share.user = user
        share.alternate = alternate
        share.title, share.description = _.random_string, _.random_string

        fake_attachment = {
            'name':share.title,
            'href':share.alternate.url,
            'description':share.description
        }

        mock_facebook = self.mox.CreateMock(Dolt)
        mock_facebook.stream = self.mox.CreateMock(Dolt)
        mock_facebook.stream.publish = self.mox.CreateMock(Dolt)
        mock_facebook.stream.publish(attachment=fake_attachment, uid=str(user.facebook.uid))
        utils.get_facebook_api(for_uid=user.facebook.uid).AndReturn(mock_facebook)
        self.mox.ReplayAll()
        service = FacebookService(None, None, None)
        service.send_share(share)
        self.mox.VerifyAll()
    def test_of_send_share(self):
        from d51.django.auth.twitter import utils, models

        random_value = _.random
        random_string = 'random thing to say no. %d' % _.random

        user = User.objects.create(
            username='******'%_.random
        )
        user.twitter = self.mox.CreateMock(models.TwitterToken)
        user.twitter.get_oauth_token().AndReturn(random_value)

        alternate = Alternate()
        alternate.url = random_string

        share = Share()
        share.alternate = alternate
        share.user = user
        share.title = random_string

        dolt_mock = self.mox.CreateMock(Dolt)
        dolt_mock.statuses = self.mox.CreateMock(Dolt)
        dolt_mock.statuses.update = self.mox.CreateMock(Dolt)
        dolt_mock.statuses.update.POST = self.mox.CreateMock(Dolt)
        dolt_mock.statuses.update.POST(status='%s %s' % (share.title, random_string))
        self.mox.StubOutWithMock(utils, 'get_twitter_api')
        utils.get_twitter_api(token=random_value).AndReturn(dolt_mock)

        self.mox.ReplayAll()
        service = TwitterService(None, None, None)
        service.send_share(share)
        self.mox.VerifyAll()