Permalink
Browse files

Coverage for timestamp vs non timestamp sorted results

  • Loading branch information...
1 parent ba069b6 commit 6455ef812aec187eab0a6ec8a010851ed6fe0f6d @dcramer dcramer committed Sep 7, 2011
Showing with 25 additions and 0 deletions.
  1. +25 −0 tests/tests.py
View
@@ -71,3 +71,28 @@ def test_multi_writers(self):
t2.add(self.key, 2, now + timedelta(minutes=1))
self.assertEqual(t1.get(self.key), [2, 1])
+
+ def test_timestamp_scores(self):
+ timeline = Timeline(connection=self.c1, bucket=self.bucket, max_items=3)
+ now = datetime.utcnow()
+
+ timeline.add(self.key, 1, now)
+ timeline.add(self.key, 2, now + timedelta(seconds=1))
+ timeline.add(self.key, 3, now + timedelta(seconds=2))
+ results = timeline.get(self.key)
+ self.assertEqual(len(results), 3)
+ self.assertEquals(results[0], 3)
+ self.assertEquals(results[1], 2)
+ self.assertEquals(results[2], 1)
+
+ def test_non_timestamp_scores(self):
+ timeline = Timeline(connection=self.c1, bucket=self.bucket, max_items=3)
+
+ timeline.add(self.key, 1, 3)
+ timeline.add(self.key, 2, 2)
+ timeline.add(self.key, 3, 1)
+ results = timeline.get(self.key)
+ self.assertEqual(len(results), 3)
+ self.assertEquals(results[0], 1)
+ self.assertEquals(results[1], 2)
+ self.assertEquals(results[2], 3)

0 comments on commit 6455ef8

Please sign in to comment.