示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
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)
示例#8
0
 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)
示例#9
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")
示例#10
0
 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)
示例#11
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")