Пример #1
0
    def test_channel_addChat_method_fails_wrong_args(self):
        """ ensure that the method works as expected"""
        channel2 = PublicChannel(name='channel2')
        channel2.save()

        badchat = {"sender": "joe", "message": "this is message", "rando": 32}

        # will cause error and decorator shall handle it
        channel2.addChat(**badchat)
Пример #2
0
    def test_channel_getchannels_method(self):
        """ ensure that the method works as expected"""

        second = PublicChannel(name='second')
        second.save()

        self.assertEqual(2, len(PublicChannel.getchannels()))
        second.delete()
        self.assertEqual(1, len(PublicChannel.getchannels()))
        self.assertEqual(self.channel1.name, PublicChannel.getchannels()[0])
Пример #3
0
    def test_channel_getChats_method(self):
        """ ensure that the method works as expected"""
        numberofchats = 5

        channel2 = PublicChannel(name='channel2')
        channel2.save()

        for i in range(numberofchats):
            channel2.addChat(**{"sender": "joe", "message": "this is message"})

        self.assertEqual(numberofchats, len(channel2.getChats()))
Пример #4
0
    def test_channel_getlastchat_method(self):
        """ ensure that the method works as expected"""

        channel2 = PublicChannel(name='channel2')
        channel2.save()

        chat1 = {"sender": "joe", "message": "this is message"}
        chat2 = {"sender": "jim", "message": "this is other message"}
        channel2.addChat(**chat1)
        channel2.addChat(**chat2)

        lastchat = channel2.getlastchat()
        lastchat.pop("date")
        self.assertEqual(chat2, lastchat)
Пример #5
0
    def test_channel_addChat_method(self):
        """ ensure that the method works as expected"""
        channel2 = PublicChannel(name='channel2')
        channel2.save()

        chat = {"sender": "joe", "message": "this is message"}
        channel2.addChat(**chat)

        self.assertIsNotNone(channel2.chats)
        recievedchat = channel2.chats[0]

        self.assertEqual(
            {
                "sender": recievedchat.sender,
                "message": recievedchat.message
            }, chat)