Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Coverage for timestamp vs non timestamp sorted results

  • Loading branch information...
commit 6455ef812aec187eab0a6ec8a010851ed6fe0f6d 1 parent ba069b6
@dcramer authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 tests/tests.py
View
25 tests/tests.py
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.