예제 #1
0
    async def test_first_message(self):
        message = self.create_message(1)
        request = await self.client.post(
            '/push-message',
            data=diary_pb2.PushMessageRequest(
                account_id=1,
                message=protobuf.from_message(message),
                diary_size=100).SerializeToString())
        await self.check_answer(request, diary_pb2.PushMessageResponse)

        diary = await operations.load_diary(1)

        self.assertEqual(list(diary.messages()), [message])
예제 #2
0
    async def test_second_message(self):
        message_1 = self.create_message(1)
        request = await self.client.post(
            "/push-message",
            data=diary_pb2.PushMessageRequest(
                account_id=1, message=protobuf.from_message(message_1), diary_size=100
            ).SerializeToString(),
        )
        await self.check_answer(request, diary_pb2.PushMessageResponse)

        message_2 = self.create_message(2)
        request = await self.client.post(
            "/push-message",
            data=diary_pb2.PushMessageRequest(
                account_id=1, message=protobuf.from_message(message_2), diary_size=100
            ).SerializeToString(),
        )
        await self.check_answer(request, diary_pb2.PushMessageResponse)

        diary = await operations.load_diary(1)

        self.assertEqual(list(diary.messages()), [message_1, message_2])
예제 #3
0
    async def test_has_diary(self):
        for i in range(21):
            message = self.create_message(i)
            request = await self.client.post(
                "/push-message",
                data=diary_pb2.PushMessageRequest(
                    account_id=1, message=protobuf.from_message(message), diary_size=20
                ).SerializeToString(),
            )
            await self.check_answer(request, diary_pb2.PushMessageResponse)
            await request.release()

        diary = await operations.load_diary(1)

        request = await self.client.post("/diary", data=diary_pb2.DiaryRequest(account_id=1).SerializeToString())
        data = await self.check_answer(request, diary_pb2.DiaryResponse)
        self.assertEqual(data.diary, protobuf.from_diary(diary))
예제 #4
0
    async def test_message_overflow(self):
        messages = []

        for i in range(21):
            message = self.create_message(i)
            request = await self.client.post(
                '/push-message',
                data=diary_pb2.PushMessageRequest(
                    account_id=1,
                    message=protobuf.from_message(message),
                    diary_size=20).SerializeToString())
            await self.check_answer(request, diary_pb2.PushMessageResponse)
            await request.release()
            messages.append(message)

        diary = await operations.load_diary(1)

        self.assertEqual(list(diary.messages()), messages[1:])
예제 #5
0
    async def test_message_overflow(self):
        messages = []

        for i in range(21):
            message = self.create_message(i)
            request = await self.client.post(
                "/push-message",
                data=diary_pb2.PushMessageRequest(
                    account_id=1, message=protobuf.from_message(message), diary_size=20
                ).SerializeToString(),
            )
            await self.check_answer(request, diary_pb2.PushMessageResponse)
            await request.release()
            messages.append(message)

        diary = await operations.load_diary(1)

        self.assertEqual(list(diary.messages()), messages[1:])
예제 #6
0
    async def test_has_diary(self):
        for i in range(21):
            message = self.create_message(i)
            request = await self.client.post(
                '/push-message',
                data=diary_pb2.PushMessageRequest(
                    account_id=1,
                    message=protobuf.from_message(message),
                    diary_size=20).SerializeToString())
            await self.check_answer(request, diary_pb2.PushMessageResponse)
            await request.release()

        diary = await operations.load_diary(1)

        request = await self.client.post(
            '/diary',
            data=diary_pb2.DiaryRequest(account_id=1).SerializeToString())
        data = await self.check_answer(request, diary_pb2.DiaryResponse)
        self.assertEqual(data.diary, protobuf.from_diary(diary))