class GooglePlusTest(testutil.HandlerTest): def setUp(self): super(GooglePlusTest, self).setUp() self.googleplus = GooglePlus(key_name='x') self.mox.StubOutWithMock(GooglePlusService, 'call') self.mox.StubOutWithMock(GooglePlusService, 'call_with_creds') def test_activity_to_salmon_vars(self): self.assert_equals(ACTIVITY_SALMON_VARS, self.googleplus.activity_to_salmon_vars(ACTIVITY_JSON)) def test_activity_to_salmon_vars_minimal(self): salmon = self.googleplus.activity_to_salmon_vars({'id': '123'}) self.assert_equals('tag:plus.google.com,2012:123', salmon['id']) def test_comment_to_salmon_vars(self): expected = copy.deepcopy(COMMENT_SALMON_VARS) expected['in_reply_to'] = None self.assert_equals(expected, self.googleplus.activity_to_salmon_vars(COMMENT_JSON)) def test_get_salmon(self): # this one should be dropped without_link = copy.deepcopy(ACTIVITY_SALMON_VARS) without_link['in_reply_to'] = None GooglePlusService.call_with_creds('my gae user id', 'activities.list', userId='x', collection='public', maxResults=100)\ .AndReturn({'items': [ACTIVITY_JSON, without_link]}) GooglePlusService.call_with_creds('my gae user id', 'comments.list', activityId='123', maxResults=100)\ .AndReturn({'items': [COMMENT_JSON]}) self.mox.ReplayAll() self.googleplus.owner = models.User(key_name='my gae user id') self.assert_equals([ACTIVITY_SALMON_VARS, COMMENT_SALMON_VARS], self.googleplus.get_salmon()) def test_new(self): GooglePlusService.call('http placeholder', 'people.get', userId='me')\ .AndReturn({'id': '1', 'displayName': 'Mr. Foo', 'url': 'http://my.g+/url', 'image': {'url': 'http://my.pic/small'}, }) self.mox.ReplayAll() gp = GooglePlus.new(self.handler, http='http placeholder') self.assertEqual('1', gp.key().name()) self.assertEqual('Mr. Foo', gp.name) self.assertEqual('http://my.pic/small', gp.picture) self.assertEqual('http://my.g+/url', gp.url) self.assertEqual(self.current_user_id, gp.owner.key().name())
def __init__(self, username): config = ConfigParser.ConfigParser() config.read('./config.properties') self.pinterest = Pinterest(username, config) self.googleplus = GooglePlus(username, config) self.youtube = YouTube(username, config) self.twitch = Twitch(username, config) self.vimeo = Vimeo(username, config) self.behance = Behance(username, config) self.instagram = Instagram(username, config) self.twitter = Twitter(username, config) self.github = Github(username, config) self.dict = dict()
def test_new(self): GooglePlusService.call('http placeholder', 'people.get', userId='me')\ .AndReturn({'id': '1', 'displayName': 'Mr. Foo', 'url': 'http://my.g+/url', 'image': {'url': 'http://my.pic/small'}, }) self.mox.ReplayAll() gp = GooglePlus.new(self.handler, http='http placeholder') self.assertEqual('1', gp.key().name()) self.assertEqual('Mr. Foo', gp.name) self.assertEqual('http://my.pic/small', gp.picture) self.assertEqual('http://my.g+/url', gp.url) self.assertEqual(self.current_user_id, gp.owner.key().name())
class SocialMediaApi(object): def __init__(self, username): config = ConfigParser.ConfigParser() config.read('./config.properties') self.pinterest = Pinterest(username, config) self.googleplus = GooglePlus(username, config) self.youtube = YouTube(username, config) self.twitch = Twitch(username, config) self.vimeo = Vimeo(username, config) self.behance = Behance(username, config) self.instagram = Instagram(username, config) self.twitter = Twitter(username, config) self.github = Github(username, config) self.dict = dict() def getAllInfo(self): pinterestcount = self.pinterest.getPinterestInfoForUser() googlepluscount = self.googleplus.getGooglePlusInfoForUser() youtubecount = self.youtube.getYouTubeInfoForUser() twitchcount = self.twitch.getTwitchInfoForUser() vimeocount = self.vimeo.getVimeoInfoForUser() behancecount = self.behance.getBehanceInfoForUser() instagramcount = self.instagram.getInstagramInfoForUser() twittercount = self.twitter.getTwitterInfoForUser() githubcount = self.github.getGitHubInfoForUser() self.dict['GITHUB'] = githubcount self.dict['TWITTER'] = twittercount self.dict['INSTAGRAM'] = instagramcount self.dict['BEHANCE'] = behancecount self.dict['PINTEREST'] = pinterestcount self.dict['GOOGLEPLUS'] = googlepluscount self.dict['YOUTUBE'] = youtubecount self.dict['TWITCH'] = twitchcount self.dict['VIMEO'] = vimeocount def printDict(self): print("\n ********Output********* \n") pprint.pprint(self.dict)
def setUp(self): super(GooglePlusTest, self).setUp() self.googleplus = GooglePlus(key_name='x') self.mox.StubOutWithMock(GooglePlusService, 'call') self.mox.StubOutWithMock(GooglePlusService, 'call_with_creds')