Skip to content

Commit

Permalink
Merge pull request #118 from basho/gh117-test-siblings
Browse files Browse the repository at this point in the history
Resolve test failures in test_siblings
  • Loading branch information
seancribbs committed Mar 30, 2012
2 parents 479c805 + 0f794c9 commit 920146c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
5 changes: 3 additions & 2 deletions riak/riak_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def get_sibling_count(self):
"""
return len(self._siblings)

def get_sibling(self, i, r=None):
def get_sibling(self, i, r=None, pr=None):
"""
Retrieve a sibling by sibling number.
Expand All @@ -573,11 +573,12 @@ def get_sibling(self, i, r=None):
else:
# Use defaults if not specified.
r = self._bucket.get_r(r)
pr = self._bucket.get_pr(pr)

# Run the request...
vtag = self._siblings[i]
obj = RiakObject(self._client, self._bucket, self._key)
obj.reload(r, vtag)
obj.reload(r=r, pr=pr, vtag=vtag)

# And make sure it knows who it's siblings are
self._siblings[i] = obj
Expand Down
19 changes: 8 additions & 11 deletions riak/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,11 @@ def test_siblings(self):
# Set up the bucket, clear any existing object...
bucket = self.client.bucket('multiBucket')
bucket.set_allow_multiples(True)
obj = bucket.get('foo')
obj.delete()

obj.reload()
self.assertFalse(obj.exists())
self.assertEqual(obj.get_data(), None)
obj = bucket.get_binary('foo')
# Even if it previously existed, let's store a base resolved version
# from which we can diverge by sending a stale vclock.
obj.set_data('start')
obj.store()

# Store the same object five times...
vals = set()
Expand All @@ -281,9 +280,10 @@ def test_siblings(self):
if randval not in vals:
break

other_obj = other_bucket.new('foo', randval)
other_obj = other_bucket.new_binary('foo', str(randval))
other_obj._vclock = obj._vclock
other_obj.store()
vals.add(randval)
vals.add(str(randval))

# Make sure the object has itself plus four siblings...
obj.reload()
Expand All @@ -304,9 +304,6 @@ def test_siblings(self):
self.assertEqual(obj.get_sibling_count(), 0)
self.assertEqual(obj.get_data(), obj3.get_data())

# Clean up for next test...
obj.delete()

def test_javascript_source_map(self):
# Create the object...
bucket = self.client.bucket("bucket")
Expand Down
2 changes: 1 addition & 1 deletion riak/transports/pbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def get(self, robj, r=None, pr=None, vtag=None):
contents.append(self.decode_content(c))
return resp.vclock, contents
else:
return 0
return None

def put(self, robj, w=None, dw=None, pw=None, return_body=True, if_none_match=False):
"""
Expand Down

0 comments on commit 920146c

Please sign in to comment.