8000 Cast set_location arguments to float by mykola-mokhnach · Pull Request #332 · appium/python-client · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions appium/webdriver/extensions/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def set_location(self, latitude, longitude, altitude):
"""
data = {
"location": {
"latitude": str(latitude),
"longitude": str(longitude),
"altitude": str(altitude)
"latitude": float(latitude),
"longitude": float(longitude),
"altitude": float(altitude)
}
}
self.execute(Command.SET_LOCATION, data)
Expand Down
14 changes: 8 additions & 6 deletions test/unit/webdriver/device/location_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

from appium.webdriver.webdriver import WebDriver

FLT_EPSILON = 1e-9


class TestWebDriverLocation(object):

Expand All @@ -44,9 +46,9 @@ def test_set_location(self):
assert isinstance(driver.set_location(11.1, 22.2, 33.3), WebDriver) == True

d = get_httpretty_request_body(httpretty.last_request())
assert d['location']['latitude'] == '11.1'
assert d['location']['longitude'] == '22.2'
assert d['location']['altitude'] == '33.3'
assert abs(d['location']['latitude'] - 11.1) <= FLT_EPSILON
assert abs(d['location']['longitude'] - 22.2) <= FLT_EPSILON
assert abs(d['location']['altitude'] - 33.3) <= FLT_EPSILON

@httpretty.activate
def test_location(self):
Expand All @@ -57,6 +59,6 @@ def test_location(self):
body='{"value": {"latitude": 11.1, "longitude": 22.2, "altitude": 33.3}}'
)
val = driver.location
assert val['latitude'] == 11.1
assert val['longitude'] == 22.2
assert val['altitude'] == 33.3
assert abs(val['latitude'] - 11.1) <= FLT_EPSILON
assert abs(val['longitude'] - 22.2) <= FLT_EPSILON
assert abs(val['altitude'] - 33.3) <= FLT_EPSILON
0