# Path: rtpmidi/engines/midi/list_circ.py
# class ListCirc(object):
# 
# 	def __init__(self, listeSize):
# 		self.index = 0
# 		self.list = []
# 		self.round = 0
# 		self.listeSize = listeSize
# 
# 	def to_list(self, note):
# 		if self.round == 1:
# 			self._replace_note(note)
# 		else:
# 			self._add_note(note)
# 
# 	def _add_note(self, note):
# 		self.list.append(note)
# 
# 		if self.index == self.listeSize-1:
# 			self.round = 1
# 			self.index = 0
# 		else:
# 			self.index += 1
# 
# 	def _replace_note(self, note):
# 		if (self.index == self.listeSize):
# 			self.index = 0
# 			self.list[self.index] = note
# 		else:
# 			self.list[self.index] = note
# 		self.index += 1
# 
# 	def flush(self):
# 		self.list = []
# 		self.round = 0
# 		self.index = 0
# 
#     	def __getitem__(self,key):
#         	return self.list[key]
# 
# 	def __len__(self):
# 		return len(self.list)
# 
# class PacketCirc(ListCirc):
# 
# 	#Recupere une note avec son compteur (numero)
# 	def find_packet(self, seqNo):
# 		"""Return emplacement of selected packet index the list"""
# 		res = -1
# 
# 		for i in range(len(self.list)):
# 			if (self.list[i].seqNo == seqNo):
# 				res = i
# 				break
# 
# 		return res
# 
# 	def get_packets(self, checkpoint, act_seq ):
# 		"""Get packets from checkpoint to act seq
# 		this function is for simplify create_recovery_journal"""
# 		midi_cmd = []
# 		#getting pos of element
# 		checkpoint_pos = self.find_packet(checkpoint)
# 		act_seq_pos = self.find_packet(act_seq)
# 
# 		#Take care of wrap around in seqNo
# 
# 		if checkpoint >= act_seq:
# 			if checkpoint_pos < act_seq_pos:
# 				midi_cmd = self.list[checkpoint_pos+1:act_seq_pos+1]
# 			else:
# 				#getting checkpoint -> 0
# 				midi_cmd = self.list[checkpoint_pos+1:]
# 
#                                 #getting 0 -> act_seq
# 				midi_cmd += self.list[:act_seq_pos+1]
# 		else:
# 			#getting checkpoint -> act_seq
# 			[midi_cmd.append(self.list[i]) \
# 				 for i in range(len(self.list)) \
# 				 if self.list[i].seqNo > checkpoint and \
# 				 self.list[i].seqNo <= act_seq]
# 
# 
# 		return midi_cmd
# 
# Path: rtpmidi/engines/midi/midi_object.py
# class OldPacket(object):
# 
#     def __init__(self, seqNo, packet, marker=0):
#         self.seqNo = seqNo
#         self.packet = packet
#         self.marker = marker


from twisted.trial.unittest import TestCase
from rtpmidi.engines.midi.list_circ import ListCirc, PacketCirc
from rtpmidi.engines.midi.midi_object import OldPacket
                assert(midi_cmd_notes[j][1]== iterator + j), \
                    self.fail("Problem with midi cmd content")

    def test_get_packets_1_1(self):
        """Packet Circ Testing get packet (case: checkpoint > act_seq with wrap around)"""
        #TestCase 1.1
        checkpoint = 8
        act_seq = 1

        #Adapting list
        self.packet_circ.flush()

        #listto test the packet list
        plist = [[[192, 120, 100],0],[[144, 104, 50],1], [[145, 110, 0],2], \
                     [[145, 112, 0],3], [[144, 124, 50],4], \
                     [[145, 114, 0],5], [[145, 12, 0],6]]

        #Create the gap
        empty_list = []
        for i in range(8):
            packy = OldPacket(i, [], 0)
            #Adding packet to list
            self.packet_circ.to_list(packy)

        #fulling the list
        for i in range(10):
            #modify plist for each packet
            plist_1 = [ [[plist[j][0][0], plist[j][0][1], plist[j][0][2]], \
                           plist[j][1] + i] for j in range(len(plist)) ]


# Path: rtpmidi/engines/midi/list_circ.py
# class ListCirc(object):
# 
# 	def __init__(self, listeSize):
# 		self.index = 0
# 		self.list = []
# 		self.round = 0
# 		self.listeSize = listeSize
# 
# 	def to_list(self, note):
# 		if self.round == 1:
# 			self._replace_note(note)
# 		else:
# 			self._add_note(note)
# 
# 	def _add_note(self, note):
# 		self.list.append(note)
# 
# 		if self.index == self.listeSize-1:
# 			self.round = 1
# 			self.index = 0
# 		else:
# 			self.index += 1
# 
# 	def _replace_note(self, note):
# 		if (self.index == self.listeSize):
# 			self.index = 0
# 			self.list[self.index] = note
# 		else:
# 			self.list[self.index] = note
# 		self.index += 1
# 
# 	def flush(self):
# 		self.list = []
# 		self.round = 0
# 		self.index = 0
# 
#     	def __getitem__(self,key):
#         	return self.list[key]
# 
# 	def __len__(self):
# 		return len(self.list)
# 
# class PacketCirc(ListCirc):
# 
# 	#Recupere une note avec son compteur (numero)
# 	def find_packet(self, seqNo):
# 		"""Return emplacement of selected packet index the list"""
# 		res = -1
# 
# 		for i in range(len(self.list)):
# 			if (self.list[i].seqNo == seqNo):
# 				res = i
# 				break
# 
# 		return res
# 
# 	def get_packets(self, checkpoint, act_seq ):
# 		"""Get packets from checkpoint to act seq
# 		this function is for simplify create_recovery_journal"""
# 		midi_cmd = []
# 		#getting pos of element
# 		checkpoint_pos = self.find_packet(checkpoint)
# 		act_seq_pos = self.find_packet(act_seq)
# 
# 		#Take care of wrap around in seqNo
# 
# 		if checkpoint >= act_seq:
# 			if checkpoint_pos < act_seq_pos:
# 				midi_cmd = self.list[checkpoint_pos+1:act_seq_pos+1]
# 			else:
# 				#getting checkpoint -> 0
# 				midi_cmd = self.list[checkpoint_pos+1:]
# 
#                                 #getting 0 -> act_seq
# 				midi_cmd += self.list[:act_seq_pos+1]
# 		else:
# 			#getting checkpoint -> act_seq
# 			[midi_cmd.append(self.list[i]) \
# 				 for i in range(len(self.list)) \
# 				 if self.list[i].seqNo > checkpoint and \
# 				 self.list[i].seqNo <= act_seq]
# 
# 
# 		return midi_cmd
# 
# Path: rtpmidi/engines/midi/midi_object.py
# class OldPacket(object):
# 
#     def __init__(self, seqNo, packet, marker=0):
#         self.seqNo = seqNo
#         self.packet = packet
#         self.marker = marker


# Path: rtpmidi/test/test_listcirc.py
from twisted.trial.unittest import TestCase
from rtpmidi.engines.midi.list_circ import ListCirc, PacketCirc
from rtpmidi.engines.midi.midi_object import OldPacket

                assert(midi_cmd_notes[j][1]== iterator + j), \
                    self.fail("Problem with midi cmd content")

    def test_get_packets_1_1(self):
        """Packet Circ Testing get packet (case: checkpoint > act_seq with wrap around)"""
        #TestCase 1.1
        checkpoint = 8
        act_seq = 1

        #Adapting list
        self.packet_circ.flush()

        #listto test the packet list
        plist = [[[192, 120, 100],0],[[144, 104, 50],1], [[145, 110, 0],2], \
                     [[145, 112, 0],3], [[144, 124, 50],4], \
                     [[145, 114, 0],5], [[145, 12, 0],6]]

        #Create the gap
        empty_list = []
        for i in range(8):
            packy = OldPacket(i, [], 0)
            #Adding packet to list
            self.packet_circ.to_list(packy)

        #fulling the list
        for i in range(10):
            #modify plist for each packet
            plist_1 = [ [[plist[j][0][0], plist[j][0][1], plist[j][0][2]], \
                           plist[j][1] + i] for j in range(len(plist)) ]


            packy = OldPacket(i, plist_1, 0)