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])
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])
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))
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:])
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:])
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))