Permalink
Browse files

Make all describe_* DTRS store calls return None

  • Loading branch information...
1 parent 9c1b4eb commit 51b35dc3f404c636bf3fa241831abf9e4471b663 @priteau priteau committed Mar 25, 2013
Showing with 10 additions and 22 deletions.
  1. +4 −7 epu/dtrs/store.py
  2. +6 −15 epu/dtrs/test/test_store.py
View
@@ -71,10 +71,11 @@ def describe_dt(self, caller, dt_name):
@retval DT definition or None if not found
"""
log.debug("describe_dt %s for user %s" % (dt_name, caller))
- if caller not in self.users:
- raise NotFoundError('Caller %s has no DT' % caller)
- dts = self.users[caller]["dts"]
+ try:
+ dts = self.users[caller]["dts"]
+ except KeyError:
+ return None
record = dts.get(dt_name)
log.debug("describe_dt %s for user %s dt found %s" % (dt_name, caller, str(record)))
@@ -199,10 +200,6 @@ def describe_credentials(self, caller, site_name):
@param caller caller owning the credentials
@retval Credentials definition or None if not found
"""
- if caller not in self.users:
- raise NotFoundError("Credentials not found for user %s and site %s"
- % (caller, site_name))
-
try:
caller_credentials = self.users[caller]["credentials"]
except KeyError:
@@ -29,13 +29,9 @@ def test_store_dts(self):
dt1_read = self.store.describe_dt('mr_white', dt_id_1)
self.assertEqual(dt1["mappings"], dt1_read["mappings"])
- # Get with a different user should throw an exception
- try:
- self.store.describe_dt('mr_pink', dt_id_1)
- except NotFoundError:
- pass
- else:
- self.fail("expected NotFoundError")
+ # Get with a different user should return None
+ dt1_pink_read = self.store.describe_dt('mr_pink', dt_id_1)
+ self.assertEqual(None, dt1_pink_read)
# now make two changes, one from the original and one from what we read
dt2 = dt1.copy()
@@ -144,14 +140,9 @@ def test_store_credentials(self):
credentials_2_read = self.store.describe_credentials('mr_white', site_id_1)
self.assertEqual("NEW_KEY", credentials_2_read["key_name"])
- # Get with a different user should throw an exception
- try:
- credentials_1_read = self.store.describe_credentials('mr_pink',
- site_id_1)
- except NotFoundError:
- pass
- else:
- self.fail("expected NotFoundError")
+ # Get with a different user should return None
+ credentials_1_read = self.store.describe_credentials('mr_pink', site_id_1)
+ self.assertEqual(None, credentials_1_read)
# Listing credentials should return both
credentials = self.store.list_credentials('mr_white')

0 comments on commit 51b35dc

Please sign in to comment.