예제 #1
0
    def test_broadcast_message(self):
        user1 = get_user_model().objects.create_user("user1", "*****@*****.**", "123456")
        user2 = get_user_model().objects.create_user("user2", "*****@*****.**", "123456")
        user3 = get_user_model().objects.create_user("user3", "*****@*****.**", "123456")

        now = timezone.now() + timezone.timedelta(days=-1)
        url = 'http://example.com/error'
        broadcast_message(stored_messages.STORED_INFO, 'broadcast test message', 'extra', now, url)
        self.assertEqual(Inbox.objects.get(user=user1.id).message.message, "broadcast test message")
        self.assertEqual(Inbox.objects.get(user=user2.id).message.message, "broadcast test message")
        self.assertEqual(Inbox.objects.get(user=user3.id).message.message, "broadcast test message")

        self.assertEqual(Inbox.objects.get(user=user1.id).message.tags, 'extra')
        self.assertEqual(Inbox.objects.get(user=user2.id).message.tags, 'extra')
        self.assertEqual(Inbox.objects.get(user=user3.id).message.tags, 'extra')

        self.assertEqual(Inbox.objects.get(user=user1.id).message.date, now)
        self.assertEqual(Inbox.objects.get(user=user2.id).message.date, now)
        self.assertEqual(Inbox.objects.get(user=user3.id).message.date, now)

        self.assertEqual(Inbox.objects.get(user=user1.id).message.url, url)
        self.assertEqual(Inbox.objects.get(user=user2.id).message.url, url)
        self.assertEqual(Inbox.objects.get(user=user3.id).message.url, url)

        self.assertEqual(MessageArchive.objects.get(user=user1.id).message.message,
                         "broadcast test message")
        self.assertEqual(MessageArchive.objects.get(user=user2.id).message.message,
                         "broadcast test message")
        self.assertEqual(MessageArchive.objects.get(user=user3.id).message.message,
                         "broadcast test message")
예제 #2
0
    def test_broadcast_message(self):
        user1 = get_user_model().objects.create_user("user1", "*****@*****.**",
                                                     "123456")
        user2 = get_user_model().objects.create_user("user2", "*****@*****.**",
                                                     "123456")
        user3 = get_user_model().objects.create_user("user3", "*****@*****.**",
                                                     "123456")

        now = timezone.now() + timezone.timedelta(days=-1)
        url = 'http://example.com/error'
        broadcast_message(stored_messages.STORED_INFO,
                          'broadcast test message', 'extra', now, url)

        self.assertEqual(
            Inbox.objects.get(user=user1.id).message.message,
            "broadcast test message")
        self.assertEqual(
            Inbox.objects.get(user=user2.id).message.message,
            "broadcast test message")
        self.assertEqual(
            Inbox.objects.get(user=user3.id).message.message,
            "broadcast test message")

        #self.assertEqual(Inbox.objects.get(user=user1.id).message.tags, 'extra')
        #self.assertEqual(Inbox.objects.get(user=user2.id).message.tags, 'extra')
        #self.assertEqual(Inbox.objects.get(user=user3.id).message.tags, 'extra')
        self.assertEqual(
            Inbox.objects.get(user=user1.id).message.tags,
            'extra persisted info')
        self.assertEqual(
            Inbox.objects.get(user=user2.id).message.tags,
            'extra persisted info')
        self.assertEqual(
            Inbox.objects.get(user=user3.id).message.tags,
            'extra persisted info')

        self.assertEqual(Inbox.objects.get(user=user1.id).message.date, now)
        self.assertEqual(Inbox.objects.get(user=user2.id).message.date, now)
        self.assertEqual(Inbox.objects.get(user=user3.id).message.date, now)

        self.assertEqual(Inbox.objects.get(user=user1.id).message.url, url)
        self.assertEqual(Inbox.objects.get(user=user2.id).message.url, url)
        self.assertEqual(Inbox.objects.get(user=user3.id).message.url, url)

        self.assertEqual(
            MessageArchive.objects.get(user=user1.id).message.message,
            "broadcast test message")
        self.assertEqual(
            MessageArchive.objects.get(user=user2.id).message.message,
            "broadcast test message")
        self.assertEqual(
            MessageArchive.objects.get(user=user3.id).message.message,
            "broadcast test message")
예제 #3
0
    def test_broadcast_message(self):
        user1 = get_user_model().objects.create_user("user1", "*****@*****.**", "123456")
        user2 = get_user_model().objects.create_user("user2", "*****@*****.**", "123456")
        user3 = get_user_model().objects.create_user("user3", "*****@*****.**", "123456")

        broadcast_message(stored_messages.STORED_INFO, "broadcast test message")
        self.assertEqual(Inbox.objects.get(user=user1.id).message.message, "broadcast test message")
        self.assertEqual(Inbox.objects.get(user=user2.id).message.message, "broadcast test message")
        self.assertEqual(Inbox.objects.get(user=user3.id).message.message, "broadcast test message")

        self.assertEqual(MessageArchive.objects.get(user=user1.id).message.message, "broadcast test message")
        self.assertEqual(MessageArchive.objects.get(user=user2.id).message.message, "broadcast test message")
        self.assertEqual(MessageArchive.objects.get(user=user3.id).message.message, "broadcast test message")
예제 #4
0
    def test_broadcast_message(self):
        user1 = get_user_model().objects.create_user("user1", "*****@*****.**", "123456")
        user2 = get_user_model().objects.create_user("user2", "*****@*****.**", "123456")
        user3 = get_user_model().objects.create_user("user3", "*****@*****.**", "123456")

        broadcast_message( stored_messages.STORED_INFO, 'broadcast test message')
        self.assertEqual(Inbox.objects.get(user=user1.id).message.message, "broadcast test message")
        self.assertEqual(Inbox.objects.get(user=user2.id).message.message, "broadcast test message")
        self.assertEqual(Inbox.objects.get(user=user3.id).message.message, "broadcast test message")

        self.assertEqual(MessageArchive.objects.get(user=user1.id).message.message,
                         "broadcast test message")
        self.assertEqual(MessageArchive.objects.get(user=user2.id).message.message,
                         "broadcast test message")
        self.assertEqual(MessageArchive.objects.get(user=user3.id).message.message,
                         "broadcast test message")
예제 #5
0
def BroadcastView(request):
    if request.method == 'GET':
        broadcast_message( stored_messages.STORED_INFO, 'This is a broadcast message from user: '******'Ok')