address @link2xt comments

This commit is contained in:
holger krekel
2019-11-03 00:06:30 +01:00
parent 4eb068613d
commit c5f64d2988
4 changed files with 11 additions and 19 deletions

View File

@@ -404,15 +404,14 @@ class Chat(object):
contact_id = contact.id
dc_array = lib.dc_get_locations(self._dc_context, self.id, contact_id, time_from, time_to)
locations = []
for i in range(0, lib.dc_array_get_cnt(dc_array)):
locations.append(Location(
return [
Location(
latitude=lib.dc_array_get_latitude(dc_array, i),
longitude=lib.dc_array_get_longitude(dc_array, i),
accuracy=lib.dc_array_get_accuracy(dc_array, i),
timestamp=datetime.utcfromtimestamp(lib.dc_array_get_timestamp(dc_array, i)),
))
return locations
timestamp=datetime.utcfromtimestamp(lib.dc_array_get_timestamp(dc_array, i)))
for i in range(lib.dc_array_get_cnt(dc_array))
]
class Location:

View File

@@ -843,7 +843,7 @@ class TestOnlineAccount:
ac2._evlogger.get_matching("DC_EVENT_INCOMING_MSG") # text message with location
locations = chat2.get_locations()
assert len(locations) >= 1
assert len(locations) == 1
assert locations[0].latitude == 2.0
assert locations[0].longitude == 3.0
assert locations[0].accuracy == 0.5
@@ -851,7 +851,7 @@ class TestOnlineAccount:
contact = ac2.create_contact(ac1.get_config("addr"))
locations2 = chat2.get_locations(contact=contact)
assert len(locations2) >= 1
assert len(locations2) == 1
assert locations2 == locations
contact = ac2.create_contact("nonexisting@example.org")