Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start of tests.

  • Loading branch information...
commit 4dac68baf6387b02470a325cd88849eb1eef4986 1 parent 7971751
@bretthoerner authored
Showing with 34 additions and 2 deletions.
  1. +34 −2 tests/tests.py
View
36 tests/tests.py
@@ -1,3 +1,4 @@
+from datetime import datetime
import unittest2
import riak
@@ -10,10 +11,41 @@ def setUp(self):
self.c1 = riak.RiakClient()
self.c2 = riak.RiakClient()
+ self.b1 = self.c1.bucket(self.bucket)
+ self.b2 = self.c2.bucket(self.bucket)
+
self.c1.bucket(self.bucket).set_allow_multiples(True)
def tearDown(self):
+ # resolve conflicts / clear data between tests
riak.RiakClient().bucket(self.bucket).get(self.key).delete()
- def test_add1(self):
- pass
+ def test_allow_multiples(self):
+ """
+ Verify that sibling objects are created on a conflict.
+ """
+ o1 = self.b1.get(self.key)
+ o2 = self.b2.get(self.key)
+
+ o1.set_data("object-1")
+ o1.store()
+ o2.set_data("object-2")
+ o2.store()
+
+ conflicted = self.b1.get(self.key)
+ self.assertEqual(conflicted.get_sibling_count(), 2)
+
+ def test_max_items(self):
+ """
+ Verify items > max_items are removed.
+ """
+ timeline = Timeline(connection=self.c1, max_items=3)
+ now = datetime.utcnow()
+
+ timeline.add(self.key, 1, now)
+ timeline.add(self.key, 2, now)
+ timeline.add(self.key, 3, now)
+ self.assertEqual(len(timeline.get(self.key)), 3)
+
+ timeline.add(self.key, 4, now)
+ self.assertEqual(len(timeline.get(self.key)), 3)
Please sign in to comment.
Something went wrong with that request. Please try again.