@@ -36,7 +36,7 @@ def test_toggle_location_services(self):
36
36
assert isinstance (driver .toggle_location_services (), WebDriver )
37
37
38
38
@httpretty .activate
39
- def test_set_location (self ):
39
+ def test_set_location_float (self ):
40
40
driver = android_w3c_driver ()
41
41
httpretty .register_uri (
42
42
httpretty .POST ,
@@ -49,6 +49,34 @@ def test_set_location(self):
49
49
assert abs (d ['location' ]['longitude' ] - 22.2 ) <= FLT_EPSILON
50
50
assert abs (d ['location' ]['altitude' ] - 33.3 ) <= FLT_EPSILON
51
51
52
+ @httpretty .activate
53
+ def test_set_location_str (self ):
54
+ driver = android_w3c_driver ()
55
+ httpretty .register_uri (
56
+ httpretty .POST ,
57
+ appium_command ('/session/1234567890/location' )
58
+ )
59
+ assert isinstance (driver .set_location ('11.1' , '22.2' , '33.3' ), WebDriver )
60
+
61
+ d = get_httpretty_request_body (httpretty .last_request ())
62
+ assert d ['location' ]['latitude' ] == '11.1'
63
+ assert d ['location' ]['longitude' ] == '22.2'
64
+ assert d ['location' ]['altitude' ] == '33.3'
65
+
66
+ @httpretty .activate
67
+ def test_set_location_without_altitude (self ):
68
+ driver = android_w3c_driver ()
69
+ httpretty .register_uri (
70
+ httpretty .POST ,
71
+ appium_command ('/session/1234567890/location' )
72
+ )
73
+ assert isinstance (driver .set_location (11.1 , 22.2 ), WebDriver )
74
+
75
+ d = get_httpretty_request_body (httpretty .last_request ())
76
+ assert abs (d ['location' ]['latitude' ] - 11.1 ) <= FLT_EPSILON
77
+ assert abs (d ['location' ]['longitude' ] - 22.2 ) <= FLT_EPSILON
78
+ assert d ['location' ].get ('altitude' ) == None
79
+
52
80
@httpretty .activate
53
81
def test_location (self ):
54
82
driver = android_w3c_driver ()
0 commit comments