55
from lp.registry.scripts.teamparticipation import check_teamparticipation
55
from lp.registry.scripts.teamparticipation import (
56
check_teamparticipation,
57
check_teamparticipation_consistency,
56
60
from lp.services.log.logger import BufferLogger
57
61
from lp.testing import (
1145
1148
TeamParticipation (person, team)
1146
1149
VALUES (9997, 9998);
1147
1150
""" % sqlvalues(approved=TeamMembershipStatus.APPROVED))
1149
1151
transaction.commit()
1150
1152
out, err = self._runScript(expected_returncode=1)
1151
1153
self.assertEqual(0, len(out))
1152
1154
self.failUnless(re.search('Circular references found', err))
1156
def test_report_spurious_participants_of_people(self):
1157
"""The script reports spurious participants of people.
1159
Teams can have multiple participants, but only the person should be a
1160
paricipant of him/herself.
1162
# Create two new people and make both participate in the first.
1163
cursor().execute("""
1165
Person (id, name, displayname, creation_rationale)
1166
VALUES (6969, 'bobby', 'Dazzler', 1);
1168
Person (id, name, displayname, creation_rationale)
1169
VALUES (6970, 'nobby', 'Jazzler', 1);
1171
TeamParticipation (person, team)
1172
VALUES (6970, 6969);
1173
""" % sqlvalues(approved=TeamMembershipStatus.APPROVED))
1174
transaction.commit()
1175
logger = BufferLogger()
1176
errors = check_teamparticipation_consistency(logger)
1177
if logger.getLogBuffer() != "":
1178
self.addDetail("log", text_content(logger.getLogBuffer()))
1180
[ConsistencyError("spurious", 6969, [6970])],
1155
1184
class TestCheckTeamParticipationScriptPerformance(TestCaseWithFactory):