~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/tests/test_teammembership.py

[rs=buildbot-poller] automatic merge from stable. Revisions: 14249,
        14250, 14251, 14252 included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    TeamMembership,
53
53
    TeamParticipation,
54
54
    )
55
 
from lp.registry.scripts.teamparticipation import check_teamparticipation
 
55
from lp.registry.scripts.teamparticipation import (
 
56
    check_teamparticipation,
 
57
    check_teamparticipation_consistency,
 
58
    ConsistencyError,
 
59
    )
56
60
from lp.services.log.logger import BufferLogger
57
61
from lp.testing import (
58
62
    login,
1105
1109
                        LIMIT 1),
1106
1110
                    %s);
1107
1111
            """ % sqlvalues(TeamMembershipStatus.APPROVED))
1108
 
        import transaction
1109
1112
        transaction.commit()
1110
1113
 
1111
1114
        out, err = self._runScript()
1145
1148
                TeamParticipation (person, team)
1146
1149
                VALUES (9997, 9998);
1147
1150
            """ % sqlvalues(approved=TeamMembershipStatus.APPROVED))
1148
 
        import transaction
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))
1153
1155
 
 
1156
    def test_report_spurious_participants_of_people(self):
 
1157
        """The script reports spurious participants of people.
 
1158
 
 
1159
        Teams can have multiple participants, but only the person should be a
 
1160
        paricipant of him/herself.
 
1161
        """
 
1162
        # Create two new people and make both participate in the first.
 
1163
        cursor().execute("""
 
1164
            INSERT INTO
 
1165
                Person (id, name, displayname, creation_rationale)
 
1166
                VALUES (6969, 'bobby', 'Dazzler', 1);
 
1167
            INSERT INTO
 
1168
                Person (id, name, displayname, creation_rationale)
 
1169
                VALUES (6970, 'nobby', 'Jazzler', 1);
 
1170
            INSERT INTO
 
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()))
 
1179
        self.assertEqual(
 
1180
            [ConsistencyError("spurious", 6969, [6970])],
 
1181
            errors)
 
1182
 
1154
1183
 
1155
1184
class TestCheckTeamParticipationScriptPerformance(TestCaseWithFactory):
1156
1185