def test_block_batch_replace(self): t = Template() for x in xrange(10): t.add(Block(5, posx=x)) t.add(Block(431, posy=x)) t.add(Block(432, posx=3, posy=3, posz=3)) assert t.num_blocks() == 21 oranges = len(t.get_all_blocks(color='orange')) t.replace({'color': 'orange'}, {'color': 'blue'}) blues = t.get_all_blocks(color='blue') assert oranges == len(blues)
def test_block_query(self): t = Template() for x in xrange(10): t.add(Block(5, posx=x)) t.add(Block(431, posy=x)) t.add(Block(432, posx=3, posy=3, posz=3)) assert t.num_blocks() == 21 orange_blocks = t.get_all_blocks(color='orange') assert len(orange_blocks) == 11 orange_hulls = t.get_all_blocks(color='orange', shape=shape('block')) print[b.shape for b in orange_hulls] assert len(orange_hulls) == 10 orange_wedges = t.get_all_blocks(color='orange', shape=shape('wedge')) assert len(orange_wedges) == 1