Skip to content

Commit

Permalink
Add better error handling to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aherlihy committed Mar 7, 2016
1 parent a590819 commit bccadf7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mongo_connector/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ def get_config(self):
def _make_post_request(self):
config = _post_request_template.copy()
config.update(self.get_config())
return requests.post(
ret = requests.post(
_mo_url(self._resource), timeout=None, json=config).json()
if type(ret) == list: # Will return a list if an error occurred.
raise RuntimeError("Error sending POST to cluster: %s" % (ret))
return ret

def client(self, **kwargs):
client = pymongo.MongoClient(self.uri, **kwargs)
Expand Down Expand Up @@ -185,8 +188,6 @@ def get_config(self):
def start(self):
# We never need to restart a sharded cluster, only start new ones.
response = self._make_post_request()
if 'shards' not in response:
raise RuntimeError("Error starting cluster: %s" % (response))
for shard in response['shards']:
if shard['id'] == 'demo-set-0':
repl1_id = shard['_id']
Expand Down

0 comments on commit bccadf7

Please sign in to comment.