*Added myspace09_test.py that contains testcases to validate the above
mentioned
classes against myspace rest container.
http://code.google.com/p/opensocial-python-client/source/detail?r=82
Added:
/trunk/tests/opensocial_tests/myspace09_test.py
Modified:
/trunk/src/opensocial/__init__.py
/trunk/src/opensocial/data.py
/trunk/src/opensocial/http.py
/trunk/src/opensocial/oauth/__init__.py
/trunk/src/opensocial/request.py
/trunk/tests/run_online_tests.py
=======================================
--- /dev/null
+++ /trunk/tests/opensocial_tests/myspace09_test.py Fri Nov 13 11:29:29 2009
@@ -0,0 +1,146 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2007, 2008 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+__author__ = 'smadyal...@myspace-inc.com (Sushruth Madyalamajalu)'
+
+
+import unittest
+
+import opensocial
+
+
+class TestMySpace09(unittest.TestCase):
+
+ def setUp(self):
+ self.config = opensocial.ContainerConfig(
+ oauth_consumer_key='http://www.myspace.com/503369944',
+
oauth_consumer_secret='a99b44c5e6bf4f82ad3b0963513f0d0b682afe517cbd4c51a40d7a5b06472966',
+ server_rest_base='http://opensocial.myspace.com/roa/09')
+ self.container = opensocial.ContainerContext(self.config)
+ self.user_id = '384066058'
+
+ def validate_user(self, user):
+ self.assertEquals("myspace.com.person." + self.user_id, user.get_id())
+
+ def validate_friends(self, friends):
+ self.assertEquals(3, len(friends))
+ self.assertEquals(3, int(friends.totalResults) )
+ self.assertEquals('myspace.com.person.6221', friends[0].get_id())
+ self.assertEquals('myspace.com.person.360215256', friends[1].get_id())
+
+ def do_fetch_person(self, use_rpc, fields=None):
+ self.container.set_allow_rpc(use_rpc)
+ person = self.container.fetch_person(self.user_id, fields)
+ return person
+
+ def do_fetch_friends(self, use_rpc, fields=None):
+ self.container.set_allow_rpc(use_rpc)
+ friends = self.container.fetch_friends(self.user_id, fields)
+ return friends
+
+ def test_fetch_person_rest(self):
+ person = self.do_fetch_person(False)
+ self.validate_user(person)
+
+ def test_fetch_friends_rest(self):
+ friends = self.do_fetch_friends(False)
+ self.validate_friends(friends)
+
+ def test_fetch_person_fields_rest(self):
+ person = self.do_fetch_person(False, ['displayName'])
+ self.assertEquals('SushTest', person.get_field('displayName'))
+
+ def test_fetch_supportedfields_rest(self):
+ self.container.set_allow_rpc(False)
+ personfields= self.container.fetch_supportedfields(
self.user_id, 'people')
+ self.assertNotEquals( personfields.index("name") , -1 )
+ groupsfields = self.container.fetch_supportedfields(
self.user_id, 'groups')
+ self.assertNotEquals( groupsfields.index("title") , -1 )
+ albumsfields = self.container.fetch_supportedfields(
self.user_id, 'albums')
+ self.assertNotEquals( albumsfields.index("mediaType") , -1 )
+
+ def test_fetch_group_rest(self):
+ self.container.set_allow_rpc(False)
+ groups = self.container.fetch_groups(self.user_id)
+ self.assertEquals(int(groups.totalResults), 2)
+ self.assertEquals(groups[0].get_title(), "FriendCategory1")
+ groups = self.container.fetch_groups(self.user_id, {'startIndex':
2, 'count': 1})
+ self.assertEquals(groups[0].get_title(), "FriendCategory2")
+
+ def test_fetch_album_rest(self):
+ self.container.set_allow_rpc(False)
+ albums = self.container.fetch_albums(self.user_id)
+ self.assertTrue(int(albums.totalResults) > 8)
+ albums =
self.container.fetch_albums(self.user_id,'myspace.com.album.1407969')
+ self.assertEquals(albums['caption'], "allBUMs")
+
+ def test_fetch_mediaitem_rest(self):
+ self.container.set_allow_rpc(False)
+ mediaitems =
self.container.fetch_mediaitems(self.user_id,'myspace.com.album.1417886')
+ self.assertEquals(int(mediaitems.totalResults), 3)
+ mediaitems =
self.container.fetch_mediaitems(self.user_id,'myspace.com.album.1417886', 'myspace.com.mediaItem.image.23434774')
+ self.assertEquals( mediaitems['title'], "doink" )
+
+ def test_fetch_post_notification(self):
+ self.container.set_allow_rpc(False)
+ recipients = ["384066058" , "360215256"]
+ mediaitems =
["http://opensocial.myspace.com/roa/09/mediaItems/360215256/@self/myspace.com.album.1417886/myspace.com.mediaItem.image.23434774",
+ "http://opensocial.myspace.com/roa/09/mediaItems/360215256/@self/myspace.com.album.1417886/myspace.com.mediaItem.image.23434774"]
+ tp =[]
+ p1 ={}
+ p2={}
+ p1["key"] = "content"
+ p1["value"]= "Hi ${recipient}, This is the a test message."
+ p2["key"] = "somethingelse"
+ p2["value"]= "okie"
+ tp.append(p1);
+ tp.append(p2);
+ notification = self.container.create_notification(self.user_id,
recipients, mediaitems,tp)
+ self.assertNotEqual( notification['statusLink'].find('http://') , -1 )
+ notification = self.container.create_notification("@me", recipients,
mediaitems,tp , {'xoauth_requestor_id':360215256})
+ self.assertNotEqual( notification['statusLink'].find('http://') , -1 )
+
+ def test_fetch_status_mood_and_Comments(self):
+ statusmood = self.container.fetch_statusmood(self.user_id)
+ statusmoodcomments =
self.container.fetch_statusmoodcomments(self.user_id, {'postedDate':
statusmood['moodStatusLastUpdated']})
+ self.assertNotEqual( len(statusmoodcomments) , 0)
+
+ def test_fetch_profileComments(self):
+ profilecomment = self.container.fetch_profilecomments(self.user_id)
+ self.assertNotEqual(len(profilecomment) , 0)
+
+ def test_fetch_activity_request(self):
+ activity = self.container.fetch_activity(self.user_id)
+ self.assertNotEquals( len(activity) , 0 )
+ activity = self.container.fetch_activity(self.user_id, '@self' ,'@app')
+
+ def test_create_album_request(self):
+ album = self.container.create_album(self.user_id, {'caption':'Test
Album1'} )
+ self.assertNotEqual( album['statusLink'].find('http://') , -1 )
+
+ def test_batch(self):
+ batch = opensocial.request.RequestBatch()
+ batch.add_request('me',
+ opensocial.request.FetchPersonRequest(self.user_id))
+ batch.add_request('friends',
+ opensocial.request.FetchPeopleRequest(self.user_id,
+ '@friends'))
+ batch.send(self.container)
+ me = batch.get('me')
+ friends = batch.get('friends')
+ self.validate_user(me)
+ self.validate_friends(friends)
+
=======================================
--- /trunk/src/opensocial/__init__.py Wed Oct 21 16:05:22 2009
+++ /trunk/src/opensocial/__init__.py Fri Nov 13 11:29:29 2009
@@ -107,6 +107,18 @@
"""
return self.allow_rpc and self.config.server_rpc_base is not None
+ def fetch_supportedfields(self, user_id='@me', osobject='' ):
+ """Fetches a supported fields for given object.
+ Args:
+ user_id: str The person's container-specific id.
+ osobject: resource\method to which supported fields need to be
retrieved .
+
+ Returns: A json object containing supported fields.
+ """
+ request = FetchSupportedFields(user_id, osobject)
+ return self.send_request(request)
+
+
def fetch_person(self, user_id='@me', fields=None):
"""Fetches a person by user id.
@@ -134,6 +146,141 @@
request = FetchPeopleRequest(user_id, '@friends', fields=fields)
return self.send_request(request)
+ def fetch_groups(self, user_id='@me', params=None):
+ """Fetches catagories created by user id.
+
+ Args:
+ user_id: str The person's container-specific id.
+ params: dict (optional) Additional query parameters.
+
+ Returns: A Group object for the specified user.
+
+ """
+
+ request = FetchGroupRequest(user_id,params)
+ return self.send_request(request)
+
+ def fetch_albums(self, user_id='@me', albumid = None, params=None):
+ """Fetches albums created by user id.
+
+ Args:
+ user_id: str The person's container-specific id.
+ albumid: str albumid (optional) that needs to be fetched.
+ params: dict (optional) Additional fields to that need to be passed
+
+ Returns: A album objects for the specified user Id.
+
+ """
+
+ request = FetchAlbumRequest(user_id, albumid, params)
+ return self.send_request(request)
+
+ def fetch_mediaitems(self, user_id='@me', albumid = None,
mediaitemid=None, params=None):
+ """Fetches mediaitems created by user id.
+
+ Args:
+ user_id: str The person's container-specific id.
+ albumid: str albumid of the mediaitem that needs to be fetched.
+ mediaitemid:str mediaitem that needs to be fetched.
+ params: dict (optional) Additional fields to that need to be passed
+
+ Returns: A collection of mediaitem object representing the specified
user id.
+
+ """
+
+ request = FetchMediaItemsRequest(user_id, albumid, mediaitemid, params)
+ return self.send_request(request)
+
+ def fetch_activity(self, user_id='@me', group='@self', app = None,
params=None):
+ """Fetches activities created by user id.
+
+ Args:
+ user_id: str The person's container-specific id.
+ group:str user specified selector.
+ fields: list (optional) List of fields to retrieve.
+
+ Returns: A collection of mediaitem object representing the specified
user id.
+
+ """
+
+ request = FetchActivityRequest(user_id, group, app, params)
+ return self.send_request(request)
+
+ def create_notification(self, user_id, recipients, mediaitems = None,
templateParameters = None,
+ params=None):
+ """Creates app notification.
+
+ Args:
+ user_id: str The person's container-specific id.
+ recipients: list of recipient to whom the notifications needs to
be sent
+ mediaitems: list of media items associated with the
+ templateParameters: list of dictionary items containing key and
value fields
+ params: dict (optional) Additional fields to that need to be
passed
+
+ Returns: a json object containing notification object id and url.
+
+ """
+
+ request = CreateNotificationRequest(user_id, recipients,
mediaitems, templateParameters, params)
+
+ return self.send_request(request)
+
+ def create_album(self, user_id, params):
+ """Creates app notification.
+
+ Args:
+ user_id: str The person's container-specific id.
+ params: dict containing the query params kvp need for album
creation like caption,mediaiteamcount etc
+
+ Returns: a json object containing notification object id and url.
+
+ """
+
+ request = CreateAlbumRequest(user_id,params)
+ return self.send_request(request)
+
+
+ def fetch_statusmood(self, user_id='@me', params=None):
+ """Fetches statusmood created by user id.
+
+ Args:
+ user_id: str The person's container-specific id.
+ parama: (optional) .
+
+ Returns: A statusmood object representing the specified user id.
+
+ """
+
+ request = FetchStatusMoodRequest(user_id,params)
+ return self.send_request(request)
+
+ def fetch_statusmoodcomments(self, user_id='@me', params=None):
+ """Fetches fetch_statusmoodcomments on users profile.
+
+ Args:
+ user_id: str The person's container-specific id.
+ parama: (optional) .
+
+ Returns: A fetch_statusmoodcomments object representing the specified
user id.
+
+ """
+
+ request = FetchStatusMoodCommentsRequest(user_id,params)
+ return self.send_request(request)
+
+ def fetch_profilecomments(self, user_id='@me', params=None):
+ """Fetches fetch_profile on users profile.
+
+ Args:
+ user_id: str The person's container-specific id.
+ parama: (optional) .
+
+ Returns: A profile comment object representing the specified user id.
+
+ """
+ request = FetchProfileCommentsRequest(user_id,params)
+ return self.send_request(request)
+
def send_request(self, request, use_rest=False):
"""Sends the request.
@@ -188,7 +335,7 @@
http_response = self._send_http_request(http_request)
json = self._handle_response(http_response)
return request.process_json(json)
-
+
def _send_rpc_requests(self, batch):
rpcs = []
id_to_key_map = {}
@@ -257,7 +404,6 @@
else:
raise BadRequestError(http_response)
-
class OrkutSandboxContext(ContainerContext):
"""The context for accessing orkut's sandbox."""
def __init__(self, config, url_fetch=None):
@@ -291,4 +437,4 @@
}
local_config.update(config)
super(GoogleFriendConnectContext, self).__init__(local_config,
url_fetch)
-
+
=======================================
--- /trunk/src/opensocial/data.py Wed Sep 30 22:30:42 2009
+++ /trunk/src/opensocial/data.py Fri Nov 13 11:29:29 2009
@@ -51,6 +51,7 @@
"""An opensocial.Person representation."""
def __init__(self, fields):
+ fields = fields.get('person') or fields
super(Person, self).__init__(fields)
def get_id(self):
@@ -86,6 +87,80 @@
"""
return Person(extract_fields(json))
+class Group(Object):
+ """Group object."""
+ def __init__(self, data):
+ if data !=None:
+ data = data.get('group') or data
+ super(Group, self).__init__(data)
+
+ def get_title(self):
+ return self['title'];
+
+ def get_id(self):
+ return self['id']
+
+ @staticmethod
+ def parse_json(json):
+ return Group(extract_fields(json))
+
+class StatusMood(Object):
+ """StatusMood object."""
+ def __init__(self, data):
+ super(StatusMood, self).__init__(data)
+
+ @staticmethod
+ def parse_json(json):
+ return StatusMood(extract_fields(json))
+
+class StatusMoodComments(Object):
+ """StatusMoodComments object."""
+ def __init__(self, data):
+ super(StatusMoodComments, self).__init__(data)
+
+ @staticmethod
+ def parse_json(json):
+ return StatusMoodComments(extract_fields(json))
+
+class ProfileComments(Object):
+ """StatusMoodComments object."""
+ def __init__(self, data):
+ super(ProfileComments, self).__init__(data)
+
+ @staticmethod
+ def parse_json(json):
+ return ProfileComments(extract_fields(json))
+
+class Album(Object):
+ """Album object."""
+ def __init__(self, data):
+ if data !=None:
+ data = data.get('album') or data
+ super(Album, self).__init__(data)
+
+ @staticmethod
+ def parse_json(json):
+ return Album(extract_fields(json))
+
+class MediaItem(Object):
+ """MediaItem object."""
+ def __init__(self, data):
+ if data !=None:
+ data = data.get('mediaItem') or data
+ super(MediaItem, self).__init__(data)
+
+ @staticmethod
+ def parse_json(json):
+ return MediaItem(extract_fields(json))
+
+class Notification(Object):
+ """NotificationItem object."""
+ def __init__(self, data):
+ super(Notification, self).__init__(data)
+
+ @staticmethod
+ def parse_json(json):
+ return Notification(extract_fields(json))
class AppData(Object):
"""Application data stored on the container."""
@@ -100,6 +175,8 @@
class Activity(Object):
"""An activity entry."""
def __init__(self, data):
+ if data !=None:
+ data = data.get('activity') or data
super(Activity, self).__init__(data)
@staticmethod
@@ -139,6 +216,7 @@
total = json.get('totalResults')
items = []
json_list = json.get('entry') or json.get('list')
- for fields in json_list:
- items.append(cls(fields))
+ if json_list != None:
+ for fields in json_list:
+ items.append(cls(fields))
return Collection(items, start, total)
=======================================
--- /trunk/src/opensocial/http.py Wed Jul 15 14:34:55 2009
+++ /trunk/src/opensocial/http.py Fri Nov 13 11:29:29 2009
@@ -131,12 +131,13 @@
"""
- def __init__(self, url, method='GET', signed_params=None,
post_body=None):
+ def __init__(self, url, method='GET', signed_params=None,
post_body=None, add_bodyhash=True):
self.post_body = post_body or None
"""OAuth library will not create a request unless there is at least one
parameter. So we are going to set at least one explicitly.
"""
self.use_body_as_signing_parameter = False
+ self.add_bodyhash = add_bodyhash;
params = signed_params or {}
params['opensocial_method'] = method
self.oauth_request = oauth.OAuthRequest.from_request(method, url,
@@ -177,11 +178,12 @@
# Otherwise, use the oauth_body_hash extension to sign the request
body.
if self.post_body:
if VERBOSE > 0:
- logging.info("post_body => %s" % str(self.post_body))
-
- body_hash = b64encode(hashlib.sha1(self.get_post_body()).digest())
- params['oauth_body_hash'] = body_hash
-
+ logging.info("post_body => %s" % str(self.post_body))
+
+ if self.add_bodyhash:
+ body_hash =
b64encode(hashlib.sha1(self.get_post_body()).digest())
+ params['oauth_body_hash'] = body_hash
+
if self.get_security_token():
self.set_parameter("xoauth_requestor_id", None)
=======================================
--- /trunk/src/opensocial/oauth/__init__.py Fri Jul 17 10:05:06 2009
+++ /trunk/src/opensocial/oauth/__init__.py Fri Nov 13 11:29:29 2009
@@ -272,7 +272,7 @@
self.signature_methods = signature_methods or {}
def set_data_store(self, oauth_data_store):
- self.data_store = data_store
+ self.data_store = oauth_data_store
def get_data_store(self):
return self.data_store
=======================================
--- /trunk/src/opensocial/request.py Thu Oct 1 13:43:13 2009
+++ /trunk/src/opensocial/request.py Fri Nov 13 11:29:29 2009
@@ -97,6 +97,155 @@
return self.rpc_request.get_rpc_body()
+class FetchSupportedFields(Request):
+ """A request class for fetching supported fields. """
+ def __init__(self, user_id, osobject):
+ rest_request =
RestRequestInfo('/'.join((osobject, '@supportedFields')),'GET')
+ super(FetchSupportedFields, self).__init__(rest_request,
+ None,
+ user_id)
+ def process_json(self, json):
+ """Construct the appropriate OpenSocial object from a JSON dict.
+ Args:
+ json: dict The JSON structure.
+ Returns: a Collection of Person objects.
+ """
+ return json
+
+
+class FetchGroupRequest(Request):
+ """A request for handling group"""
+ def __init__(self, user_id, params=None):
+ params = params or {}
+ rest_request = RestRequestInfo('/'.join(('groups',
user_id)),'GET', params )
+
+ super(FetchGroupRequest, self).__init__(rest_request,
+ None,
+ user_id)
+
+ def process_json(self, json):
+ """Construct the appropriate OpenSocial object from a JSON dict.
+ Args:
+ json: dict The JSON structure.
+ Returns: a Collection of Person objects.
+ """
+ return data.Collection.parse_json(json, data.Group)
+
+class FetchAlbumRequest(Request):
+ """A request for handling Album"""
+
+ def __init__(self, user_id, albumid=None, params=None):
+ params = params or {}
+ if albumid != None:
+ rest_request = RestRequestInfo('/'.join(('albums',
user_id,'@self', albumid)),'GET', params )
+ else:
+ rest_request = RestRequestInfo('/'.join(('albums',
user_id,'@self')),'GET', params )
+
+ super(FetchAlbumRequest, self).__init__(rest_request,
+ None,
+ user_id)
+
+ def process_json(self, json):
+ """Construct the appropriate OpenSocial object from a JSON dict.
+ Args:
+ json: dict The JSON structure.
+ Returns: a Collection of Person objects.
+ """
+ json_list = json.get('album')
+
+ if json_list != None:
+ """ this is individual album """
+ return data.Album(json_list)
+
+ return data.Collection.parse_json(json, data.Album )
+
+
+class FetchMediaItemsRequest(Request):
+ """A request for handling Album"""
+
+ def __init__(self, user_id, albumid=None, mediaitemid=None,
params=None):
+ params = params or {}
+ if mediaitemid != None:
+ rest_request = RestRequestInfo('/'.join(('mediaitems',
user_id,'@self', albumid, mediaitemid)),'GET', params )
+ else:
+ rest_request = RestRequestInfo('/'.join(('mediaitems',
user_id,'@self', albumid)),'GET', params )
+
+ super(FetchMediaItemsRequest, self).__init__(rest_request,
+ None,
+ user_id)
+
+ def process_json(self, json):
+ """Construct the appropriate OpenSocial object from a JSON dict.
+ Args:
+ json: dict The JSON structure.
+ Returns: a Collection of Person objects.
+ """
+ json_list = json.get('mediaItem')
+
+ if json_list != None:
+ """ this is individual album """
+ return data.MediaItem(json_list)
+
+ return data.Collection.parse_json(json, data.MediaItem )
+
+
+class FetchStatusMoodRequest(Request):
+ """A request for handling Statusmoodcomments"""
+
+ def __init__(self, user_id, params=None):
+ params = params or {}
+ rest_request = RestRequestInfo('/'.join(('statusmood',
user_id,'@self')),'GET', params )
+
+ super(FetchStatusMoodRequest, self).__init__(rest_request,
+ None,
+ user_id)
+
+ def process_json(self, json):
+ """Construct the appropriate OpenSocial object from a JSON dict.
+ Args:
+ json: dict The JSON structure.
+ Returns: a Collection of Person objects.
+ """
+ return data.StatusMood(json)
+
+class FetchStatusMoodCommentsRequest(Request):
+ """A request for handling StatusmoodcommentsRequests"""
+
+ def __init__(self, user_id, params=None):
+ params = params or {}
+ rest_request = RestRequestInfo('/'.join(('statusMoodComments',
user_id,'@self')),'GET', params )
+
+ super(FetchStatusMoodCommentsRequest, self).__init__(rest_request,
+ None,
+ user_id)
+
+ def process_json(self, json):
+ """Construct the appropriate OpenSocial object from a JSON dict.
+ Args:
+ json: dict The JSON structure.
+ Returns: a Collection of statusmoodcomments objects objects.
+ """
+ return data.Collection.parse_json(json, data.StatusMoodComments)
+
+
+class FetchProfileCommentsRequest(Request):
+ """A request for handling profile comments"""
+
+ def __init__(self, user_id, params=None):
+ params = params or {}
+ rest_request = RestRequestInfo('/'.join(('profilecomments',
user_id,'@self')),'GET', params )
+ super(FetchProfileCommentsRequest, self).__init__(rest_request,
+ None,
+ user_id)
+
+ def process_json(self, json):
+ """Construct the appropriate OpenSocial object from a JSON dict.
+ Args:
+ json: dict The JSON structure.
+ Returns: a Collection of statusmoodcomments objects objects.
+ """
+ return data.Collection.parse_json(json, data.ProfileComments)
+
class FetchPeopleRequest(Request):
"""A request for handling fetching a collection of people."""
@@ -233,6 +382,47 @@
return json
+
+
+class CreateNotificationRequest(Request):
+ """ A request for creating an Notification. """
+ def __init__(self, user_id, recipients, mediaitems = None,
templateParameters = None,
+ params=None):
+
+ params = params or {}
+ bodycontent = {}
+ if mediaitems !=None:
+ itemlist =[]
+ for mediaitem in mediaitems:
+ itemdict = {}
+ itemdict['msMediaItemUri'] = mediaitem;
+ itemlist.append(itemdict);
+
+ bodycontent['mediaItems'] = itemlist
+ bodycontent['recipientIds'] = recipients
+ bodycontent['templateParameters'] = templateParameters
+
+ #if user_id != "@me":
+ # params['xoauth_requestor_id'] = user_id;
+
+ rest_request = RestRequestInfo('/'.join(('notifications',
user_id,'@self')),'POST', params, bodycontent, False)
+ super(CreateNotificationRequest, self).__init__(rest_request,
+ None,
+ user_id)
+
+ def process_json(self, json):
+ return json
+
+class CreateAlbumRequest(Request):
+ def __init__(self, user_id, body, params = None):
+ params = params or {}
+ rest_request = RestRequestInfo('/'.join(('albums',
user_id,'@self')),'POST', params, body , False)
+ super(CreateAlbumRequest, self ).__init__(rest_request, None, user_id)
+ pass
+
+ def process_json(self, json):
+ return json
+
class CreateActivityRequest(Request):
""" A request for creating an activity. """
def __init__(self, user_id, activity, group_id='@self', app_id='@app',
@@ -254,7 +444,7 @@
class FetchActivityRequest(Request):
- def __init__(self, user_id, group_id='@self', app_id='@app',
params=None):
+ def __init__(self, user_id, group_id='@self', app_id=None, params=None):
params = params or {}
#TODO: add support for rest
params.update({'userId': user_id,
@@ -262,7 +452,12 @@
'appId': app_id,
})
rpc_request = RpcRequestInfo('activities.get', params=params)
- super(FetchActivityRequest, self).__init__(None,
+ if app_id != None:
+ rest_request = RestRequestInfo('/'.join(('activities',
user_id,'@self', app_id)),'GET', params)
+ else:
+ rest_request = RestRequestInfo('/'.join(('activities',
user_id,'@self')),'GET', params)
+
+ super(FetchActivityRequest, self).__init__(rest_request,
rpc_request,
user_id)
@@ -273,10 +468,12 @@
class RestRequestInfo(object):
"""Represents a pending REST request."""
- def __init__(self, path, method='GET', params=None):
+ def __init__(self, path, method='GET', params=None, body=None,
body_hash=True):
self.method = method
self.path = path
self.params = params or {}
+ self.body = body
+ self.body_hash = body_hash
def make_http_request(self, url_base, query_params=None):
"""Generates a http.Request object for the UrlFetch interface.
@@ -293,8 +490,8 @@
url = url_base + self.path
if query_params:
self.params.update(query_params)
- return http.Request(url, method=self.method, signed_params=self.params)
-
+
+ return http.Request(url, method=self.method,
signed_params=self.params, post_body=self.body, add_bodyhash=self.body_hash)
class TextRpcRequest(Request):
""" Represents an RPC request which is not configured with parameters,
but
=======================================
--- /trunk/tests/run_online_tests.py Wed Oct 7 16:44:57 2009
+++ /trunk/tests/run_online_tests.py Fri Nov 13 11:29:29 2009
@@ -24,12 +24,14 @@
import opensocial_tests.partuza_test
import opensocial_tests.oauth_test
import opensocial_tests.google_sandbox_test
+import opensocial_tests.myspace09_test
def RunOnlineTests():
test_runner = module_test_runner.ModuleTestRunner()
test_runner.modules = [
opensocial_tests.orkut_test,
opensocial_tests.myspace_test,
+ opensocial_tests.myspace09_test,
opensocial_tests.partuza_test,
opensocial_tests.oauth_test,
opensocial_tests.google_sandbox_test,