-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathintrospection_test.py
More file actions
57 lines (47 loc) · 1.4 KB
/
introspection_test.py
File metadata and controls
57 lines (47 loc) · 1.4 KB
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
import os
import mapnik
import pytest
from .utilities import execution_path
@pytest.fixture(scope="module")
def setup():
# All of the paths used are relative, if we run the tests
# from another directory we need to chdir()
os.chdir(execution_path('.'))
yield
def test_introspect_symbolizers(setup):
# create a symbolizer
p = mapnik.PointSymbolizer()
p.file = "../data/images/dummy.png"
p.allow_overlap = True
p.opacity = 0.5
assert p.allow_overlap == True
assert p.opacity == 0.5
assert str(p.file) == '../data/images/dummy.png'
# make sure the defaults
# are what we think they are
assert p.allow_overlap == True
assert p.opacity == 0.5
assert str(p.file) == '../data/images/dummy.png'
# contruct objects to hold it
r = mapnik.Rule()
r.symbolizers.append(p)
s = mapnik.Style()
s.rules.append(r)
m = mapnik.Map(0, 0)
m.append_style('s', s)
# try to figure out what is
# in the map and make sure
# style is there and the same
s2 = m.find_style('s')
rules = s2.rules
assert len(rules) == 1
r2 = rules[0]
syms = r2.symbolizers
assert len(syms) == 1
# TODO here, we can do...
sym = syms[0]
p2 = sym.extract()
assert isinstance(p2, mapnik.PointSymbolizer)
assert p2.allow_overlap == True
assert p2.opacity == 0.5
assert str(p2.file) == '../data/images/dummy.png'