Exemplo n.º 1
0
 def setUp(self):
     self.source = SRC_DWG[self.VERSION]
     self.target = create_target_drawing(self.VERSION)
     self.importer = Importer(self.source, self.target)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
 def test_raise_error_ac1009_to_ac1015(self):
     with self.assertRaises(TypeError):
         Importer(self.ac1009, self.ac1015, strict_mode=True)
Exemplo n.º 4
0
 def test_ac1024_to_ac1015(self):
     importer = Importer(self.ac1024, self.ac1015, strict_mode=False)
     self.assertFalse(importer.is_compatible())
Exemplo n.º 5
0
 def test_ac1009_to_ac1009(self):
     importer = Importer(self.ac1009, self.ac1009, strict_mode=False)
     self.assertTrue(importer.is_compatible())