Exemplo n.º 1
0
    def test_doesnt_send_to_blacklisted_connections(self):
        fake = Backend.objects.create(name='fake')
        connection1 = Connection.objects.create(identity="02022222220", backend=fake)

	Blacklist.objects.create(connection = connection1)
        broadcast("Happy New Year!")	

	self.assertFalse(Message.objects.filter(direction='O', status='Q', connection=connection1).exists())
Exemplo n.º 2
0
    def test_broadcasts_message_to_all(self):
        fake = Backend.objects.create(name='fake')
        connection1 = Connection.objects.create(identity="02022222220", backend=fake)
        connection2 = Connection.objects.create(identity="02022222221", backend=fake)

	text = "Happy New Year!"
        broadcast(text)	

	messages = Message.objects.filter(text=text, direction='O', status='Q').order_by('connection__identity')
	self.assertEquals([connection1, connection2], [m.connection for m in messages])
Exemplo n.º 3
0
    def test_doesnt_send_to_blacklisted_connections(self):
        fake = Backend.objects.create(name='fake')
        connection1 = Connection.objects.create(identity="02022222220",
                                                backend=fake)

        Blacklist.objects.create(connection=connection1)
        broadcast("Happy New Year!")

        self.assertFalse(
            Message.objects.filter(direction='O',
                                   status='Q',
                                   connection=connection1).exists())
Exemplo n.º 4
0
    def test_broadcasts_message_to_all(self):
        fake = Backend.objects.create(name='fake')
        connection1 = Connection.objects.create(identity="02022222220",
                                                backend=fake)
        connection2 = Connection.objects.create(identity="02022222221",
                                                backend=fake)

        text = "Happy New Year!"
        broadcast(text)

        messages = Message.objects.filter(
            text=text, direction='O',
            status='Q').order_by('connection__identity')
        self.assertEquals([connection1, connection2],
                          [m.connection for m in messages])
Exemplo n.º 5
0
 def handle(self, **options):
     text = options['text'] or raw_input('Text of the message: ')
     broadcast(text)
     self.stdout.write('Done!\n')