Skip to content

Commit dcc1bca

Browse files
committed
Added assertion logging for found group parent loops to is_decendant_of().
- Legacy-Id: 13687
1 parent e87e3eb commit dcc1bca

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

ietf/group/models.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ietf.name.models import GroupStateName, GroupTypeName, DocTagName, GroupMilestoneStateName, RoleName
1515
from ietf.person.models import Email, Person
1616
from ietf.utils.mail import formataddr
17-
from ietf.utils.log import unreachable
17+
from ietf.utils import log
1818

1919

2020
class GroupInfo(models.Model):
@@ -93,13 +93,14 @@ def has_role(self, user, role_names):
9393
return user.is_authenticated and self.role_set.filter(name__in=role_names, person__user=user).exists()
9494

9595
def is_decendant_of(self, sought_parent):
96-
p = self.parent
97-
seen = set()
98-
while ((p != None) and (p != self) and (p not in seen)):
99-
seen.add(p)
100-
if p.acronym == sought_parent:
96+
parent = self.parent
97+
decendants = [ self, ]
98+
while (parent != None) and (parent not in decendants):
99+
decendants = [ parent ] + decendants
100+
if parent.acronym == sought_parent:
101101
return True
102-
p = p.parent
102+
parent = parent.parent
103+
log.assertion('parent not in decendants')
103104
return False
104105

105106
def get_chair(self):
@@ -286,7 +287,7 @@ def name_and_email(self):
286287
Is intended for display use, not in email context.
287288
Use self.formatted_email() for that.
288289
"""
289-
unreachable()
290+
log.unreachable()
290291
if self.person:
291292
return u"%s <%s>" % (self.person.plain_name(), self.email.address)
292293
else:

ietf/group/tests_info.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,8 @@ def timeout_handler(signum, frame):
13191319
signal.alarm(1) # One second
13201320
try:
13211321
test2.is_decendant_of("ietf")
1322+
except AssertionError:
1323+
pass
13221324
except Exception:
13231325
raise
13241326
finally:

0 commit comments

Comments
 (0)