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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
# Copyright (c) 2022, Manfred Moitzi
# License: MIT License
import pytest
import ezdxf
from ezdxf import appsettings
@pytest.fixture(scope="module")
def doc():
return ezdxf.new()
def test_set_current_layer(doc):
appsettings.set_current_layer(doc, "0")
assert doc.header["$CLAYER"] == "0"
def test_invalid_layer_raises_exception(doc):
with pytest.raises(ezdxf.DXFValueError):
appsettings.set_current_layer(doc, "INVALID")
def test_set_current_aci_color(doc):
appsettings.set_current_color(doc, 7)
assert doc.header["$CECOLOR"] == 7
def test_invalid_aci_color_raises_exception(doc):
with pytest.raises(ezdxf.DXFValueError):
appsettings.set_current_color(doc, 300)
def test_set_current_linetype(doc):
doc.linetypes.add("TEST", [0.0])
appsettings.set_current_linetype(doc, "TEST")
assert doc.header["$CELTYPE"] == "TEST"
def test_invalid_linetype_raises_exception(doc):
with pytest.raises(ezdxf.DXFValueError):
appsettings.set_current_linetype(doc, "INVALID")
def test_set_current_lineweight(doc):
appsettings.set_current_lineweight(doc, 50)
assert doc.header["$CELWEIGHT"] == 50
def test_invalid_lineweight_raises_exception(doc):
with pytest.raises(ezdxf.DXFValueError):
appsettings.set_current_lineweight(doc, 300)
def test_set_current_linetype_scale(doc):
appsettings.set_current_linetype_scale(doc, 2.0)
assert doc.header["$CELTSCALE"] == 2.0
def test_invalid_linetype_scale_raises_exception(doc):
with pytest.raises(ezdxf.DXFValueError):
appsettings.set_current_linetype_scale(doc, 0)
def test_set_current_textstyle(doc):
doc.styles.add("TEST", font="arial.ttf")
appsettings.set_current_textstyle(doc, "TEST")
assert doc.header["$TEXTSTYLE"] == "TEST"
def test_invalid_textstyle_raises_exception(doc):
with pytest.raises(ezdxf.DXFValueError):
appsettings.set_current_textstyle(doc, "INVALID")
def test_set_current_dimstyle(doc):
doc.dimstyles.add("TEST")
appsettings.set_current_dimstyle(doc, "TEST")
assert doc.header["$DIMSTYLE"] == "TEST"
def test_invalid_dimstyle_raises_exception(doc):
with pytest.raises(ezdxf.DXFValueError):
appsettings.set_current_dimstyle(doc, "INVALID")
if __name__ == "__main__":
pytest.main([__file__])
|