def change_cross_section(self): for cross_part in chain.from_iterable( iter(self.env.setup["cross"].values())): for _id, _port_id in grouper(cross_part, 2): if _id in self.tg.tgs: # Change cross part using new TG id and port id tg_id = self.tg.id try: port_id = self.tg.get_port_id(_id, _port_id) except ValueError as err: self.class_logger.info( "Port is not in TG ports: {}".format(err)) raise custom_exceptions.TAFCoreException( "Check setup file") cross_part[cross_part.index(_id)] = tg_id cross_part[cross_part.index(tg_id) + 1] = port_id break
def test_grouper_bigger(self): assert list(helpers.grouper('ABCDEFG', 200)) == [('A', 'B', 'C', 'D', 'E', 'F', 'G')]
def test_grouper_empty(self): assert list(helpers.grouper('', 3)) == []
def test_grouper_negative(self): with pytest.raises(ValueError): list(helpers.grouper('ABCDEFG', -1)) == []
def test_grouper_1(self): assert list(helpers.grouper('ABCDEFG', 1)) == [('A', ), ('B', ), ('C', ), ('D', ), ('E', ), ('F', ), ('G', )]
def test_grouper_3(self): assert list(helpers.grouper('ABCDEFG', 3)) == [('A', 'B', 'C'), ('D', 'E', 'F'), ('G', )]