Exemple #1
0
 def test_new_duplicate_room_creation(self):
     room = models.Room()
     room.name = 'some room'
     room.slug = 'slug'
     room.save()
     vals = {'name': 'some room'}
     self.forms.set(vals)
     out = views.room_new_do()
     self.assertIn('already exist', out)
Exemple #2
0
    def test_view_part(self):
        room = models.Room()
        room.name = 'room name'
        room.slug = 'foo-bar'
        room.save()
        room.add(self.user)

        with self.assertRaises(HTTPResponse):
            views.room_part(room.get_id(), room.slug)
Exemple #3
0
    def test_slug(self):
        room = models.Room()
        room.name = ''
        room.slug = 'foo bar baz'
        room.topic = 'topic'
        room.date_created = 0
        room.deleted = 0
        room.language = 'language'

        self.assertEqual(room.to_row()['slug'], 'foo-bar-baz')
Exemple #4
0
    def test_user_joins_recent_room_on_index(self):
        room = models.Room()
        room.name = 'some room'
        room.slug = 'slug'
        room.save()

        room.add(self.user)
        # We just guess this is a redirect.
        # TODO: Improve test to be more specific
        with self.assertRaises(HTTPResponse):
            views.index()
Exemple #5
0
def create_test_room():
    room = models.Room()
    room.name = 'Some room'
    room.slug = 'Some room'
    room.topic = 'topic'
    room.date_created = datetime.datetime(2005,
                                          4,
                                          5,
                                          hour=12,
                                          minute=30,
                                          second=0)
    room.deleted = False
    room.language = 'nb_no'
    return room
Exemple #6
0
    def test_view_say(self):
        room = models.Room()
        room.name = 'room name'
        room.slug = 'foo-bar'
        room.save()
        room.add(self.user)

        vals = {'message': 'some-message', 'client_id': 'foo'}
        self.forms.set(vals)

        views.room_say(room.get_id(), room.slug)

        self.assertEqual(len(room.get_messages()), 1)
        self.assertEqual(room.get_messages()[0].content, 'some-message')
        self.assertEqual(room.get_messages()[0].get_owner().get_id(),
                         self.user.get_id())
Exemple #7
0
    def test_view_rooms(self):
        room = models.Room()
        room.name = 'room name'
        room.slug = 'foo-bar'
        room.topic = 'topic'
        room.save()

        message = models.Message()
        message.content = 'some message'
        message.save()
        self.user.add(message)
        room.add(message)

        out = views.room(room.get_id(), room.slug)
        self.assertIn(room.name, out)
        self.assertIn(message.content, out)
Exemple #8
0
    def test_messages_from(self):
        room = models.Room()
        room.name = 'room name'
        room.slug = 'foo-bar'
        room.save()

        message1 = models.Message()
        message1.content = 'first'
        message1.save()
        self.user.add(message1)
        room.add(message1)

        message2 = models.Message()
        message2.content = 'second'
        message2.save()
        self.user.add(message2)
        room.add(message2)

        out = views.messages_from(room.get_id(), room.slug, 1)
        self.assertIn(message2.content, out)
        self.assertNotIn(message1.content, out)