Skip to content

Commit 8cc2bc4

Browse files
committed
add two additional cases and add tests for all
execption raising cases
1 parent 948fd06 commit 8cc2bc4

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

riak/mapreduce.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ def add_bucket(self, bucket):
8383

8484
def add_key_filters(self, key_filters):
8585
if self._input_mode == 'query':
86-
raise Exception('Key filters are not supported in a query.')
86+
raise ValueError('Key filters are not supported in a query.')
8787

8888
self._key_filters.extend(key_filters)
8989
return self
9090

9191
def add_key_filter(self, *args):
9292
if self._input_mode == 'query':
93-
raise Exception('Key filters are not supported in a query.')
93+
raise ValueError('Key filters are not supported in a query.')
9494

9595
self._key_filters.append(args)
9696
return self

riak/tests/test_mapreduce.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,27 @@ def test_erlang_map_reduce(self):
8383
.run()
8484
self.assertEqual(len(result), 2)
8585

86+
def test_client_exceptional_paths(self):
87+
bucket = self.client.bucket('bucket')
88+
bucket.new("foo", 2).store()
89+
bucket.new("bar", 2).store()
90+
bucket.new("baz", 4).store()
91+
92+
#adding a b-key pair to a bucket input
93+
with self.assertRaises(ValueError):
94+
mr = self.client.add('bucket')
95+
mr.add('bucket', 'bar')
96+
97+
#adding a b-key pair to a query input
98+
with self.assertRaises(ValueError):
99+
mr = self.client.search('bucket', 'fleh')
100+
mr.add('bucket', 'bar')
101+
102+
#adding a key filter to a query input
103+
with self.assertRaises(ValueError):
104+
mr = self.client.search('bucket', 'fleh')
105+
mr.add_key_filter("tokenize", "-", 1)
106+
86107

87108
class JSMapReduceTests(object):
88109
def test_javascript_source_map(self):

0 commit comments

Comments
 (0)