示例#1
0
def test_list_messages_sender(database):
    user_hash_1 = User.create_user(2, 2, "Test user 1", database)
    user_hash_2 = User.create_user(3, 3, "Test user 2", database)
    assert len(Message.inspect_messages(user_hash_1, True, database)) == 0
    assert len(Message.inspect_messages(user_hash_2, True, database)) == 0
    Message.create_message(user_hash_1, user_hash_2, "HELLO", database)
    assert len(Message.inspect_messages(user_hash_1, True, database)) == 1
    assert len(Message.inspect_messages(user_hash_2, True, database)) == 0
示例#2
0
 def inspect_messages(self, is_sender, user_hash=None):
     self.user_validation()
     if user_hash is None:
         user_hash = self.user.character_hash
     messages = Message.inspect_messages(user_hash, is_sender,
                                         self.database)
     resulting_data = ""
     for message in messages:
         resulting_data += str(message) + '\n'
     if not messages:
         resulting_data = NO_MESSAGES_FOUND
     return resulting_data