Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-08-14 00:38:27 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-08-14 00:38:27 (GMT)
commita33f52d09f5eb8c8224507627ed2cd907d8ae4e9 (patch)
tree6815940a6c0708c8f374412f4a6e25245d480d2a
parent74bb68d407b2ea5b0d36d053e5e7d6e24f7bdddb (diff)
Treat sorting properly in DS api
-rw-r--r--sugar_network/local/dbus_datastore.py4
-rwxr-xr-xtests/units/dbus_datastore.py8
2 files changed, 7 insertions, 5 deletions
diff --git a/sugar_network/local/dbus_datastore.py b/sugar_network/local/dbus_datastore.py
index 740cda4..bceb140 100644
--- a/sugar_network/local/dbus_datastore.py
+++ b/sugar_network/local/dbus_datastore.py
@@ -112,8 +112,10 @@ class Datastore(dbus_thread.Service):
query = request.get('query')
order_by = request.get('order_by')
if order_by:
+ order_by = order_by[0]
if order_by[0] in ('+', '-'):
- sign = order_by[0]
+ # Revert sign for Journal
+ sign = '+' if order_by[0] == '-' else '-'
order_by = order_by[1:]
else:
sign = ''
diff --git a/tests/units/dbus_datastore.py b/tests/units/dbus_datastore.py
index 68bb08c..f95059a 100755
--- a/tests/units/dbus_datastore.py
+++ b/tests/units/dbus_datastore.py
@@ -51,7 +51,7 @@ class DbusDatastoreTest(tests.Test):
'activity': '',
'keep': '0',
'mime_type': '',
- 'title': '',
+ 'title': 'Unnamed',
'description': '',
'activity_id': '',
'filesize': '0',
@@ -107,7 +107,7 @@ class DbusDatastoreTest(tests.Test):
'activity': '',
'keep': '0',
'mime_type': '',
- 'title': '',
+ 'title': 'Unnamed',
'description': '',
'activity_id': '',
'filesize': '0',
@@ -253,7 +253,7 @@ class DbusDatastoreTest(tests.Test):
entries, total = self.ds.find({'order_by': '-uid'}, ['uid'], timeout=3)
self.assertEqual(3, total)
self.assertEqual(
- [i for i in reversed(sorted([{'uid': guid_1}, {'uid': guid_2}, {'uid': guid_3}]))],
+ [i for i in sorted([{'uid': guid_1}, {'uid': guid_2}, {'uid': guid_3}])],
entries)
# order by not mapped property
@@ -265,7 +265,7 @@ class DbusDatastoreTest(tests.Test):
entries, total = self.ds.find({'order_by': '-title'}, ['uid'], timeout=3)
self.assertEqual(3, total)
self.assertEqual(
- [{'uid': guid_3}, {'uid': guid_2}, {'uid': guid_1}],
+ [{'uid': guid_1}, {'uid': guid_2}, {'uid': guid_3}],
entries)
def test_get_uniquevaluesfor(self):