File: test_hpgl2_addon.py

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (35 lines) | stat: -rw-r--r-- 870 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#  Copyright (c) 2023, Manfred Moitzi
#  License: MIT License

import pytest
from pathlib import Path
from xml.etree import ElementTree as ET
from ezdxf.addons.hpgl2 import api as hpgl2

DATA = Path(__file__).parent / "data"
PLOTFILE = DATA / "PLOTFILE.plt"

if not PLOTFILE.exists():
    pytest.skip(reason=f"required file '{PLOTFILE}' not found", allow_module_level=True)


@pytest.fixture(scope="module")
def svg_str():
    data = PLOTFILE.read_bytes()
    return hpgl2.to_svg(data)


def test_svg_was_created(svg_str):
    assert len(svg_str) > 70000


def test_basic_svg_attributes(svg_str):
    root = ET.fromstring(svg_str)
    assert root.tag.endswith("svg")
    assert root.attrib["width"] == "593.8mm"
    assert root.attrib["height"] == "419.9mm"
    assert root.attrib["viewBox"] == "0 0 23752 16794"


if __name__ == '__main__':
    pytest.main([__file__])