2 # -*- coding: iso-8859-15 -*-
4 import wrpylib.wrmwmarkup
5 import wrpylib.mwmarkup
10 def test_rodelbahnbox_to_sledrun():
11 wikitext = u'''== Allgemeines ==
13 | Position = 47.309820 N 9.986508 E
20 | Lawinen = gelegentlich
22 | Öffentliche Anreise = Ja
24 | Aufstieg getrennt = Nein
25 | Aufstiegshilfe = Nein
26 | Beleuchtungsanlage = Nein
31 | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
32 | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
33 | In Übersichtskarte = Ja
36 Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
37 start, end, sledrun = wrpylib.wrmwmarkup.rodelbahnbox_to_sledrun(wikitext)
38 wrpylib.wrmwmarkup.sledrun_to_rodelbahnbox(sledrun, '1.3')
41 def test_RodelbahnboxDictConverter():
42 v = wrpylib.wrmwmarkup.RodelbahnboxDictConverter()
43 class Sledrun(object):
45 other = collections.OrderedDict([
46 (u'Position', (47.30982, 9.986508)),
47 (u'Position oben', (None, None)),
49 (u'Position unten', (None, None)),
52 (u'Schwierigkeit', None),
55 (u'Öffentliche Anreise', 6),
56 (u'Aufstieg möglich', True),
57 (u'Aufstieg getrennt', (0.0, None)),
59 (u'Aufstiegshilfe', (False, None)),
60 (u'Beleuchtungsanlage', (0.0, None)),
61 (u'Beleuchtungstage', (None, None)),
62 (u'Rodelverleih', (True, u'Ja')),
63 (u'Gütesiegel', None),
64 (u'Webauskunft', None),
65 (u'Telefonauskunft', u'+43-664-1808482 (Bergkristallhütte)'),
66 (u'Bild', u'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
67 (u'In Übersichtskarte', True),
69 sledrun = v.to_python((other, Sledrun()))
70 assert sledrun.forum_id == 72
71 other2 = v.from_python(sledrun)
72 assert other == other2
75 def test_gasthausbox_to_inn():
76 wikitext = u'''{{Gasthausbox
77 | Position = 47.295549 N 9.986970 E
84 | Handyempfang = A1; T-Mobile/Telering
85 | Homepage = http://www.bergkristallhuette.com/
86 | E-Mail = bergkristallhuette@gmx.at
87 | Telefon = +43-664-1808482
88 | Bild = Bergkritsallhütte 2009-02-07.JPG
89 | Rodelbahnen = [[Bergkristallhütte]]
91 Die Bergkristallhütte ist Teil des Boden-Vorsäß.'''
92 start, end, inn = wrpylib.wrmwmarkup.gasthausbox_to_inn(wikitext)
93 wrpylib.wrmwmarkup.inn_to_gasthausbox(inn)
96 def test_googlemap_to_wrmap():
98 <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15" height="450">
99 (Parkplatz)47.114958,11.266026
102 (Gasthaus) 47.114715, 11.266262, Alt Bärnbad (Gasthaus)
111 attributes, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
112 json = wrpylib.wrmwmarkup.googlemap_to_wrmap(attributes, coords, paths)
113 assert json['properties']['lon'] == 11.272337
114 assert json['properties']['lat'] == 47.113291
115 assert json['properties']['zoom'] == 15
116 assert json['properties']['height'] == 450
117 assert json['features'][0]['properties']['type'] == 'parkplatz'
118 assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
119 assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
120 assert json['features'][1]['properties']['type'] == 'gasthaus'
121 assert json['features'][1]['properties']['name'] == u'Alt Bärnbad (Gasthaus)'
122 assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
123 assert json['features'][2]['properties']['type'] == 'rodelbahn'
124 assert json['features'][2]['geometry']['coordinates'] == [
125 [11.266262, 47.114715],
126 [11.268381, 47.114135],
127 [11.269322, 47.113421],
128 [11.269979, 47.11277],
129 [11.271119, 47.112408]]
132 def test_parse_wrmap():
134 <wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
135 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
136 <parkplatz>47.245789 11.238971</parkplatz>
137 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>
145 json = wrpylib.wrmwmarkup.parse_wrmap(wikitext)
146 assert json['properties']['lon'] == 11.21408895
147 assert json['properties']['lat'] == 47.2417134
148 assert json['properties']['zoom'] == 14
149 assert json['properties']['width'] == 700
150 assert json['properties']['height'] == 400
151 assert json['features'][0]['properties']['type'] == 'gasthaus'
152 assert json['features'][0]['properties']['name'] == u'Rosskogelhütte'
153 assert json['features'][0]['properties']['wiki'] == u'Rosskogelhütte'
154 assert json['features'][0]['geometry']['coordinates'] == [11.190454, 47.240689]
155 assert json['features'][1]['properties']['type'] == 'parkplatz'
156 assert json['features'][1]['geometry']['coordinates'] == [11.238971, 47.245789]
157 assert json['features'][2]['properties']['type'] == 'haltestelle'
158 assert json['features'][2]['properties']['name'] == u'Oberperfuss Rangger Köpfl Lift'
159 assert json['features'][2]['geometry']['coordinates'] == [11.238283, 47.245711]
160 assert json['features'][3]['properties']['type'] == 'rodelbahn'
161 assert json['features'][3]['geometry']['coordinates'] == [
162 [11.203360, 47.238587],
163 [11.230868, 47.244951],
164 [11.237853, 47.245470]]
167 def test_create_wrmap():
169 'type': 'FeatureCollection',
175 'coordinates': [11.190454, 47.240689]},
176 'properties': {'type': 'gasthaus', 'name': u'Rosskogelhütte', 'wiki': u'Rosskogelhütte'}
181 'coordinates': [11.238971, 47.245789]},
182 'properties': {'type': 'parkplatz'}
187 'coordinates': [11.238283, 47.245711]},
188 'properties': {'type': 'haltestelle', 'name': u'Oberperfuss Rangger Köpfl Lift'}
192 'type': 'LineString',
194 [11.203360, 47.238587],
195 [11.230868, 47.244951],
196 [11.237853, 47.245470]]},
197 'properties': {'type': 'rodelbahn'}
207 wikitext = wrpylib.wrmwmarkup.create_wrmap(geojson)
208 assert wikitext == textwrap.dedent(u'''\
209 <wrmap height="400" lat="47.241713" lon="11.214089" width="700" zoom="14">
211 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 N 11.190454 E</gasthaus>
212 <parkplatz>47.245789 N 11.238971 E</parkplatz>
213 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 N 11.238283 E</haltestelle>
216 47.238587 N 11.203360 E
217 47.244951 N 11.230868 E
218 47.245470 N 11.237853 E