summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-03-03 14:33:40 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-03-03 14:46:53 +0100
commit8858f431f62c095b6cb2aace46ae560c35c2afea (patch)
tree23c3ab7aa564788345bdae8058ba8ace4544e990
parentf736336501db0065bcc890bbdfcf31c677c40590 (diff)
location: implement the 'accuracy' key
We forgot it for some reason.
-rw-r--r--src/conn-location.c1
-rw-r--r--tests/twisted/test-location.py7
2 files changed, 7 insertions, 1 deletions
diff --git a/src/conn-location.c b/src/conn-location.c
index fbfbd25de..1368bd217 100644
--- a/src/conn-location.c
+++ b/src/conn-location.c
@@ -44,6 +44,7 @@ static const LocationMapping mappings[] = {
{ "text", "text", G_TYPE_STRING },
{ "timestamp", "timestamp", G_TYPE_INT64 },
{ "uri", "uri", G_TYPE_STRING },
+ { "accuracy", "accuracy", G_TYPE_DOUBLE },
/* Not (yet?) part of XEP-0080 */
{ "countrycode", "countrycode", G_TYPE_STRING },
/* language is a special case as it's not mapped on a node but on the
diff --git a/tests/twisted/test-location.py b/tests/twisted/test-location.py
index fceb5bdfa..20d67216e 100644
--- a/tests/twisted/test-location.py
+++ b/tests/twisted/test-location.py
@@ -107,6 +107,7 @@ def test(q, bus, conn, stream):
'language': 'en',
'timestamp': date,
'country': 'Congo',
+ 'accuracy': 1.4,
# Gabble silently ignores unknown keys
'badger': 'mushroom'})
@@ -124,6 +125,8 @@ def test(q, bus, conn, stream):
assertEquals(str(timestamp), date_str)
country = xpath.queryForNodes('/geoloc/country', geoloc)[0]
assertEquals(str(country), 'Congo')
+ lat = xpath.queryForNodes('/geoloc/accuracy', geoloc)[0]
+ assertEquals(float(str(lat)), 1.4)
# Request Bob's location
bob_handle = conn.RequestHandles(1, ['bob@foo.com'])[0]
@@ -148,6 +151,7 @@ def test(q, bus, conn, stream):
geoloc.addElement('lat', content='1.25')
geoloc.addElement('lon', content='5.5')
geoloc.addElement('country', content='Belgium')
+ geoloc.addElement('accuracy', content='2.3')
geoloc.addElement('timestamp', content=date_str)
# invalid element, will be discarded by Gabble
geoloc.addElement('badger', content='mushroom')
@@ -158,11 +162,12 @@ def test(q, bus, conn, stream):
handle, location = update_event.args
assertEquals(handle, bob_handle)
- assertLength(5, location)
+ assertLength(6, location)
assertEquals(location['language'], 'en')
assertEquals(location['lat'], 1.25)
assertEquals(location['lon'], 5.5)
assertEquals(location['country'], 'Belgium')
+ assertEquals(location['accuracy'], 2.3)
assertEquals(location['timestamp'], date)
q.forbid_events([geoloc_iq_set_event])