ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 1 | #!/usr/bin/python2.4 |
| 2 | # |
| 3 | # Copyright 2010 Google Inc. All Rights Reserved. |
| 4 | |
| 5 | """Discovery document tests |
| 6 | |
| 7 | Functional tests that verify we can retrieve data from existing services. |
| 8 | |
| 9 | These tests are read-only in order to ensure they're repeatable. They also |
| 10 | only work with publicly visible data in order to avoid dealing with OAuth. |
| 11 | """ |
| 12 | |
| 13 | __author__ = 'ade@google.com (Ade Oshineye)' |
| 14 | |
| 15 | from apiclient.discovery import build |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 16 | import logging |
| 17 | import unittest |
| 18 | |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 19 | class BuzzFunctionalTest(unittest.TestCase): |
| 20 | def test_can_get_buzz_activities_with_many_params(self): |
| 21 | buzz = build('buzz', 'v1') |
| 22 | max_results = 2 |
Joe Gregorio | c5c5a37 | 2010-09-22 11:42:32 -0400 | [diff] [blame] | 23 | actcol = buzz.activities() |
| 24 | activities = actcol.list(userId='googlebuzz', scope='@self', |
| 25 | max_comments=max_results*2 ,max_liked=max_results*3, |
Joe Gregorio | db849af | 2010-09-22 16:53:59 -0400 | [diff] [blame] | 26 | max_results=max_results).execute() |
| 27 | activity_count = len(activities['items']) |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 28 | self.assertEquals(max_results, activity_count) |
Joe Gregorio | c5c5a37 | 2010-09-22 11:42:32 -0400 | [diff] [blame] | 29 | |
Joe Gregorio | db849af | 2010-09-22 16:53:59 -0400 | [diff] [blame] | 30 | activities = actcol.list_next(activities).execute() |
| 31 | activity_count = len(activities['items']) |
| 32 | self.assertEquals(max_results, activity_count) |
| 33 | |
ade@google.com | 973d1a6 | 2010-09-23 21:21:21 +0100 | [diff] [blame^] | 34 | def test_can_page_through_users_activities(self): |
| 35 | buzz = build('buzz', 'v1') |
| 36 | max_results = 2 |
| 37 | actcol = buzz.activities() |
| 38 | |
| 39 | activities = actcol.list(userId='adewale', scope='@self', |
| 40 | max_results=max_results).execute() |
| 41 | for count in range(10): |
| 42 | activities = actcol.list_next(activities).execute() |
| 43 | activity_count = len(activities['items']) |
| 44 | self.assertEquals(max_results, activity_count, 'Failed after %s pages' % str(count)) |
| 45 | |
Joe Gregorio | db849af | 2010-09-22 16:53:59 -0400 | [diff] [blame] | 46 | if __name__ == '__main__': |
| 47 | unittest.main() |