forked from DinoTools/python-overpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_json.py
More file actions
74 lines (59 loc) · 2.02 KB
/
Copy pathtest_json.py
File metadata and controls
74 lines (59 loc) · 2.02 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import pytest
import overpy
from tests.base_class import BaseTestNodes, BaseTestRelation, BaseTestWay
from tests.base_class import read_file
class TestNodes(BaseTestNodes):
def test_node01(self):
api = overpy.Overpass()
result = api.parse_json(read_file("json/node-01.json"))
self._test_node01(result)
class TestRelation(BaseTestRelation):
def test_relation01(self):
api = overpy.Overpass()
result = api.parse_json(read_file("json/relation-01.json"))
self._test_relation01(result)
def test_relation02(self):
api = overpy.Overpass()
result = api.parse_json(read_file("json/relation-02.json"))
self._test_relation02(result)
class TestWay(BaseTestWay):
def test_way01(self):
api = overpy.Overpass()
result = api.parse_json(read_file("json/way-01.json"))
self._test_way01(result)
def test_way02(self):
api = overpy.Overpass()
result = api.parse_json(read_file("json/way-02.json"))
self._test_way02(result)
class TestDataError(object):
def test_element_wrong_type(self):
with pytest.raises(overpy.exception.ElementDataWrongType):
overpy.Node.from_json(
{
"type": "foo"
}
)
with pytest.raises(overpy.exception.ElementDataWrongType):
overpy.Relation.from_json(
{
"type": "foo"
}
)
with pytest.raises(overpy.exception.ElementDataWrongType):
overpy.RelationNode.from_json(
{
"type": "foo"
}
)
with pytest.raises(overpy.exception.ElementDataWrongType):
overpy.RelationWay.from_json(
{
"type": "foo"
}
)
with pytest.raises(overpy.exception.ElementDataWrongType):
overpy.Way.from_json(
{
"type": "foo"
}
)