def _post_playlist(self): json = simplejson.dumps({ 'title': 'lopez', 'videos': [ { 'title': 'video1', 'videoId': 'z2Am3aLwu1E', }, ], }) form = 'json=' + json handler = PlaylistsHandler() handler.request = Request({ 'REQUEST_METHOD': 'POST', 'PATH_INFO': '/api/playlists', 'wsgi.input': StringIO(form), 'CONTENT_LENGTH': len(form), 'SERVER_NAME': 'hi', 'SERVER_PORT': '80', 'wsgi.url_scheme': 'http', }) handler.response = Response() handler.post() return handler.response.out.getvalue()
def test_get_playlists(self): self._post_playlist() playlists = [m for m in Playlist.all()] playlist_model = playlists[0] handler = PlaylistsHandler() handler.request = Request({ 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/api/playlists', 'SERVER_NAME': 'hi', 'SERVER_PORT': '80', 'wsgi.url_scheme': 'http', }) handler.response = Response() handler.get() response = handler.response.out.getvalue() response = simplejson.loads(response) self.failUnless(response[0]['title'] == 'lopez') self.failUnless(response[0]['remoteId'] == playlist_model.key().id())