Ever since upgrading to Google App Engine SDK version 1.8.2 we've been having an issue with one of our Channel API related unit tests.

Here's the skinny.

We have a handler that creates a channel and returns the channel ID as well as the channel token. That handler looks something like:

import json from uuid import uuid4 from google.appengine.api.channel import channel import webapp2 class ChannelSubscriptionHandler(webapp2.RequestHandler): def get(self): self.response.headers['Context-Type'] = 'application/json' channel_id = str(uuid4()) token = channel.create_channel(channel_id) self.response.write(json.dumps({ 'channel_id': channel_id, 'token': token })) app = webapp2.WSGIApplication([ ('/channel_subscription/', ChannelSubscriptionHandler) ], debug=True)

Nothing crazy going on, just creating a channel and returning the particulars.

Then we have a unit test the exercises the handler code that looks like:

import json from unittest import TestCase from google.appengine.api.channel import channel from google.appengine.ext.testbed import Testbed from webtest import TestApp import example_channel_api_handler class ChannelSubscriptionHandlerTests(TestCase): def setUp(self): self.testbed = Testbed() self.testbed.activate() self.testbed.init_channel_stub() self.channel_stub = self.testbed.get_stub('channel') self.app = TestApp(example_channel_api_handler.app) def test_can_get_channel_subscription(self): response = self.app.get('/channel_subscription/', status=200) data = json.loads(response.body) token = data.get('token', None) channel_id = data.get('channel_id', None) self.assertIsNotNone(token) self.assertIsNotNone(channel_id) self.channel_stub.connect_channel(token) channel.send_message(channel_id, 'Hello World') self.assertEquals(['Hello World'], self.channel_stub.get_channel_messages(token))

Like I said above, up until version 1.8.2 of the GAE SDK the above test worked like a charm. I scanned the release notes for the latest release and did see some Channel API related stuff, but it didn't look like it applied to the issue that I'm having.

Also, the above code isn't really from the application that I'm working on, but it replicates the issue as I have described it.

Finally, it doesn't appear that the application is broken in production, it's like this issue revolves around the testbed for the Channel API.

Thanks for reading.