Added a denormalizeAccount
Updated the existing testcases to make sure it works.
Patch by: Sverre Rabbelier
--- a/app/soc/logic/accounts.py Fri Feb 27 23:33:20 2009 +0000
+++ b/app/soc/logic/accounts.py Sat Feb 28 00:09:34 2009 +0000
@@ -38,6 +38,19 @@
return users.User(email=normalized)
+def denormalizeAccount(account):
+ """Returns a denormalized version of the specified account.
+ """
+
+ if account.email().find('@') != -1:
+ return account
+
+ normalized = normalizeAccount(account)
+ domain = account.auth_domain()
+ denormalized = ''.join([account.email(), '@', domain])
+
+ return users.User(email=denormalized)
+
def isDeveloper(account=None):
"""Returns True if a Google Account is a Developer with special privileges.
--- a/tests/app/soc/logic/models/test_user.py Fri Feb 27 23:33:20 2009 +0000
+++ b/tests/app/soc/logic/models/test_user.py Sat Feb 28 00:09:34 2009 +0000
@@ -25,6 +25,7 @@
from google.appengine.api import users
from soc.models import user
+from soc.logic import accounts
from soc.logic.models.user import logic as user_logic
@@ -69,6 +70,9 @@
self.failUnlessEqual(link_id, entity.link_id)
self.failUnlessEqual(name, entity.name)
+ denormalized = accounts.denormalizeAccount(entity.account)
+ self.failUnlessEqual(account.email().lower(), denormalized.email())
+
def testAuthEntity(self):
"""
"""
@@ -93,6 +97,9 @@
self.failUnlessEqual(link_id, entity.link_id)
self.failUnlessEqual(name, entity.name)
+ denormalized = accounts.denormalizeAccount(entity.account)
+ self.failUnlessEqual(account.email().lower(), denormalized.email())
+
def testCapsAuthEntity(self):
"""
"""
@@ -116,3 +123,6 @@
self.failUnlessEqual('caps@example.com', entity.account.email())
self.failUnlessEqual(link_id, entity.link_id)
self.failUnlessEqual(name, entity.name)
+
+ denormalized = accounts.denormalizeAccount(entity.account)
+ self.failUnlessEqual(account.email().lower(), denormalized.email())