Exemplo n.º 1
0
	def test_publish_with_custom_realm1(self):
		pc = PubControlTestClass()
		fanout._pubcontrols[('realm2', 'key==2', False)] = pc
		fanout.publish('channel', 'item', realm='realm2',
				key='key==2', ssl=False)
		self.assertEqual(pc.publish_channel, 'channel')
		self.assertEqual(pc.publish_item.export(), 
				Item(fanout.JsonObjectFormat('item')).export())
		self.assertEqual(pc.publish_blocking, False)
Exemplo n.º 2
0
	def test_publish(self):
		fanout.realm = 'realm'
		fanout.key = 'key=='
		fanout.ssl = True
		pc = PubControlTestClass()
		fanout._pubcontrols[('realm', 'key==', True)] = pc
		fanout.publish('channel', 'item')
		self.assertEqual(pc.publish_channel, 'channel')
		self.assertEqual(pc.publish_item.export(), 
				Item(fanout.JsonObjectFormat('item')).export())
		self.assertEqual(pc.publish_blocking, False)
Exemplo n.º 3
0
	def test_publish_with_callback(self):
		self.has_callback_been_called = False
		fanout.realm = 'realm'
		fanout.key = 'key=='
		fanout.ssl = True
		pc = PubControlTestClass()
		fanout._pubcontrols[('realm', 'key==', True)] = pc
		fanout.publish('channel', 'item', 'id', 'prev-id', False,
				self.callback_for_testing)
		self.assertEqual(pc.publish_channel, 'channel')
		self.assertEqual(pc.publish_item.export(),
				Item(fanout.JsonObjectFormat('item'), 'id', 'prev-id').export())
		self.assertEqual(pc.publish_blocking, False)
		pc.publish_callback(False, 'error')
		self.assertTrue(self.has_callback_been_called)