mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 15:36:30 +03:00
extend and fix python/test side of location streaming
This commit is contained in:
@@ -410,7 +410,7 @@ class Chat(object):
|
|||||||
latitude=lib.dc_array_get_latitude(dc_array, i),
|
latitude=lib.dc_array_get_latitude(dc_array, i),
|
||||||
longitude=lib.dc_array_get_longitude(dc_array, i),
|
longitude=lib.dc_array_get_longitude(dc_array, i),
|
||||||
accuracy=lib.dc_array_get_accuracy(dc_array, i),
|
accuracy=lib.dc_array_get_accuracy(dc_array, i),
|
||||||
timestamp=datetime.utcfromtimestamp(lib.dc_array_get_accuracy(dc_array, i)),
|
timestamp=datetime.utcfromtimestamp(lib.dc_array_get_timestamp(dc_array, i)),
|
||||||
))
|
))
|
||||||
return locations
|
return locations
|
||||||
|
|
||||||
@@ -422,3 +422,6 @@ class Location:
|
|||||||
self.longitude = longitude
|
self.longitude = longitude
|
||||||
self.accuracy = accuracy
|
self.accuracy = accuracy
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return self.__dict__ == other.__dict__
|
||||||
|
|||||||
@@ -811,6 +811,7 @@ class TestOnlineAccount:
|
|||||||
assert chat.get_profile_image() is None
|
assert chat.get_profile_image() is None
|
||||||
|
|
||||||
def test_send_receive_locations(self, acfactory, lp):
|
def test_send_receive_locations(self, acfactory, lp):
|
||||||
|
now = datetime.utcnow()
|
||||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||||
|
|
||||||
lp.sec("ac1: create chat with ac2")
|
lp.sec("ac1: create chat with ac2")
|
||||||
@@ -829,7 +830,7 @@ class TestOnlineAccount:
|
|||||||
assert chat1.is_sending_locations()
|
assert chat1.is_sending_locations()
|
||||||
ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")
|
ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")
|
||||||
|
|
||||||
ac1.set_location(latitude=2.0, longitude=3.0)
|
ac1.set_location(latitude=2.0, longitude=3.0, accuracy=0.5)
|
||||||
ac1._evlogger.get_matching("DC_EVENT_LOCATION_CHANGED")
|
ac1._evlogger.get_matching("DC_EVENT_LOCATION_CHANGED")
|
||||||
chat1.send_text("hello")
|
chat1.send_text("hello")
|
||||||
ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")
|
ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")
|
||||||
@@ -841,9 +842,21 @@ class TestOnlineAccount:
|
|||||||
ac2._evlogger.get_matching("DC_EVENT_LOCATION_CHANGED")
|
ac2._evlogger.get_matching("DC_EVENT_LOCATION_CHANGED")
|
||||||
ac2._evlogger.get_matching("DC_EVENT_INCOMING_MSG") # text message with location
|
ac2._evlogger.get_matching("DC_EVENT_INCOMING_MSG") # text message with location
|
||||||
|
|
||||||
# contact = ac2.create_contact(ac1.get_config("addr"))
|
locations = chat2.get_locations()
|
||||||
locations = chat2.get_locations() # XXX per contact
|
|
||||||
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
|
||||||
|
assert locations[0].timestamp > now
|
||||||
|
|
||||||
|
contact = ac2.create_contact(ac1.get_config("addr"))
|
||||||
|
locations2 = chat2.get_locations(contact=contact)
|
||||||
|
assert len(locations2) >= 1
|
||||||
|
assert locations2 == locations
|
||||||
|
|
||||||
|
contact = ac2.create_contact("nonexisting@example.org")
|
||||||
|
locations3 = chat2.get_locations(contact=contact)
|
||||||
|
assert not locations3
|
||||||
|
|
||||||
|
|
||||||
class TestOnlineConfigureFails:
|
class TestOnlineConfigureFails:
|
||||||
|
|||||||
@@ -813,9 +813,6 @@ impl<'a> MimeParser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn do_add_single_part(&mut self, mut part: Part) {
|
fn do_add_single_part(&mut self, mut part: Part) {
|
||||||
// we transfer the encryption-state to each part
|
|
||||||
// because each part lands to each part ? Autocrypt does not define "partially encrypted"
|
|
||||||
// so either the whole message is encrypted properly or nothing
|
|
||||||
if self.encrypted {
|
if self.encrypted {
|
||||||
if self.signatures.len() > 0 {
|
if self.signatures.len() > 0 {
|
||||||
part.param.set_int(Param::GuaranteeE2ee, 1);
|
part.param.set_int(Param::GuaranteeE2ee, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user