Exemple #1
0
 def test_empty_section(self):
     section = BlocksSection(Tags.from_text(EMPTYSEC), self.dwg)
     stream = StringIO()
     section.write(stream)
     result = stream.getvalue()
     stream.close()
     self.assertEqual(EMPTYSEC, result)
 def test_empty_section(self):
     section = BlocksSection(Tags.from_text(EMPTYSEC), self.dwg)
     stream = StringIO()
     section.write(stream)
     result = stream.getvalue()
     stream.close()
     self.assertEqual(EMPTYSEC, result)
Exemple #3
0
 def setUp(self):
     self.dwg = DrawingProxy('AC1009')
     self.section = BlocksSection(Tags.from_text(TESTBLOCKS), self.dwg)
Exemple #4
0
class TestBlocksSectionAC1009(unittest.TestCase):
    def setUp(self):
        self.dwg = DrawingProxy('AC1009')
        self.section = BlocksSection(Tags.from_text(TESTBLOCKS), self.dwg)

    def test_write(self):
        stream = StringIO()
        self.section.write(stream)
        result = stream.getvalue()
        stream.close()
        t1 = sorted(normlines(TESTBLOCKS))
        t2 = sorted(normlines(result))
        self.assertEqual(t1, t2)

    def test_empty_section(self):
        section = BlocksSection(Tags.from_text(EMPTYSEC), self.dwg)
        stream = StringIO()
        section.write(stream)
        result = stream.getvalue()
        stream.close()
        self.assertEqual(EMPTYSEC, result)

    def test_create_block(self):
        block = self.section.new('TEST')
        self.assertTrue(block in self.section)

    def test_not_in_blocks_section(self):
        self.assertFalse('TEST' in self.section)

    def test_getitem(self):
        newblock = self.section.new('TEST')
        block = self.section['TEST']
        self.assertEqual('TEST', block.name)

    def test_iter_blocks(self):
        blocks = list(self.section)
        self.assertEqual(4, len(blocks))

    def test_block_content_entity_drawing_attribute(self):
        archtick = self.section['_ARCHTICK']
        entities = list(archtick)
        self.assertEqual(1, len(entities))  # VERTEX & SEQEND doesn't count
        e = entities[0]
        self.assertEqual(self.dwg, e.drawing)

    def test_delete_block(self):
        archtick = self.section['_ARCHTICK']
        entities = list(archtick)
        archtick_name = archtick.name
        self.section.delete_block(archtick_name)
        self.assertTrue(archtick_name not in self.section)
        db = self.dwg.entitydb
        self.assertTrue(archtick._block_handle not in db)
        self.assertTrue(archtick._endblk_handle not in db)
        for entity in entities:
            self.assertTrue(entity.dxf.handle not in db)

    def test_delete_all_blocks(self):
        self.section.delete_all_blocks()
        blocks = list(self.section)
        # assure not deleting layout blocks
        self.assertEqual(2, len(blocks))
        block_names = [block.name for block in blocks]
        block_names.sort()
        self.assertEqual(['$MODEL_SPACE', '$PAPER_SPACE'], block_names)
 def setUp(self):
     self.dwg = DrawingProxy("AC1009")
     self.section = BlocksSection(Tags.from_text(TESTBLOCKS), self.dwg)
class TestBlocksSectionAC1009(unittest.TestCase):
    def setUp(self):
        self.dwg = DrawingProxy("AC1009")
        self.section = BlocksSection(Tags.from_text(TESTBLOCKS), self.dwg)

    def test_write(self):
        stream = StringIO()
        self.section.write(stream)
        result = stream.getvalue()
        stream.close()
        t1 = sorted(normlines(TESTBLOCKS))
        t2 = sorted(normlines(result))
        self.assertEqual(t1, t2)

    def test_empty_section(self):
        section = BlocksSection(Tags.from_text(EMPTYSEC), self.dwg)
        stream = StringIO()
        section.write(stream)
        result = stream.getvalue()
        stream.close()
        self.assertEqual(EMPTYSEC, result)

    def test_create_block(self):
        block = self.section.new("TEST")
        self.assertTrue(block in self.section)

    def test_not_in_blocks_section(self):
        self.assertFalse("TEST" in self.section)

    def test_getitem(self):
        newblock = self.section.new("TEST")
        block = self.section["TEST"]
        self.assertEqual("TEST", block.name)

    def test_iter_blocks(self):
        blocks = list(self.section)
        self.assertEqual(4, len(blocks))

    def test_block_content_entity_drawing_attribute(self):
        archtick = self.section["_ARCHTICK"]
        entities = list(archtick)
        self.assertEqual(1, len(entities))  # VERTEX & SEQEND doesn't count
        e = entities[0]
        self.assertEqual(self.dwg, e.drawing)

    def test_delete_block(self):
        archtick = self.section["_ARCHTICK"]
        entities = list(archtick)
        archtick_name = archtick.name
        self.section.delete_block(archtick_name)
        self.assertTrue(archtick_name not in self.section)
        db = self.dwg.entitydb
        self.assertTrue(archtick._block_handle not in db)
        self.assertTrue(archtick._endblk_handle not in db)
        for entity in entities:
            self.assertTrue(entity.dxf.handle not in db)

    def test_delete_all_blocks(self):
        self.section.delete_all_blocks()
        blocks = list(self.section)
        # assure not deleting layout blocks
        self.assertEqual(2, len(blocks))
        block_names = [block.name for block in blocks]
        block_names.sort()
        self.assertEqual(["$MODEL_SPACE", "$PAPER_SPACE"], block_names)