def get(self, message_id): message = db.get_message_from_id(int(message_id)) if not message: self.send_error(404) return if not (message['public'] or db.in_contacts(self.get_user_id(), message['recipients'])): self.send_error(403) return if int(message['visible_on']) < time.time(): self.render('templates/message_detail_locked.html', message=message, replies=db.get_replies(message['id']), user=self.get_current_user())
def test_create_reply(self): with mock_message() as message: with mock_user() as reply_user: reply_content = random_string(1000) now = datetime.now() reply_id = db.create_reply( sender_email=reply_user['email'], message_id=message['message_id'], content=reply_content) replies = db.get_replies(message['message_id']) self.assertTrue(replies) reply = replies[0] self.assertEqual(reply['content'], reply_content) self.assertTrue(reply['created_on'] >= now)