def test_slotframe_set_length_without_cells(sim_engine): """ Test if we can change the slotframe length when no cells are allocated """ sim_engine = sim_engine() # need for log slotframe = SlotFrame(None, 1, 101) # decrease the slotframe length new_length = 50 slotframe.set_length(new_length) assert slotframe.length == new_length # increase the slotframe length new_length = 150 slotframe.set_length(new_length) assert slotframe.length == new_length
def test_slotframe_set_length_with_cells(sim_engine): """ Test if we can change the slotframe length when cells are allocated """ sim_engine = sim_engine() # need for log neighbor_mac_addr_1 = 'test_mac_addr_1' neighbor_mac_addr_2 = 'test_mac_addr_2' slotframe = SlotFrame(None, 1, 101) # create cells cell_0 = Cell(0, 0, [d.CELLOPTION_TX], neighbor_mac_addr_1) cell_70 = Cell(70, 0, [d.CELLOPTION_TX], neighbor_mac_addr_2) cells = [cell_0, cell_70] # add cells to slotframe for c in cells: slotframe.add(c) # decrease the slotframe length assert len(slotframe.get_busy_slots()) == len(cells) new_length = 50 slotframe.set_length(new_length) assert slotframe.length == new_length assert len(slotframe.get_busy_slots() ) == len(cells) - 1 # make sure cell is delete # make sure we cannot add a cell after new length with pytest.raises(Exception): slotframe.add(cell_70) # increase the slotframe length new_length = 150 slotframe.set_length(new_length) assert slotframe.length == new_length assert len(slotframe.get_busy_slots( )) == len(cells) - 1 # make sure we have the right amount of cells