def setUp(self): self.delivery = IODelivery() self.device1 = Mock() self.device2 = Mock() self.device3 = Mock() self.delivery.newDevice(self.device1) # Impresora self.delivery.newDevice(self.device2) # Pantalla print(self.delivery.numberOfDevices())
def testReplaceValueForSameKey(self): td = _Dict() obj = {} mock1 = Mock(None) mock2 = Mock(None) td[obj] = mock1 td[obj] = mock2 assert td.pop(obj) == mock2 with pytest.raises(KeyError): td.pop(obj)
def setUp(self): self.comparator = lambda pcb1, pcb2: pcb1.getPriority( ) > pcb2.getPriority() # the greater, the better self.semaphore = Mock() self.myCpu = Mock() self.queue = OwnHeap(self.semaphore, self.comparator) self.myScheduler = Scheduler(self.myCpu, self.queue, 1, self.semaphore) # Priority Round Robin self.highPriorityPCB = PCB(1, 1, 5, 10) self.higherPriorityPCB = PCB(1, 1, 5, 15) self.lowPriorityPCB = PCB(2, 6, 5, 1) self.queue.put(self.highPriorityPCB) self.queue.put(self.higherPriorityPCB) self.queue.put(self.lowPriorityPCB)
def testIterValues(self): td = _Dict() obj = {} mock = Mock(None) td[obj] = mock assert td.values() == [mock]
def testGetValueForKey(self): td = _Dict() obj = {} mock = Mock(None) td[obj] = mock assert td.get(obj) == mock
def testClear(self): td = _Dict() obj = {} mock = Mock(None) td[obj] = mock td.clear() assert td.get(obj) is None
def testPopKey(self): td = _Dict() obj = {} mock = Mock(None) td[obj] = mock assert td.pop(obj) == mock assert td.get(obj) is None
def test_when_new_instruction_puts_the_data_in_the_expected_device_queue( self): self.data = Mock() # ARRANGE self.cod = 0 # CODIGO CORRESPONDIENTE A LA IMPRESORA self.delivery.putInQueue(self.data, self.cod) # ACT self.assertEquals(self.delivery.numberOfInstructions(self.cod), 1)
def setUp(self): self.memory = RAM(65535) self.mmu = MMU(1, self.memory) self.scheduler = Mock() self.hdd = Mock() self.queue = Mock() self.interruptor2 = Mock() self.interruptor = Mock() self.logger = Mock() self.semaphore = RLock() self.cpu = CPU(self.memory, self.interruptor, self.semaphore, self.mmu) self.cpu.setLogger(self.logger) self.clock = Clock(self.cpu) self.mov = InstCPU("Matar a Flanders") self.Instruction2 = InstCPU("Y Tambien A Selma") self.instructionIO = InstIO("Soy de IO", 0) self.memory.putDir(0, self.mov) self.memory.putDir(1, self.Instruction2) self.memory.putDir(2, self.instructionIO) page0 = Page(0) page1 = Page(1) page2 = Page(2) page0.changeMemoryFlag() page1.changeMemoryFlag() page2.changeMemoryFlag() self.aPcb = PCB(0, [page0, page1, page2], 3, 4, 1, [Page(123)])
def setUp(self): self.disco = Mock() self.mmu = Mock() self.coladeprocesos = Mock() self.ram = RAM(65534) self.mmuReal = MMU(1, self.ram) self.mmuReal2 = MMU(2, self.ram) self.progLoader = ProgramLoader(self.ram, self.disco, self.coladeprocesos, self.mmu) self.progLoader2 = ProgramLoader(self.ram, self.disco, self.coladeprocesos, self.mmuReal) self.progLoader3 = ProgramLoader(self.ram, self.disco, self.coladeprocesos, self.mmuReal2) # Preparando un programa de dos (2) instrucciones self.instruccion1 = InstCPU("2+2") self.instruccion2 = InstIO("Leer de teclado", 2) self.program = Program("prog") self.program.addInstruction(self.instruccion1) self.program.addInstruction(self.instruccion2)
def setUp(self): self.scheduler = Mock() self.cpu = Mock() self.disco = Mock() self.condition = Mock() self.pcbTable = Mock() self.iodelivery = Mock() self.ram = Mock() self.aPCB = Mock() when(self.pcbTable).getPCB(0).thenReturn(self.aPCB) self.cod = 4 self.data = [self.aPCB, self.cod] self.imanager = InterruptorManager(self.ram, self.scheduler, self.disco, self.iodelivery, self.condition, self.pcbTable)
def testAssignKeyValuePair(self): td = _Dict() obj = {} mock = Mock(None) td[obj] = mock