#!/usr/bin/python3.4
-# -*- coding: iso-8859-15 -*-
import collections
-import wrpylib.wrmwmarkup
-import wrpylib.mwmarkup
import textwrap
import unittest
+import mwparserfromhell
+import wrpylib.wrvalidators
+import wrpylib.wrmwmarkup
+from wrpylib.wrvalidators import LonLat
+from wrpylib.wrmwmarkup import sledrun_from_rodelbahnbox, sledrun_to_rodelbahnbox, \
+ inn_from_gasthausbox, inn_to_gasthausbox, lonlat_ele_from_template, latlon_ele_to_template
-class TestWrMwMarkup(unittest.TestCase):
- def test_rodelbahnbox_to_sledrun(self):
- wikitext = '''== Allgemeines ==
- {{Rodelbahnbox
- | Position = 47.309820 N 9.986508 E
- | Position oben =
- | Höhe oben = 1244
- | Position unten =
- | Höhe unten = 806
- | Länge = 5045
- | Schwierigkeit =
- | Lawinen = gelegentlich
- | Betreiber =
- | Öffentliche Anreise = Ja
- | Gehzeit = 105
- | Aufstieg möglich = Nein
- | Aufstieg getrennt = Nein
- | Aufstiegshilfe = Nein
- | Beleuchtungsanlage = Nein
- | Beleuchtungstage =
- | Rodelverleih = Ja
- | Gütesiegel =
- | Webauskunft =
- | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
- | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
- | In Übersichtskarte = Ja
- | Forumid = 72
- }}
- Die Rodelbahn zur Bergkristallhütte ist durchaus abwechslungsreich.'''
- start, end, sledrun = wrpylib.wrmwmarkup.rodelbahnbox_to_sledrun(wikitext)
- wrpylib.wrmwmarkup.sledrun_to_rodelbahnbox(sledrun)
-
-
- def test_RodelbahnboxDictConverter(self):
- v = wrpylib.wrmwmarkup.RodelbahnboxDictConverter()
- other = collections.OrderedDict([
- ('Position', (47.30982, 9.986508)),
- ('Position oben', (None, None)),
- ('Höhe oben', 1244),
- ('Position unten', (None, None)),
- ('Höhe unten', 806),
- ('Länge', 5045),
- ('Schwierigkeit', None),
- ('Lawinen', 3),
- ('Betreiber', None),
- ('Öffentliche Anreise', 6),
- ('Aufstieg möglich', True),
+class TestSledrun(unittest.TestCase):
+ def test_sledrun_from_rodelbahnbox(self):
+ class Sledrun:
+ pass
+ rodelbahnbox = collections.OrderedDict([
+ ('Position', LonLat(9.986508, 47.30982)),
+ ('Position oben', LonLat(None, None)),
+ ('Höhe oben', 1244),
+ ('Position unten', LonLat(8.506047, 46.20210)),
+ ('Höhe unten', None),
+ ('Länge', 5045),
+ ('Schwierigkeit', 3),
+ ('Lawinen', 2),
+ ('Betreiber', 'SchneeFunFit'),
+ ('Öffentliche Anreise', 2),
+ ('Aufstieg möglich', True),
('Aufstieg getrennt', (0.0, None)),
('Gehzeit', 105),
- ('Aufstiegshilfe', (False, None)),
- ('Beleuchtungsanlage', (0.0, None)),
+ ('Aufstiegshilfe', [('Sessellift', 'gratis'), ('Bus', None)]),
+ ('Beleuchtungsanlage', (0.0, 'in Planung für 2020')),
('Beleuchtungstage', (None, None)),
- ('Rodelverleih', (True, 'Ja')),
- ('Gütesiegel', None),
- ('Webauskunft', None),
- ('Telefonauskunft', '+43-664-1808482 (Bergkristallhütte)'),
- ('Bild', 'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
- ('In Übersichtskarte', True),
+ ('Rodelverleih', []),
+ ('Gütesiegel', []),
+ ('Webauskunft', (True, 'http://example.com/schneelage')),
+ ('Telefonauskunft', [('+43-664-1808482', 'Bergkristallhütte')]),
+ ('Bild', 'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
+ ('In Übersichtskarte', True),
('Forumid', 72)])
- sledrun = v.to_python(other)
- assert sledrun.forum_id == 72
- other2 = v.from_python(sledrun)
- assert other == other2
+ sledrun = Sledrun()
+ sledrun_from_rodelbahnbox(rodelbahnbox, sledrun)
+ self.assertEqual(47.30982, sledrun.position_latitude)
+ self.assertEqual(9.986508, sledrun.position_longitude)
+ self.assertEqual(None, sledrun.top_latitude)
+ self.assertEqual(None, sledrun.top_longitude)
+ self.assertEqual(1244, sledrun.top_elevation)
+ self.assertEqual(46.20210, sledrun.bottom_latitude)
+ self.assertEqual(8.506047, sledrun.bottom_longitude)
+ self.assertEqual(None, sledrun.bottom_elevation)
+ self.assertEqual(5045, sledrun.length)
+ self.assertEqual(3, sledrun.difficulty)
+ self.assertEqual(2, sledrun.avalanches)
+ self.assertEqual('SchneeFunFit', sledrun.operator)
+ self.assertEqual(2, sledrun.public_transport)
+ self.assertEqual(True, sledrun.walkup_possible)
+ self.assertEqual(105, sledrun.walkup_time)
+ self.assertEqual(0.0, sledrun.walkup_separate)
+ self.assertEqual(None, sledrun.walkup_separate_comment)
+ self.assertEqual(True, sledrun.lift)
+ self.assertEqual('Sessellift (gratis); Bus', sledrun.lift_details)
+ self.assertEqual(0.0, sledrun.night_light)
+ self.assertEqual('in Planung für 2020', sledrun.night_light_comment)
+ self.assertEqual(None, sledrun.night_light_days)
+ self.assertEqual(None, sledrun.night_light_days_comment)
+ self.assertEqual(False, sledrun.sled_rental)
+ self.assertEqual('Nein', sledrun.sled_rental_comment)
+ self.assertEqual('Nein', sledrun.cachet)
+ self.assertEqual('http://example.com/schneelage', sledrun.information_web)
+ self.assertEqual('+43-664-1808482 (Bergkristallhütte)', sledrun.information_phone)
+ self.assertEqual('Rodelbahn Bergkristallhütte 2009-03-03.jpg', sledrun.image)
+ self.assertEqual(True, sledrun.show_in_overview)
+ self.assertEqual(72, sledrun.forum_id)
+ def test_sledrun_to_rodelbahnbox(self):
+ class Sledrun:
+ pass
+ sledrun = Sledrun()
+ sledrun.position_longitude = 13.5
+ sledrun.position_latitude = 50.7
+ sledrun.top_longitude = 12.2
+ sledrun.top_latitude = 49.8
+ sledrun.top_elevation = 3456
+ sledrun.bottom_longitude = 9.89
+ sledrun.bottom_latitude = 51.2
+ sledrun.bottom_elevation = 2075
+ sledrun.length = 9644
+ sledrun.difficulty = 3
+ sledrun.avalanches = 2
+ sledrun.operator = 'McRodel'
+ sledrun.public_transport = 3
+ sledrun.walkup_possible = True
+ sledrun.walkup_time = 77
+ sledrun.walkup_separate = 0.5
+ sledrun.walkup_separate_comment = 'Nur unterer Teil'
+ sledrun.lift = True
+ sledrun.lift_details = 'Sessellift'
+ sledrun.night_light = 1.0
+ sledrun.night_light_comment = 'Schlecht beleuchtet'
+ sledrun.night_light_days = 6
+ sledrun.night_light_days_comment = 'Mo-Sa'
+ sledrun.sled_rental = True
+ sledrun.sled_rental_comment = 'In der Hütte'
+ sledrun.cachet = 'Tiroler Rodelbahngütesielgel mittelschwer 2010'
+ sledrun.information_web = 'http://example.com'
+ sledrun.information_phone = '+4364412345678'
+ sledrun.image = 'Sicht_von_unten.jpg'
+ sledrun.show_in_overview = True
+ sledrun.forum_id = 65
+ rodelbahnbox = sledrun_to_rodelbahnbox(sledrun)
+ self.assertEqual(rodelbahnbox['Position'], LonLat(lon=13.5, lat=50.7))
+ self.assertEqual(rodelbahnbox['Position oben'], LonLat(12.2, 49.8))
+ self.assertEqual(rodelbahnbox['Höhe oben'], 3456)
+ self.assertEqual(rodelbahnbox['Position unten'], LonLat(9.89, 51.2))
+ self.assertEqual(rodelbahnbox['Höhe unten'], 2075)
+ self.assertEqual(rodelbahnbox['Länge'], 9644)
+ self.assertEqual(rodelbahnbox['Schwierigkeit'], 3)
+ self.assertEqual(rodelbahnbox['Lawinen'], 2)
+ self.assertEqual(rodelbahnbox['Betreiber'], 'McRodel')
+ self.assertEqual(rodelbahnbox['Öffentliche Anreise'], 3)
+ self.assertEqual(rodelbahnbox['Aufstieg möglich'], True)
+ self.assertEqual(rodelbahnbox['Aufstieg getrennt'], (0.5, 'Nur unterer Teil'))
+ self.assertEqual(rodelbahnbox['Gehzeit'], 77)
+ self.assertEqual(rodelbahnbox['Aufstiegshilfe'], [('Sessellift', None)])
+ self.assertEqual(rodelbahnbox['Beleuchtungsanlage'], (1.0, 'Schlecht beleuchtet'))
+ self.assertEqual(rodelbahnbox['Beleuchtungstage'], (6, 'Mo-Sa'))
+ self.assertEqual(rodelbahnbox['Rodelverleih'], (True, 'In der Hütte'))
+ self.assertEqual(rodelbahnbox['Gütesiegel'], 'Tiroler Rodelbahngütesielgel mittelschwer 2010')
+ self.assertEqual(rodelbahnbox['Webauskunft'], 'http://example.com')
+ self.assertEqual(rodelbahnbox['Bild'], 'Sicht_von_unten.jpg')
+ self.assertEqual(rodelbahnbox['In Übersichtskarte'], True)
+ self.assertEqual(rodelbahnbox['Forumid'], 65)
- def test_RodelbahnboxValidator(self):
- v = wrpylib.wrmwmarkup.RodelbahnboxValidator()
- wikitext = textwrap.dedent('''\
- {{Rodelbahnbox
- | Position = 47.309820 N 9.986508 E
- | Position oben =
- | Höhe oben = 1244
- | Position unten =
- | Höhe unten = 806
- | Länge = 5045
- | Schwierigkeit =
- | Lawinen = gelegentlich
- | Betreiber =
- | Öffentliche Anreise = Ja
- | Aufstieg möglich = Nein
- | Aufstieg getrennt = Nein
- | Gehzeit = 105
- | Aufstiegshilfe = Nein
- | Beleuchtungsanlage = Nein
- | Beleuchtungstage =
- | Rodelverleih = Ja
- | Gütesiegel =
- | Webauskunft =
- | Telefonauskunft = +43-664-1808482 (Bergkristallhütte)
- | Bild = Rodelbahn Bergkristallhütte 2009-03-03.jpg
- | In Übersichtskarte = Ja
- | Forumid = 72
- }}''')
- sledrun = v.to_python(wikitext)
- wikitext2 = v.from_python(sledrun)
- assert wikitext == wikitext2
- wikitext = textwrap.dedent('''\
- {{Rodelbahnbox
- | Position =
- | Position oben =
- | Höhe oben =
- | Position unten =
- | Höhe unten =
- | Länge =
- | Schwierigkeit =
- | Lawinen =
- | Betreiber =
- | Öffentliche Anreise =
- | Aufstieg möglich =
- | Aufstieg getrennt =
- | Gehzeit =
- | Aufstiegshilfe =
- | Beleuchtungsanlage =
- | Beleuchtungstage =
- | Rodelverleih =
- | Gütesiegel =
- | Webauskunft =
- | Telefonauskunft =
- | Bild =
- | In Übersichtskarte =
- | Forumid =
- }}''')
- sledrun = v.to_python(wikitext)
- wikitext2 = v.from_python(sledrun)
- assert wikitext == wikitext2
+class TestInn(unittest.TestCase):
+ def test_inn_from_gasthausbox(self):
+ class Inn:
+ pass
+ gasthausbox = collections.OrderedDict()
+ gasthausbox['Position'] = LonLat(11.015883, 9.876000)
+ gasthausbox['Höhe'] = 2145
+ gasthausbox['Betreiber'] = 'Max Mustermann'
+ gasthausbox['Sitzplätze'] = 30
+ gasthausbox['Übernachtung'] = (True, '2 Zimmer')
+ gasthausbox['Rauchfrei'] = 0.5
+ gasthausbox['Rodelverleih'] = (True, '6 Euro')
+ gasthausbox['Handyempfang'] = [('A1', None), ('Drei', 'schlecht')]
+ gasthausbox['Homepage'] = (True, 'http://www.graf-ferdinand.at/')
+ gasthausbox['E-Mail'] = [(('max.mustermann@graf-ferdinand.at', False), None), (('ich@example.com', True), 'privat')]
+ gasthausbox['Telefon'] = [('+43-5039-21666', None), ('+43-686-4134880', 'Sommer')]
+ gasthausbox['Bild'] = 'Gasthaus_Graf_Ferdinand_Haus_01.jpg'
+ gasthausbox['Rodelbahnen'] = ['[[Finstertaler Speicher]]', '[[Birgitzer Alm]]']
+ inn = Inn()
+ inn_from_gasthausbox(gasthausbox, inn)
+ self.assertEqual(inn.position_latitude, 9.876000)
+ self.assertEqual(inn.position_longitude, 11.015883)
+ self.assertEqual(inn.position_elevation, 2145)
+ self.assertEqual(inn.operator, 'Max Mustermann')
+ self.assertEqual(inn.seats, 30)
+ self.assertEqual(inn.overnight, True)
+ self.assertEqual(inn.overnight_comment, '2 Zimmer')
+ self.assertEqual(inn.smoker_area, True)
+ self.assertEqual(inn.nonsmoker_area, True)
+ self.assertEqual(inn.sled_rental, True)
+ self.assertEqual(inn.sled_rental_comment, '6 Euro')
+ self.assertEqual(inn.mobile_provider, 'A1; Drei (schlecht)')
+ self.assertEqual(inn.homepage, 'http://www.graf-ferdinand.at/')
+ self.assertEqual(inn.email_list, 'max.mustermann@graf-ferdinand.at; ich(at)example.com (privat)')
+ self.assertEqual(inn.phone_list, '+43-5039-21666; +43-686-4134880 (Sommer)')
+ self.assertEqual(inn.image, 'Gasthaus_Graf_Ferdinand_Haus_01.jpg')
+ self.assertEqual(inn.sledding_list, '[[Finstertaler Speicher]]; [[Birgitzer Alm]]')
- def test_gasthausbox_to_inn(self):
- wikitext = '''{{Gasthausbox
- | Position = 47.295549 N 9.986970 E
- | Höhe = 1250
- | Betreiber =
- | Sitzplätze =
- | Übernachtung =
- | Rauchfrei = Nein
- | Rodelverleih =
- | Handyempfang = A1; T-Mobile/Telering
- | Homepage = http://www.bergkristallhuette.com/
- | E-Mail = bergkristallhuette@gmx.at
- | Telefon = +43-664-1808482
- | Bild = Bergkritsallhütte 2009-02-07.JPG
- | Rodelbahnen = [[Bergkristallhütte]]
- }}
- Die Bergkristallhütte ist Teil des Boden-Vorsäß.'''
- start, end, inn = wrpylib.wrmwmarkup.gasthausbox_to_inn(wikitext)
- wrpylib.wrmwmarkup.inn_to_gasthausbox(inn)
+ def test_inn_to_gasthausbox(self):
+ class Inn:
+ pass
+ inn = Inn()
+ inn.position_latitude = 9.876000
+ inn.position_longitude = 11.015883
+ inn.position_elevation = 2145
+ inn.operator = 'Max Mustermann'
+ inn.seats = 30
+ inn.overnight = True
+ inn.overnight_comment = '2 Zimmer'
+ inn.smoker_area = True
+ inn.nonsmoker_area = True
+ inn.sled_rental = True
+ inn.sled_rental_comment = '6 Euro'
+ inn.mobile_provider = 'A1; Drei (schlecht)'
+ inn.homepage = 'http://www.graf-ferdinand.at/'
+ inn.email_list = 'max.mustermann@graf-ferdinand.at; ich(at)example.com (privat)'
+ inn.phone_list = '+43-5039-21666; +43-686-4134880 (Sommer)'
+ inn.image = 'Gasthaus_Graf_Ferdinand_Haus_01.jpg'
+ inn.sledding_list = '[[Finstertaler Speicher]]; [[Birgitzer Alm]]'
+ gasthausbox = inn_to_gasthausbox(inn)
+ self.assertEqual(gasthausbox['Position'], LonLat(11.015883, 9.876000))
+ self.assertEqual(gasthausbox['Höhe'], 2145)
+ self.assertEqual(gasthausbox['Betreiber'], 'Max Mustermann')
+ self.assertEqual(gasthausbox['Sitzplätze'], 30)
+ self.assertEqual(gasthausbox['Übernachtung'], (True, '2 Zimmer'))
+ self.assertEqual(gasthausbox['Rauchfrei'], 0.5)
+ self.assertEqual(gasthausbox['Rodelverleih'], (True, '6 Euro'))
+ self.assertEqual(gasthausbox['Handyempfang'], [('A1', None), ('Drei', 'schlecht')])
+ self.assertEqual(gasthausbox['Homepage'], (True, 'http://www.graf-ferdinand.at/'))
+ self.assertEqual(gasthausbox['E-Mail'], [(('max.mustermann@graf-ferdinand.at', False), None), (('ich@example.com', True), 'privat')])
+ self.assertEqual(gasthausbox['Telefon'], [('+43-5039-21666', None), ('+43-686-4134880', 'Sommer')])
+ self.assertEqual(gasthausbox['Bild'], 'Gasthaus_Graf_Ferdinand_Haus_01.jpg')
+ self.assertEqual(gasthausbox['Rodelbahnen'], ['[[Finstertaler Speicher]]', '[[Birgitzer Alm]]'])
+ def test_inn_from_gasthausbox_no(self):
+ class Inn:
+ pass
+ gasthausbox = collections.OrderedDict()
+ gasthausbox['Position'] = LonLat(None, None)
+ gasthausbox['Höhe'] = None
+ gasthausbox['Betreiber'] = None
+ gasthausbox['Sitzplätze'] = None
+ gasthausbox['Übernachtung'] = (False, None)
+ gasthausbox['Rauchfrei'] = 0.0
+ gasthausbox['Rodelverleih'] = (False, None)
+ gasthausbox['Handyempfang'] = []
+ gasthausbox['Homepage'] = (False, None)
+ gasthausbox['E-Mail'] = []
+ gasthausbox['Telefon'] = []
+ gasthausbox['Bild'] = None
+ gasthausbox['Rodelbahnen'] = []
+ inn = Inn()
+ inn_from_gasthausbox(gasthausbox, inn)
+ self.assertEqual(inn.position_latitude, None)
+ self.assertEqual(inn.position_longitude, None)
+ self.assertEqual(inn.position_elevation, None)
+ self.assertEqual(inn.operator, None)
+ self.assertEqual(inn.seats, None)
+ self.assertEqual(inn.overnight, False)
+ self.assertEqual(inn.overnight_comment, None)
+ self.assertEqual(inn.smoker_area, True)
+ self.assertEqual(inn.nonsmoker_area, False)
+ self.assertEqual(inn.sled_rental, False)
+ self.assertEqual(inn.sled_rental_comment, None)
+ self.assertEqual(inn.mobile_provider, 'Nein')
+ self.assertEqual(inn.homepage, 'Nein')
+ self.assertEqual(inn.email_list, 'Nein')
+ self.assertEqual(inn.phone_list, 'Nein')
+ self.assertEqual(inn.image, None)
+ self.assertEqual(inn.sledding_list, 'Nein')
- def test_GasthausboxDictConverter(self):
- v = wrpylib.wrmwmarkup.GasthausboxDictConverter()
- other = collections.OrderedDict([
- ('Position', (47.295549, 9.986970)),
- ('Höhe', 1250),
- ('Betreiber', None),
- ('Sitzplätze', None),
- ('Übernachtung', (None, None)),
- ('Rauchfrei', (True, False)),
- ('Rodelverleih', (None, None)),
- ('Handyempfang', 'A1; T-Mobile/Telering'),
- ('Homepage', 'http://www.bergkristallhuette.com/'),
- ('E-Mail', 'bergkristallhuette@gmx.at'),
- ('Telefon', '+43-664-1808482'),
- ('Bild', 'Bergkritsallhütte 2009-02-07.JPG'),
- ('Rodelbahnen', '[[Bergkristallhütte]]')])
- inn = v.to_python(other)
- assert inn.homepage == 'http://www.bergkristallhuette.com/'
- other2 = v.from_python(inn)
- assert other == other2
+ def test_inn_to_gasthausbox_no(self):
+ class Inn:
+ pass
+ inn = Inn()
+ inn.position_latitude = None
+ inn.position_longitude = None
+ inn.position_elevation = None
+ inn.operator = None
+ inn.seats = None
+ inn.overnight = False
+ inn.overnight_comment = None
+ inn.smoker_area = True
+ inn.nonsmoker_area = False
+ inn.sled_rental = False
+ inn.sled_rental_comment = None
+ inn.mobile_provider = 'Nein'
+ inn.homepage = 'Nein'
+ inn.email_list = 'Nein'
+ inn.phone_list = 'Nein'
+ inn.image = None
+ inn.sledding_list = 'Nein'
+ gasthausbox = inn_to_gasthausbox(inn)
+ self.assertEqual(gasthausbox['Position'], LonLat(None, None))
+ self.assertEqual(gasthausbox['Höhe'], None)
+ self.assertEqual(gasthausbox['Betreiber'], None)
+ self.assertEqual(gasthausbox['Sitzplätze'], None)
+ self.assertEqual(gasthausbox['Übernachtung'], (False, None))
+ self.assertEqual(gasthausbox['Rauchfrei'], 0.0)
+ self.assertEqual(gasthausbox['Rodelverleih'], (False, None))
+ self.assertEqual(gasthausbox['Handyempfang'], [])
+ self.assertEqual(gasthausbox['Homepage'], (False, None))
+ self.assertEqual(gasthausbox['E-Mail'], [])
+ self.assertEqual(gasthausbox['Telefon'], [])
+ self.assertEqual(gasthausbox['Bild'], None)
+ self.assertEqual(gasthausbox['Rodelbahnen'], [])
+ def test_inn_from_gasthausbox_none(self):
+ class Inn:
+ pass
+ gasthausbox = collections.OrderedDict()
+ gasthausbox['Position'] = LonLat(None, None)
+ gasthausbox['Höhe'] = None
+ gasthausbox['Betreiber'] = None
+ gasthausbox['Sitzplätze'] = None
+ gasthausbox['Übernachtung'] = (None, None)
+ gasthausbox['Rauchfrei'] = None
+ gasthausbox['Rodelverleih'] = (None, None)
+ gasthausbox['Handyempfang'] = None
+ gasthausbox['Homepage'] = (None, None)
+ gasthausbox['E-Mail'] = None
+ gasthausbox['Telefon'] = None
+ gasthausbox['Bild'] = None
+ gasthausbox['Rodelbahnen'] = None
+ inn = Inn()
+ inn_from_gasthausbox(gasthausbox, inn)
+ self.assertEqual(inn.position_latitude, None)
+ self.assertEqual(inn.position_longitude, None)
+ self.assertEqual(inn.position_elevation, None)
+ self.assertEqual(inn.operator, None)
+ self.assertEqual(inn.seats, None)
+ self.assertEqual(inn.overnight, None)
+ self.assertEqual(inn.overnight_comment, None)
+ self.assertEqual(inn.smoker_area, None)
+ self.assertEqual(inn.nonsmoker_area, None)
+ self.assertEqual(inn.sled_rental, None)
+ self.assertEqual(inn.sled_rental_comment, None)
+ self.assertEqual(inn.mobile_provider, None)
+ self.assertEqual(inn.homepage, None)
+ self.assertEqual(inn.email_list, None)
+ self.assertEqual(inn.phone_list, None)
+ self.assertEqual(inn.image, None)
+ self.assertEqual(inn.sledding_list, None)
- def test_GasthausboxValidator(self):
- v = wrpylib.wrmwmarkup.GasthausboxValidator()
- wikitext = textwrap.dedent('''\
- {{Gasthausbox
- | Position = 47.295549 N 9.986970 E
- | Höhe = 1250
- | Betreiber =
- | Sitzplätze =
- | Übernachtung =
- | Rauchfrei = Nein
- | Rodelverleih =
- | Handyempfang = A1; T-Mobile/Telering
- | Homepage = http://www.bergkristallhuette.com/
- | E-Mail = bergkristallhuette@gmx.at
- | Telefon = +43-664-1808482
- | Bild = Bergkritsallhütte 2009-02-07.JPG
- | Rodelbahnen = [[Bergkristallhütte]]
- }}''')
- inn = v.to_python(wikitext)
- wikitext2 = v.from_python(inn)
- assert wikitext == wikitext2
+ def test_inn_to_gasthausbox_none(self):
+ class Inn:
+ pass
+ inn = Inn()
+ inn.position_latitude = None
+ inn.position_longitude = None
+ inn.position_elevation = None
+ inn.operator = None
+ inn.seats = None
+ inn.overnight = None
+ inn.overnight_comment = None
+ inn.smoker_area = None
+ inn.nonsmoker_area = None
+ inn.sled_rental = None
+ inn.sled_rental_comment = None
+ inn.mobile_provider = None
+ inn.homepage = None
+ inn.email_list = None
+ inn.phone_list = None
+ inn.image = None
+ inn.sledding_list = None
+ gasthausbox = inn_to_gasthausbox(inn)
+ self.assertEqual(gasthausbox['Position'], LonLat(None, None))
+ self.assertEqual(gasthausbox['Höhe'], None)
+ self.assertEqual(gasthausbox['Betreiber'], None)
+ self.assertEqual(gasthausbox['Sitzplätze'], None)
+ self.assertEqual(gasthausbox['Übernachtung'], (None, None))
+ self.assertEqual(gasthausbox['Rauchfrei'], None)
+ self.assertEqual(gasthausbox['Rodelverleih'], (None, None))
+ self.assertEqual(gasthausbox['Handyempfang'], None)
+ self.assertEqual(gasthausbox['Homepage'], (None, None))
+ self.assertEqual(gasthausbox['E-Mail'], None)
+ self.assertEqual(gasthausbox['Telefon'], None)
+ self.assertEqual(gasthausbox['Bild'], None)
+ self.assertEqual(gasthausbox['Rodelbahnen'], None)
- def test_googlemap_to_wrmap(self):
- wikitext = '''
- <googlemap version="0.9" lat="47.113291" lon="11.272337" zoom="15" height="450">
- (Parkplatz)47.114958,11.266026
- Erster Parkplatz
+class TestLonlatEle(unittest.TestCase):
+ def test_lonlat_ele_from_template(self):
+ template = mwparserfromhell.parse('{{Position oben|46.942239 N 11.468819 E|1866}}').filter_templates()[0]
+ lonlat, ele = lonlat_ele_from_template(template)
+ self.assertEqual(LonLat(11.468819, 46.942239), lonlat)
+ self.assertEqual(1866, ele)
- (Gasthaus) 47.114715, 11.266262, Alt Bärnbad (Gasthaus)
- 6#FF014E9A
- 47.114715,11.266262
- 47.114135,11.268381
- 47.113421,11.269322
- 47.11277,11.269979
- 47.112408,11.271119
- </googlemap>
- '''
- attributes, coords, paths = wrpylib.mwmarkup.parse_googlemap(wikitext)
- json = wrpylib.wrmwmarkup.googlemap_to_wrmap(attributes, coords, paths)
- assert json['properties']['lon'] == 11.272337
- assert json['properties']['lat'] == 47.113291
- assert json['properties']['zoom'] == 15
- assert json['properties']['height'] == 450
- assert json['features'][0]['properties']['type'] == 'parkplatz'
- assert json['features'][0]['properties']['name'] == 'Erster Parkplatz'
- assert json['features'][0]['geometry']['coordinates'] == [11.266026, 47.114958]
- assert json['features'][1]['properties']['type'] == 'gasthaus'
- assert json['features'][1]['properties']['name'] == 'Alt Bärnbad (Gasthaus)'
- assert json['features'][1]['geometry']['coordinates'] == [11.266262, 47.114715]
- assert json['features'][2]['properties']['type'] == 'rodelbahn'
- assert json['features'][2]['geometry']['coordinates'] == [
- [11.266262, 47.114715],
- [11.268381, 47.114135],
- [11.269322, 47.113421],
- [11.269979, 47.11277],
- [11.271119, 47.112408]]
+ def test_latlon_ele_to_template(self):
+ template = latlon_ele_to_template((LonLat(11.468819, 46.942239), 1866), 'Position oben')
+ self.assertEqual('{{Position oben|46.942239 N 11.468819 E|1866}}', template)
+class TestWrMap(unittest.TestCase):
def test_parse_wrmap(self):
wikitext = '''
<wrmap lat="47.2417134" lon="11.21408895" zoom="14" width="700" height="400">
- <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
+ <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 11.190454</gasthaus>
<parkplatz>47.245789 11.238971</parkplatz>
- <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>
+ <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 11.238283</haltestelle>
<rodelbahn>
47.238587 11.203360
47.244951 11.230868
assert json['properties']['width'] == 700
assert json['properties']['height'] == 400
assert json['features'][0]['properties']['type'] == 'gasthaus'
- assert json['features'][0]['properties']['name'] == 'Rosskogelhütte'
- assert json['features'][0]['properties']['wiki'] == 'Rosskogelhütte'
+ assert json['features'][0]['properties']['name'] == 'Rosskogelhütte'
+ assert json['features'][0]['properties']['wiki'] == 'Rosskogelhütte'
assert json['features'][0]['geometry']['coordinates'] == [11.190454, 47.240689]
assert json['features'][1]['properties']['type'] == 'parkplatz'
assert json['features'][1]['geometry']['coordinates'] == [11.238971, 47.245789]
assert json['features'][2]['properties']['type'] == 'haltestelle'
- assert json['features'][2]['properties']['name'] == 'Oberperfuss Rangger Köpfl Lift'
+ assert json['features'][2]['properties']['name'] == 'Oberperfuss Rangger Köpfl Lift'
assert json['features'][2]['geometry']['coordinates'] == [11.238283, 47.245711]
assert json['features'][3]['properties']['type'] == 'rodelbahn'
assert json['features'][3]['geometry']['coordinates'] == [
[11.230868, 47.244951],
[11.237853, 47.245470]]
-
def test_create_wrmap(self):
geojson = {
'type': 'FeatureCollection',
'geometry': {
'type': 'Point',
'coordinates': [11.190454, 47.240689]},
- 'properties': {'type': 'gasthaus', 'name': 'Rosskogelhütte', 'wiki': 'Rosskogelhütte'}
+ 'properties': {'type': 'gasthaus', 'name': 'Rosskogelhütte', 'wiki': 'Rosskogelhütte'}
}, {
'type': 'Feature',
'geometry': {
'geometry': {
'type': 'Point',
'coordinates': [11.238283, 47.245711]},
- 'properties': {'type': 'haltestelle', 'name': 'Oberperfuss Rangger Köpfl Lift'}
+ 'properties': {'type': 'haltestelle', 'name': 'Oberperfuss Rangger Köpfl Lift'}
}, {
'type': 'Feature',
'geometry': {
assert wikitext == textwrap.dedent('''\
<wrmap height="400" lat="47.241713" lon="11.214089" width="700" zoom="14">
- <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 N 11.190454 E</gasthaus>
+ <gasthaus name="Rosskogelhütte" wiki="Rosskogelhütte">47.240689 N 11.190454 E</gasthaus>
<parkplatz>47.245789 N 11.238971 E</parkplatz>
- <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 N 11.238283 E</haltestelle>
+ <haltestelle name="Oberperfuss Rangger Köpfl Lift">47.245711 N 11.238283 E</haltestelle>
<rodelbahn>
47.238587 N 11.203360 E
</rodelbahn>
</wrmap>''')
-