def test_delete_gone(self): """Test that long polling subscribers get a 410 Gone response when the channel they were waiting on is deleted""" channel_id = 'delete_gone' self.execute( self.publisher('PUT', channel_id, cb=self.expect(200)), par( self.long_subscriber('GET', channel_id, cb=self.expect(410)), self.publisher('DELETE', channel_id, cb=self.expect(200)), ), )
def test_long_subscriber(self): """Test that a long polling subscriber will get a message as soon as it is available""" channel_id = 'long_subscriber' request_headers = [] def _pass_headers(status, headers, body): request_headers.append('If-Modified-Since: %s' % headers['Last-Modified']) request_headers.append('If-None-Match: %s' % headers['Etag']) self.execute( self.publisher('PUT', channel_id, cb=self.expect(200)), par( self.long_subscriber('GET', channel_id, cb=self.expect(200, (ct_textplain,), hello_world)), self.long_subscriber('GET', channel_id, cb=(self.expect(200, (ct_textplain,), hello_world), _pass_headers)), self.publisher('POST', channel_id, headers=(ct_textplain,), body=hello_world, cb=self.expect(201)), ), par( self.long_subscriber('GET', channel_id, headers=request_headers, cb=self.expect(200, (ct_textplain,), hello_world+'1')), self.long_subscriber('GET', channel_id, headers=request_headers, cb=(self.expect(200, (ct_textplain,), hello_world+'1'), _pass_headers)), self.publisher('POST', channel_id, headers=(ct_textplain,), body=hello_world+'1', cb=self.expect(201)), ), )
def test_post_subscribers(self): """Test thath publishers receive the right HTTP status code when posting a message, 201 when there was subscribers to whom the message has been sent to, 202 otherwise""" channel_id = 'post_subscribers' self.execute( self.publisher('PUT', channel_id, cb=self.expect(200)), par( self.long_subscriber('GET', channel_id, cb=self.expect(200)), self.long_subscriber('GET', channel_id, cb=self.expect(200)), self.publisher('POST', channel_id, headers=(ct_textplain,), cb=self.expect(201)), ), self.publisher('POST', channel_id, headers=(ct_textplain,), cb=self.expect(202)), )