def test_creates_a_new_drawing_with_layer_name_for_single_layer_drawing( self): drawing = a(validDrawing().withName('TheDrawing').withLayers( Layer('Layer1'))) drawings = drawing.split_stacked(self) assert_that( drawings, equal_to([ a(validDrawing().withName('TheDrawing-0-Layer1').withLayers( Layer('Layer1'))) ]))
def test_splits_into_drawings_named_after_the_layers_where_consecutive_drawings_add_a_layer( self): drawing = a(validDrawing().withName('TheDrawing').withLayers( Layer('Layer1'), Layer('Layer2'))) drawings = drawing.split_stacked(self) assert_that( drawings, equal_to([ a(validDrawing().withName('TheDrawing-0-Layer1').withLayers( Layer('Layer1'))), a(validDrawing().withName('TheDrawing-1-Layer2').withLayers( Layer('Layer1'), Layer('Layer2'))) ]))
def test_splits_into_drawings_named_after_the_layers_with_one_layer_each( self): drawing = a(validDrawing().withName('TheDrawing').withLayers( Layer('Layer1'), Layer('Layer2'))) drawings = drawing.split(self) assert_that( drawings, equal_to([ a(validDrawing().withName('TheDrawing-0-Layer1').withLayers( Layer('Layer1'))), a(validDrawing().withName('TheDrawing-1-Layer2').withLayers( Layer('Layer2'))) ]))
def as_layer(svg_layer_element): return Layer(name=svg_layer_element.attrib['id'], opacity=svg_layer_element.attrib['opacity'], strokes=[ as_stroke(xml_stroke) for xml_stroke in svg_layer_element.iterchildren() ])
def validDrawing(): return DrawingBuilder( Drawing(name='someDrawing', width='900px', height='400px', version='2.0', view_box='80 80 80 80', layers=[ Layer(name='Layer1', strokes=[ Stroke(type='path', attributes=dict(d="1212321")) ]) ]))
def layer_with_name(name): return Layer(name=name)