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 other = collections.OrderedDict([
44 (u'Position', (47.30982, 9.986508)),
45 (u'Position oben', (None, None)),
47 (u'Position unten', (None, None)),
50 (u'Schwierigkeit', None),
53 (u'Öffentliche Anreise', 6),
54 (u'Aufstieg möglich', True),
55 (u'Aufstieg getrennt', (0.0, None)),
57 (u'Aufstiegshilfe', (False, None)),
58 (u'Beleuchtungsanlage', (0.0, None)),
59 (u'Beleuchtungstage', (None, None)),
60 (u'Rodelverleih', (True, u'Ja')),
61 (u'Gütesiegel', None),
62 (u'Webauskunft', None),
63 (u'Telefonauskunft', u'+43-664-1808482 (Bergkristallhütte)'),
64 (u'Bild', u'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
65 (u'In Übersichtskarte', True),
67 sledrun = v.to_python(other)
68 assert sledrun.forum_id == 72
69 other2 = v.from_python(sledrun)
70 assert other == other2
73 def test_gasthausbox_to_inn():
74 wikitext = u'''{{Gasthausbox
75 | Position = 47.295549 N 9.986970 E
82 | Handyempfang = A1; T-Mobile/Telering
83 | Homepage = http://www.bergkristallhuette.com/
84 | E-Mail = bergkristallhuette@gmx.at
85 | Telefon = +43-664-1808482
86 | Bild = Bergkritsallhütte 2009-02-07.JPG
87 | Rodelbahnen = [[Bergkristallhütte]]
89 Die Bergkristallhütte ist Teil des Boden-Vorsäß.'''
90 start, end, inn = wrpylib.wrmwmarkup.gasthausbox_to_inn(wikitext)
91 wrpylib.wrmwmarkup.inn_to_gasthausbox(inn)
94 def test_googlemap_to_wrmap():
96 <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15" height="450">
97 (Parkplatz)47.114958,11.266026
100 (Gasthaus) 47.114715, 11.266262, Alt Bärnbad (Gasthaus)
109 attributes, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
110 json = wrpylib.wrmwmarkup.googlemap_to_wrmap(attributes, coords, paths)
111 assert json['properties']['lon'] == 11.272337
112 assert json['properties']['lat'] == 47.113291
113 assert json['properties']['zoom'] == 15
114 assert json['properties']['height'] == 450
115 assert json['features'][0]['properties']['type'] == 'parkplatz'
116 assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
117 assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
118 assert json['features'][1]['properties']['type'] == 'gasthaus'
119 assert json['features'][1]['properties']['name'] == u'Alt Bärnbad (Gasthaus)'
120 assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
121 assert json['features'][2]['properties']['type'] == 'rodelbahn'
122 assert json['features'][2]['geometry']['coordinates'] == [
123 [11.266262, 47.114715],
124 [11.268381, 47.114135],
125 [11.269322, 47.113421],
126 [11.269979, 47.11277],
127 [11.271119, 47.112408]]
130 def test_parse_wrmap():
132 <wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
133 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
134 <parkplatz>47.245789 11.238971</parkplatz>
135 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>
143 json = wrpylib.wrmwmarkup.parse_wrmap(wikitext)
144 assert json['properties']['lon'] == 11.21408895
145 assert json['properties']['lat'] == 47.2417134
146 assert json['properties']['zoom'] == 14
147 assert json['properties']['width'] == 700
148 assert json['properties']['height'] == 400
149 assert json['features'][0]['properties']['type'] == 'gasthaus'
150 assert json['features'][0]['properties']['name'] == u'Rosskogelhütte'
151 assert json['features'][0]['properties']['wiki'] == u'Rosskogelhütte'
152 assert json['features'][0]['geometry']['coordinates'] == [11.190454, 47.240689]
153 assert json['features'][1]['properties']['type'] == 'parkplatz'
154 assert json['features'][1]['geometry']['coordinates'] == [11.238971, 47.245789]
155 assert json['features'][2]['properties']['type'] == 'haltestelle'
156 assert json['features'][2]['properties']['name'] == u'Oberperfuss Rangger Köpfl Lift'
157 assert json['features'][2]['geometry']['coordinates'] == [11.238283, 47.245711]
158 assert json['features'][3]['properties']['type'] == 'rodelbahn'
159 assert json['features'][3]['geometry']['coordinates'] == [
160 [11.203360, 47.238587],
161 [11.230868, 47.244951],
162 [11.237853, 47.245470]]
165 def test_create_wrmap():
167 'type': 'FeatureCollection',
173 'coordinates': [11.190454, 47.240689]},
174 'properties': {'type': 'gasthaus', 'name': u'Rosskogelhütte', 'wiki': u'Rosskogelhütte'}
179 'coordinates': [11.238971, 47.245789]},
180 'properties': {'type': 'parkplatz'}
185 'coordinates': [11.238283, 47.245711]},
186 'properties': {'type': 'haltestelle', 'name': u'Oberperfuss Rangger Köpfl Lift'}
190 'type': 'LineString',
192 [11.203360, 47.238587],
193 [11.230868, 47.244951],
194 [11.237853, 47.245470]]},
195 'properties': {'type': 'rodelbahn'}
205 wikitext = wrpylib.wrmwmarkup.create_wrmap(geojson)
206 assert wikitext == textwrap.dedent(u'''\
207 <wrmap height="400" lat="47.241713" lon="11.214089" width="700" zoom="14">
209 <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 N 11.190454 E</gasthaus>
210 <parkplatz>47.245789 N 11.238971 E</parkplatz>
211 <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 N 11.238283 E</haltestelle>
214 47.238587 N 11.203360 E
215 47.244951 N 11.230868 E
216 47.245470 N 11.237853 E