-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathtest_geo_point.py
More file actions
47 lines (30 loc) · 1.12 KB
/
test_geo_point.py
File metadata and controls
47 lines (30 loc) · 1.12 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
# coding: utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from nose.tools import assert_raises # type: ignore
from nose.tools import eq_ # type: ignore
from leancloud import GeoPoint
__author__ = "asaka <lan@leancloud.rocks>"
def test_invalid(): # type: () -> None
assert_raises(ValueError, GeoPoint, 0, 200)
assert_raises(ValueError, GeoPoint, -100, 10)
def test_setter(): # type: () -> None
p = GeoPoint()
p.latitude = 10
assert p.latitude == 10
def f():
p.longitude = 200
assert_raises(ValueError, f)
def test_dump(): # type: () -> None
p = GeoPoint(10, 20)
assert p.dump() == {"latitude": 10, "__type": "GeoPoint", "longitude": 20}
def test_radians_to(): # type: () -> None
assert GeoPoint(0, 0).radians_to(GeoPoint(10, 10)) - 0.24619691677893205 < 0.00001
assert (
GeoPoint(10, 10).radians_to(GeoPoint(14.5, 24.5)) - 0.25938444522905957
< 0.00001
)
def test_eq(): # type: () -> None
eq_(GeoPoint(0, 1) == GeoPoint(0, 1), True)
eq_(GeoPoint(1, 1) == GeoPoint(1, 0), False)