예제 #1
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])
예제 #2
0
    def setUpClass(cls):
        super().setUpClass()

        cls.client = app.test_client()

        cls.user1 = HelperFunctions.createUser("Thomas", "tracce")
        cls.user2 = HelperFunctions.createUser("Tracee", "billy")

        cls.public1 = PublicChannel(name="General")
        cls.public1.save()
        cls.public2 = PublicChannel(name="random")
        cls.public2.save()

        # urls
        cls.client_url = "/client"
        cls.isChannelValid_url = "/isChannelValid"
        cls.getUsers_url = "/getAllUsers"
        cls.getChats_url = "/getChats"
예제 #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_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)
예제 #5
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)
예제 #6
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)
예제 #7
0
 def setUpClass(cls):
     super().setUpClass()
     cls.channel1 = PublicChannel(name='first')
     cls.channel1.save()