This repository has been archived by the owner on Feb 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
maproot_test.py
73 lines (66 loc) · 2.6 KB
/
maproot_test.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python
# Copyright 2012 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at: http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distrib-
# uted under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
# specific language governing permissions and limitations under the License.
"""Tests for maproot.py."""
__author__ = '[email protected] (Cihat Imamoglu)'
import maproot
import test_utils
class MaprootTest(test_utils.BaseTest):
def testGetAllLayers(self):
# Not a complete or valid MapRoot structure but is enough for testing
# relevant parts.
maproot_object = {'layers': [
{'type': 'KML'},
{'type': 'FOLDER',
'sublayers': [
{'type': 'FOLDER',
'sublayers': [
{'type': 'GEORSS'},
{'type': 'MAP_DATA'},
{'type': 'GOOGLE_MAPS_ENGINE_LITE_OR_PRO'}
]},
{'type': 'FUSION'}]
},
{'type': 'TILE'},
{'type': 'FOLDER'}]}
expected = ['FUSION', 'GEORSS', 'GOOGLE_MAPS_ENGINE_LITE_OR_PRO', 'KML',
'MAP_DATA', 'TILE']
self.assertEquals(expected, sorted(
[x['type'] for x in maproot.GetAllLayers(maproot_object)]))
self.assertEquals([], maproot.GetAllLayers({'nolayers': {'type': 'KML'}}))
def testGetSourceAddress(self):
self.assertEquals('GEORSS:abc', maproot.GetSourceAddress(
{'type': 'GEORSS', 'source': {'georss': {'url': 'abc'}}}
))
self.assertEquals('KML:xyz', maproot.GetSourceAddress(
{'type': 'KML', 'source': {'kml': {'url': 'xyz'}}}
))
self.assertEquals('WMS:tuv', maproot.GetSourceAddress(
{'type': 'WMS',
'source': {'wms': {'url': 'tuv'}}}
))
self.assertEquals(
'GOOGLE_MAPS_ENGINE_LITE_OR_PRO:def',
maproot.GetSourceAddress(
{'type': 'GOOGLE_MAPS_ENGINE_LITE_OR_PRO',
'source': {'google_maps_engine_lite_or_pro': {'url': 'def'}}}
))
self.assertEquals(None, maproot.GetSourceAddress(
{'type': 'GOOGLE_MAP_DATA', 'source': {'google_map_data': 'ab'}}
))
self.assertEquals(None, maproot.GetSourceAddress(
{'type': 'GOOGLE_TRAFFIC'}
))
self.assertEquals(None, maproot.GetSourceAddress(
{'type': 'GOOGLE_PLACES'}
))
if __name__ == '__main__':
test_utils.main()