Simplified tests in RolePrincipalsFieldProperty
authorThierry Florac <thierry.florac@onf.fr>
Tue, 25 Jun 2019 15:02:52 +0200
changeset 158 0f9c64c65e5f
parent 157 73dd45088205
child 159 9bff468cbfc3
Simplified tests in RolePrincipalsFieldProperty
src/pyams_security/property.py
--- a/src/pyams_security/property.py	Fri Jan 18 15:39:35 2019 +0100
+++ b/src/pyams_security/property.py	Tue Jun 25 15:02:52 2019 +0200
@@ -29,10 +29,10 @@
     def __init__(self, field, role_id=None, name=None, **args):
         if not IField.providedBy(field):
             raise ValueError("Provided field must implement IField interface")
-        if (role_id is None) and not IRoleField.providedBy(field):
-            raise ValueError("Provided field must implement IRoleField interface "
-                             "or you must provide a role ID")
         if role_id is None:
+            if not IRoleField.providedBy(field):
+                raise ValueError("Provided field must implement IRoleField interface "
+                                 "or you must provide a role ID")
             role_id = field.role_id
         elif IRole.providedBy(role_id):
             role_id = role_id.id