예제 #1
0
def test_ImageURL() -> None:
    glyph = ImageURL()
    assert glyph.url is None
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.w is None
    assert glyph.h is None
    assert glyph.angle == 0
    assert glyph.dilate is False
    assert glyph.anchor == Anchor.top_left
    assert glyph.retry_attempts == 0
    assert glyph.retry_timeout == 0
    assert glyph.global_alpha == 1.0
    check_properties_existence(glyph, [
        "url",
        "x",
        "y",
        "w",
        "w_units",
        "h",
        "h_units",
        "angle",
        "angle_units",
        "dilate",
        "anchor",
        "retry_attempts",
        "retry_timeout",
        "global_alpha",
    ], GLYPH)
예제 #2
0
def test_HasProps_set_from_json() -> None:
    c = Child()
    c.set_from_json('lst2', [1,2])
    assert c.int1 == 10
    assert c.ds1 == field("x")
    assert c.lst1 == []
    assert c.int2 == None
    assert c.str2 == "foo"
    assert c.ds2 == field("y")
    assert c.lst2 == [1,2]

    c.set_from_json('ds1', "foo")
    assert c.int1 == 10
    assert c.ds1 == "foo"
    assert c.lst1 == []
    assert c.int2 == None
    assert c.str2 == "foo"
    assert c.ds2 == field("y")
    assert c.lst2 == [1,2]

    c.set_from_json('int2', 100)
    assert c.int1 == 10
    assert c.ds1 == "foo"
    assert c.lst1 == []
    assert c.int2 == 100
    assert c.str2 == "foo"
    assert c.ds2 == field("y")
    assert c.lst2 == [1,2]
예제 #3
0
def test_AnnularWedge() -> None:
    glyph = AnnularWedge()
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.inner_radius is None
    assert glyph.outer_radius is None
    assert glyph.start_angle is None
    assert glyph.end_angle is None
    assert glyph.direction == "anticlock"
    check_line_properties(glyph)
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y",
        "inner_radius",
        "inner_radius_units",
        "outer_radius",
        "outer_radius_units",
        "start_angle",
        "start_angle_units",
        "end_angle",
        "end_angle_units",
        "direction",
    ], LINE, FILL, HATCH, GLYPH)
예제 #4
0
def test_Segment() -> None:
    glyph = Segment()
    assert glyph.x0 == field("x0")
    assert glyph.y0 == field("y0")
    assert glyph.x1 == field("x1")
    assert glyph.y1 == field("y1")
    check_line_properties(glyph)
    check_properties_existence(glyph, ["x0", "y0", "x1", "y1"], LINE, GLYPH)
예제 #5
0
def test_Line() -> None:
    glyph = Line()
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    check_line_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y",
    ], LINE, GLYPH)
예제 #6
0
def test_MultiLine() -> None:
    glyph = MultiLine()
    assert glyph.xs == field("xs")
    assert glyph.ys == field("ys")
    check_line_properties(glyph)
    check_properties_existence(glyph, [
        "xs",
        "ys",
    ], LINE, GLYPH)
예제 #7
0
def test_HasProps_update_from_json() -> None:
    c = Child()
    c.update_from_json(dict(lst2=[1,2], str2="baz", int1=25, ds1=field("foo")))
    assert c.int1 == 25
    assert c.ds1 == field("foo")
    assert c.lst1 == []
    assert c.int2 == None
    assert c.str2 == "baz"
    assert c.ds2 == field("y")
    assert c.lst2 == [1,2]
예제 #8
0
def test_Step() -> None:
    glyph = Step()
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.mode == "before"
    check_line_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y",
        "mode",
    ], LINE, GLYPH)
예제 #9
0
def test_Patches() -> None:
    glyph = Patches()
    assert glyph.xs == field("xs")
    assert glyph.ys == field("ys")
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_line_properties(glyph)
    check_properties_existence(glyph, [
        "xs",
        "ys",
    ], FILL, HATCH, LINE, GLYPH)
예제 #10
0
def test_Text() -> None:
    glyph = Text()
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.text == "text"
    assert glyph.angle == 0
    check_text_properties(glyph)
    check_properties_existence(
        glyph,
        ["x", "y", "text", "angle", "angle_units", "x_offset", "y_offset"],
        TEXT, GLYPH)
예제 #11
0
def test_HArea() -> None:
    glyph = HArea()
    assert glyph.y == field("y")
    assert glyph.x1 == field("x1")
    assert glyph.x2 == field("x2")
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_properties_existence(glyph, [
        "y",
        "x1",
        "x2",
    ], FILL, HATCH, GLYPH)
예제 #12
0
def test_VArea() -> None:
    glyph = VArea()
    assert glyph.x == field("x")
    assert glyph.y1 == field("y1")
    assert glyph.y2 == field("y2")
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y1",
        "y2",
    ], FILL, HATCH, GLYPH)
예제 #13
0
def test_HasProps_set() -> None:
    c = Child()
    c.update(**dict(lst2=[1,2], str2="baz", int1=25, ds1=field("foo")))
    assert c.int1 == 25
    assert c.ds1 == field("foo")
    assert c.lst1 == []
    assert c.int2 == None
    assert c.str2 == "baz"
    assert c.ds2 == field("y")
    assert c.lst2 == [1,2]

    c.str2_proxy = "some"
    assert c.str2 == "somesome"
    assert c.str2_proxy == "somesome"
예제 #14
0
def test_HasProps_default_init() -> None:
    p = Parent()
    assert p.int1 == 10
    assert p.ds1 == field("x")
    assert p.lst1 == []

    c = Child()
    assert c.int1 == 10
    assert c.ds1 == field("x")
    assert c.lst1 == []
    assert c.int2 == None
    assert c.str2 == "foo"
    assert c.ds2 == field("y")
    assert c.lst2 == [1,2,3]
예제 #15
0
def test_HasProps_kw_init() -> None:
    p = Parent(int1=30, ds1=field("foo"))
    assert p.int1 == 30
    assert p.ds1 == field("foo")
    assert p.lst1 == []

    c = Child(str2="bar", lst2=[2,3,4], ds2=10)
    assert c.int1 == 10
    assert c.ds1 == field("x")
    assert c.lst1 == []
    assert c.int2 == None
    assert c.str2 == "bar"
    assert c.ds2 == 10
    assert c.lst2 == [2,3,4]
예제 #16
0
def test_VBar() -> None:
    glyph = VBar()
    assert glyph.x == field("x")
    assert glyph.width == 1
    assert glyph.top == field("top")
    assert glyph.bottom == 0
    check_line_properties(glyph)
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "width",
        "top",
        "bottom",
    ], FILL, HATCH, LINE, GLYPH)
예제 #17
0
def test_Quad() -> None:
    glyph = Quad()
    assert glyph.left == field("left")
    assert glyph.right == field("right")
    assert glyph.bottom == field("bottom")
    assert glyph.top == field("top")
    check_line_properties(glyph)
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_properties_existence(glyph, [
        "left",
        "right",
        "bottom",
        "top",
    ], FILL, HATCH, LINE, GLYPH)
예제 #18
0
def test_HBar() -> None:
    glyph = HBar()
    assert glyph.y == field("y")
    assert glyph.height == 1
    assert glyph.left == 0
    assert glyph.right == field("right")
    check_line_properties(glyph)
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_properties_existence(glyph, [
        "y",
        "height",
        "left",
        "right",
    ], FILL, HATCH, LINE, GLYPH)
예제 #19
0
def test_Ray() -> None:
    glyph = Ray()
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.angle is None
    assert glyph.length is None
    check_line_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y",
        "angle",
        "angle_units",
        "length",
        "length_units",
    ], LINE, GLYPH)
예제 #20
0
def test_Annulus() -> None:
    glyph = Annulus()
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.inner_radius is None
    assert glyph.outer_radius is None
    check_fill_properties(glyph)
    check_line_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y",
        "inner_radius",
        "inner_radius_units",
        "outer_radius",
        "outer_radius_units",
    ], FILL, LINE, GLYPH)
예제 #21
0
def test_Oval() -> None:
    glyph = Oval()
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.width is None
    assert glyph.height is None
    assert glyph.angle == 0
    check_fill_properties(glyph)
    check_line_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y",
        "width",
        "width_units",
        "height",
        "height_units",
        "angle",
        "angle_units",
    ], FILL, LINE, GLYPH)
예제 #22
0
def test_ImageRGBA() -> None:
    glyph = ImageRGBA()
    assert glyph.image is None
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.dw is None
    assert glyph.dh is None
    assert glyph.dilate is False
    check_properties_existence(glyph, [
        "image",
        "x",
        "y",
        "dw",
        "dw_units",
        "dh",
        "dh_units",
        "global_alpha",
        "dilate",
    ], GLYPH)
예제 #23
0
def test_Image() -> None:
    glyph = Image()
    assert glyph.image == field("image")
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.dw == field("dw")
    assert glyph.dh == field("dh")
    assert glyph.dilate is False
    check_properties_existence(glyph, [
        "image",
        "x",
        "y",
        "dw",
        "dw_units",
        "dh",
        "dh_units",
        "global_alpha",
        "dilate",
        "color_mapper",
    ], GLYPH)
예제 #24
0
def test_HasProps_intrinsic() -> None:
    obj0 = Parent(int1=Intrinsic, ds1=Intrinsic, lst1=Intrinsic)

    assert obj0.int1 == 10
    assert obj0.ds1 == field("x")
    assert obj0.lst1 == []

    obj1 = Parent(int1=30, ds1=field("y"), lst1=["x", "y", "z"])

    assert obj1.int1 == 30
    assert obj1.ds1 == field("y")
    assert obj1.lst1 == ["x", "y", "z"]

    obj1.int1 = Intrinsic
    obj1.ds1 = Intrinsic
    obj1.lst1 = Intrinsic

    assert obj1.int1 == 10
    assert obj1.ds1 == field("x")
    assert obj1.lst1 == []
예제 #25
0
def test_Arc() -> None:
    glyph = Arc()
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.radius is None
    assert glyph.start_angle is None
    assert glyph.end_angle is None
    assert glyph.direction == "anticlock"
    check_line_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y",
        "radius",
        "radius_units",
        "start_angle",
        "start_angle_units",
        "end_angle",
        "end_angle_units",
        "direction",
    ], LINE, GLYPH)
예제 #26
0
class Child(Parent):
    int2 = Nullable(Int())
    str2 = String(default="foo")
    ds2 = NumberSpec(default=field("y"))
    lst2 = List(Int, default=[1,2,3])

    @property
    def str2_proxy(self):
        return self.str2
    @str2_proxy.setter
    def str2_proxy(self, value):
        self.str2 = value*2
예제 #27
0
def test_Rect() -> None:
    glyph = Rect()
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.width == field("width")
    assert glyph.height == field("height")
    assert glyph.angle == 0
    assert glyph.dilate is False
    check_line_properties(glyph)
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y",
        "width",
        "width_units",
        "height",
        "height_units",
        "angle",
        "angle_units",
        "dilate",
    ], LINE, FILL, HATCH, GLYPH)
예제 #28
0
def test_Wedge() -> None:
    glyph = Wedge()
    assert glyph.x == field("x")
    assert glyph.y == field("y")
    assert glyph.radius == field("radius")
    assert glyph.start_angle == field("start_angle")
    assert glyph.end_angle == field("end_angle")
    assert glyph.direction == "anticlock"
    check_line_properties(glyph)
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y",
        "radius",
        "radius_units",
        "start_angle",
        "start_angle_units",
        "end_angle",
        "end_angle_units",
        "direction",
    ], LINE, FILL, HATCH, GLYPH)
예제 #29
0
def test_HasProps_unapply_theme() -> None:
    c = Child()
    theme = dict(int2=10, lst1=["foo", "bar"])
    c.apply_theme(theme)
    assert c.int2 == 10
    assert c.lst1 == ["foo", "bar"]

    assert c.int1 == 10
    assert c.ds1 == field("x")
    assert c.str2 == "foo"
    assert c.ds2 == field("y")
    assert c.lst2 == [1,2,3]

    c.unapply_theme()
    assert c.int2 == None
    assert c.lst1 == []

    assert c.int1 == 10
    assert c.ds1 == field("x")
    assert c.str2 == "foo"
    assert c.ds2 == field("y")
    assert c.lst2 == [1,2,3]

    assert c.themed_values() == None
예제 #30
0
def test_Bezier() -> None:
    glyph = Bezier()
    assert glyph.x0 == field("x0")
    assert glyph.y0 == field("y0")
    assert glyph.x1 == field("x1")
    assert glyph.y1 == field("y1")
    assert glyph.cx0 == field("cx0")
    assert glyph.cy0 == field("cy0")
    assert glyph.cx1 == field("cx1")
    assert glyph.cy1 == field("cy1")
    check_line_properties(glyph)
    check_properties_existence(glyph, [
        "x0",
        "y0",
        "x1",
        "y1",
        "cx0",
        "cy0",
        "cx1",
        "cy1",
    ], LINE, GLYPH)
예제 #31
0
def test_field_function():
    assert bcpd.field("foo") == dict(field="foo")
    assert bcpd.field("foo", "junk") == dict(field="foo", transform="junk")
    assert bcpd.field("foo", transform="junk") == dict(field="foo", transform="junk")