def test_add_message_reply(self): data = self.build_data() new_id = message.add_message(data) data["parent_id"] = new_id second_id = message.add_message(data) new_message = Message.query.filter_by(id=new_id).first() self.assertTrue(new_message.replies[0].id == second_id)
def test_mark_all_read_message(self): data = self.build_data() new_id = message.add_message(data) second_id = message.add_message(data) message.mark_all_read(1) new_message = Message.query.filter_by(id=new_id).first() second_message = Message.query.filter_by(id=second_id).first() self.assertTrue(new_message.message_read == True) self.assertTrue(second_message.message_read == True)
def test_mark_read_message(self): data = self.build_data() new_id = message.add_message(data) second_id = message.add_message(data) message.update_read_status(new_id, True, 1) new_message = Message.query.filter_by(id=new_id).first() second_message = Message.query.filter_by(id=second_id).first() self.assertTrue(new_message.message_read == True) self.assertTrue(second_message.message_read == False)
def add_message(): user_id = auth.auth_from_data(request) if user_id > 0: if user_logic.in_blocklist(user_id, request.json['to_user']): responseObject = { 'status': 'failure', 'message': 'Cannot message user who has you blocked.' } return make_response(jsonify(responseObject), 403) request.json['from_user'] = user_id return json.dumps(message.add_message(request.json)) else: abort(400)
def test_delete_message(self): data = self.build_data() new_id = message.add_message(data) message.delete_message(new_id, 1) self.assertTrue(len(Message.query.all()) == 0)
def test_add_message(self): data = self.build_data() new_id = message.add_message(data) new_message = Message.query.filter_by(id=new_id).first() self.assertTrue(new_message.message_subject == "test")
def test_delete_message(self): data = self.build_data() new_id = message.add_message(data) message.delete_message(new_id, 1) self.assertTrue(len( Message.query.all()) == 0)