def test_import_polyline(): source = ezdxf.new() source.modelspace().add_polyline3d([(0, 0), (3, 0), (3, 3), (0, 3)]) target = ezdxf.new() importer = Importer(source, target) importer.import_modelspace() tpoly = target.modelspace()[0] assert len(tpoly.vertices) == 4 assert tpoly.seqend is not None assert tpoly.seqend.dxf.layer == tpoly.dxf.layer
def test_import_insert_with_attribs(): source = ezdxf.new() source.blocks.new('Test') sinsert = source.modelspace().add_blockref('Test', insert=(0, 0)) sinsert.add_attrib('A1', 'text1') sinsert.add_attrib('A2', 'text2') target = ezdxf.new() importer = Importer(source, target) importer.import_modelspace() tinsert = target.modelspace()[0] assert len(tinsert.attribs) == 2 assert tinsert.seqend is not None assert tinsert.seqend.dxf.layer == tinsert.dxf.layer
def test_import_insert_with_attribs(): source = ezdxf.new() source.blocks.new("Test") sinsert = source.modelspace().add_blockref("Test", insert=(0, 0)) sinsert.add_attrib("A1", "text1") sinsert.add_attrib("A2", "text2") target = ezdxf.new() importer = Importer(source, target) importer.import_modelspace() tinsert = target.modelspace()[0] assert len(tinsert.attribs) == 2 assert tinsert.seqend is not None assert tinsert.seqend.dxf.layer == tinsert.dxf.layer
def importer(request): version = request.param source = SRC_DWG[version] target = create_target_drawing(version) return Importer(source, target)
def setUp(self): self.source = SRC_DWG[self.VERSION] self.target = create_target_drawing(self.VERSION) self.importer = Importer(self.source, self.target)
class TestImportModelspace_AC1009(unittest.TestCase): VERSION = "AC1009" def setUp(self): self.source = SRC_DWG[self.VERSION] self.target = create_target_drawing(self.VERSION) self.importer = Importer(self.source, self.target) def test_import_simple_modelspace(self): self.importer.import_modelspace_entities() source_entities = list(self.source.modelspace()) target_entities = list(self.target.modelspace()) self.assertEqual(len(source_entities), len(target_entities)) def test_import_tables_without_conflict(self): self.importer.import_table('layers') layer = self.target.layers.get('Test') self.assertEqual(17, layer.get_color()) def test_import_tables_with_conflict_discard(self): self.importer.import_table('layers', conflict="discard") layer = self.target.layers.get('TestConflict') self.assertEqual(19, layer.get_color()) # target dwg layer def def test_import_tables_with_conflict_replace(self): self.importer.import_table('layers', conflict="replace") layer = self.target.layers.get('TestConflict') self.assertEqual(18, layer.get_color()) # source dwg layer def def test_import_block_without_conflict(self): self.importer.import_blocks('TestBlock') block = self.target.blocks.get('TestBlock') block_entities = list(block) self.assertEqual(2, len(block_entities)) def test_import_block_with_conflict_discard(self): self.importer.import_blocks('ConflictBlock', conflict='discard') block = self.target.blocks.get('ConflictBlock') block_entities = list(block) self.assertEqual(3, len(block_entities)) def test_import_block_with_conflict_replace(self): self.importer.import_blocks('ConflictBlock', conflict='replace') block = self.target.blocks.get('ConflictBlock') block_entities = list(block) self.assertEqual(2, len(block_entities)) def test_import_block_with_conflict_rename(self): self.importer.import_blocks('ConflictBlock', conflict='rename') block = self.target.blocks.get('ConflictBlock_1') block_entities = list(block) self.assertEqual(2, len(block_entities)) def test_import_block_with_conflict_rename_resolve_block_ref(self): self.importer.import_blocks('ConflictBlock', conflict='rename') self.importer.import_modelspace_entities('INSERT') msp = list(self.target.modelspace()) self.assertEqual('ConflictBlock_1', msp[1].dxf.name) def test_import_block_with_conflict_rename_resolve_block_ref_inside_block_def(self): self.importer.import_blocks(conflict='rename') block = self.target.blocks.get('RefToConflictBlock') block_entities = list(block) block_ref_to_conflict_block = block_entities[2] self.assertEqual('ConflictBlock_1', block_ref_to_conflict_block.dxf.name)
def test_ac1024_to_ac1015(self): importer = Importer(self.ac1024, self.ac1015, strict_mode=False) self.assertFalse(importer.is_compatible())
def test_raise_error_ac1009_to_ac1015(self): with self.assertRaises(TypeError): Importer(self.ac1009, self.ac1015, strict_mode=True)
def test_ac1009_to_ac1009(self): importer = Importer(self.ac1009, self.ac1009, strict_mode=False) self.assertTrue(importer.is_compatible())