# Path: src/lifeRaft/boards/memory_board.py
# class MemoryBoard(Board):
# 
#     def __init__(self):
#         Board.__init__(self)
#         self._board = []
# 
#     def post_message(self, message):
#         self._board.append(message)
# 
#         self._board = sorted(self._board,
#                              key=lambda a: a.timestamp, reverse=True)
# 
#     def get_message(self):
#         if(len(self._board) > 0):
#             return self._board.pop()
#         else:
#             return None
# 
# Path: src/lifeRaft/messages/base.py
# class BaseMessage(object):
#     AppendEntries = 0
#     RequestVote = 1
#     RequestVoteResponse = 2
#     Response = 3
# 
#     def __init__(self, sender, receiver, term, data):
#         self._timestamp = int(time.time())
# 
#         self._sender = sender
#         self._receiver = receiver
#         self._data = data
#         self._term = term
# 
#     @property
#     def receiver(self):
#         return self._receiver
# 
#     @property
#     def sender(self):
#         return self._sender
# 
#     @property
#     def data(self):
#         return self._data
# 
#     @property
#     def timestamp(self):
#         return self._timestamp
# 
#     @property
#     def term(self):
#         return self._term
# 
#     @property
#     def type(self):
#         return self._type


import unittest
from ..boards.memory_board import MemoryBoard
from ..messages.base import BaseMessage


class TestMemoryBoard( unittest.TestCase ):

	def setUp( self ):
		self.board = MemoryBoard()

	def test_memoryboard_post_message( self ):

		msg = BaseMessage( 0, 0, 0, 0 )	
		self.board.post_message( msg )
		self.assertEquals( msg, self.board.get_message() )

	def test_memoryboard_post_message_make_sure_they_are_ordered( self ):

		msg = BaseMessage( 0, 0, 0, 0 )

# Path: src/lifeRaft/boards/memory_board.py
# class MemoryBoard(Board):
# 
#     def __init__(self):
#         Board.__init__(self)
#         self._board = []
# 
#     def post_message(self, message):
#         self._board.append(message)
# 
#         self._board = sorted(self._board,
#                              key=lambda a: a.timestamp, reverse=True)
# 
#     def get_message(self):
#         if(len(self._board) > 0):
#             return self._board.pop()
#         else:
#             return None
# 
# Path: src/lifeRaft/messages/base.py
# class BaseMessage(object):
#     AppendEntries = 0
#     RequestVote = 1
#     RequestVoteResponse = 2
#     Response = 3
# 
#     def __init__(self, sender, receiver, term, data):
#         self._timestamp = int(time.time())
# 
#         self._sender = sender
#         self._receiver = receiver
#         self._data = data
#         self._term = term
# 
#     @property
#     def receiver(self):
#         return self._receiver
# 
#     @property
#     def sender(self):
#         return self._sender
# 
#     @property
#     def data(self):
#         return self._data
# 
#     @property
#     def timestamp(self):
#         return self._timestamp
# 
#     @property
#     def term(self):
#         return self._term
# 
#     @property
#     def type(self):
#         return self._type


# Path: src/lifeRaft/tests/test_MemoryBoard.py
import unittest
from ..boards.memory_board import MemoryBoard
from ..messages.base import BaseMessage



class TestMemoryBoard( unittest.TestCase ):

	def setUp( self ):
		self.board = MemoryBoard()

	def test_memoryboard_post_message( self ):

		msg = BaseMessage( 0, 0, 0, 0 )	
		self.board.post_message( msg )
		self.assertEquals( msg, self.board.get_message() )

	def test_memoryboard_post_message_make_sure_they_are_ordered( self ):

		msg = BaseMessage( 0, 0, 0, 0 )

		msg2 = BaseMessage( 0, 0, 0, 0 )