← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~sinzui/launchpad/remove-automatic-renewal into lp:launchpad

 

Curtis Hovey has proposed merging lp:~sinzui/launchpad/remove-automatic-renewal into lp:launchpad.

Requested reviews:
  William Grant (wgrant)
Related bugs:
  Bug #179853 in Launchpad itself: "Purpose of "Renew their membership automatically" is unclear"
  https://bugs.launchpad.net/launchpad/+bug/179853

For more details, see:
https://code.launchpad.net/~sinzui/launchpad/remove-automatic-renewal/+merge/117486

RULES

    Pre-implementation: no one
    * Remove all the code that is aware of
      TeamMembershipRenewalPolicy.AUTOMATIC
    * Prepare a SQL script that can be run *before* the branch in deployed
      to update the ~130 teams that use AUTOMATIC to clearly state that
      memberships do not expire.


    Extra credit
    * Indent the renewal period field so that it is beneath the ONDEAMND
      TeamMembershipRenewalPolicy item in the form.
    * Revise the text so that it is clear that the field is only needed
      by ONDEMAND.


QA

    http://people.canonical.com/~curtis/self-renewal.png
    shows the text and position changes.

    * Visit https://qastaging.launchpad.net/~launchpad-dev/+edit
    * Verify the two choices for renewal are invite to *apply*, or *Renew*.
    * Verify the renewal period is beneath the Renew radio option.


LINT

    cronscripts/flag-expired-memberships.py
    lib/lp/registry/configure.zcml
    lib/lp/registry/doc/teammembership-email-notification.txt
    lib/lp/registry/doc/teammembership.txt
    lib/lp/registry/interfaces/person.py
    lib/lp/registry/interfaces/teammembership.py
    lib/lp/registry/model/teammembership.py
    lib/lp/registry/tests/test_team.py
    lib/lp/registry/tests/test_teammembership.py

    There is lint in ./lib/lp/registry/interfaces/teammembership.py that I
    can cleanup before I land.


TEST

    ./bin/test -vvc -t doc/teammembership lp.registry.tests
    ./bin/test -vvc lp.registry.tests.test_team
    ./bin/test -vvc lp.registry.tests.test_teammembership


IMPLEMENTATION

SQL that *must* be run just before delopyments
    http://pastebin.ubuntu.com/1121763/

Removed TeamMembershipRenewalPolicy.AUTOMATIC and all code that was aware
of it.
    cronscripts/flag-expired-memberships.py
    lib/lp/registry/configure.zcml
    lib/lp/registry/doc/teammembership-email-notification.txt
    lib/lp/registry/doc/teammembership.txt
    lib/lp/registry/interfaces/person.py
    lib/lp/registry/interfaces/teammembership.py
    lib/lp/registry/model/teammembership.py
    lib/lp/registry/tests/test_team.py
    lib/lp/registry/tests/test_teammembership.py

Revised the field descriptions and indented the renewal period field.
    lib/lp/registry/browser/team.py
    lib/lp/registry/interfaces/person.py
-- 
https://code.launchpad.net/~sinzui/launchpad/remove-automatic-renewal/+merge/117486
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'cronscripts/flag-expired-memberships.py'
--- cronscripts/flag-expired-memberships.py	2012-01-01 03:14:54 +0000
+++ cronscripts/flag-expired-memberships.py	2012-07-31 16:46:22 +0000
@@ -48,7 +48,7 @@
             days=DAYS_BEFORE_EXPIRATION_WARNING_IS_SENT)
         self.txn.begin()
         for membership in membershipset.getMembershipsToExpire(
-            min_date_for_warning, exclude_autorenewals=True):
+            min_date_for_warning):
             membership.sendExpirationWarningEmail()
             self.logger.debug("Sent warning email to %s in %s team."
                           % (membership.person.name, membership.team.name))

=== modified file 'lib/lp/registry/browser/team.py'
--- lib/lp/registry/browser/team.py	2012-07-17 18:59:29 +0000
+++ lib/lp/registry/browser/team.py	2012-07-31 16:46:22 +0000
@@ -90,6 +90,7 @@
     )
 from lp.app.widgets.owner import HiddenUserWidget
 from lp.app.widgets.popup import PersonPickerWidget
+from lp.app.widgets.textwidgets import StrippedTextWidget
 from lp.code.browser.sourcepackagerecipelisting import HasRecipesMenuMixin
 from lp.registry.browser.branding import BrandingChangeView
 from lp.registry.browser.mailinglists import enabled_with_active_mailing_list
@@ -295,6 +296,8 @@
 
     custom_widget(
         'renewal_policy', LaunchpadRadioWidget, orientation='vertical')
+    custom_widget('defaultrenewalperiod', StrippedTextWidget,
+        widget_class='field subordinate')
     custom_widget(
         'subscriptionpolicy', LaunchpadRadioWidgetWithDescription,
         orientation='vertical')
@@ -1000,6 +1003,8 @@
         'subscriptionpolicy', LaunchpadRadioWidgetWithDescription,
         orientation='vertical')
     custom_widget('teamdescription', TextAreaWidget, height=10, width=30)
+    custom_widget('defaultrenewalperiod', StrippedTextWidget,
+        widget_class='field subordinate')
 
     def setUpFields(self):
         """See `LaunchpadViewForm`.

=== modified file 'lib/lp/registry/configure.zcml'
--- lib/lp/registry/configure.zcml	2012-07-13 08:29:56 +0000
+++ lib/lp/registry/configure.zcml	2012-07-31 16:46:22 +0000
@@ -57,8 +57,7 @@
                 sendExpirationWarningEmail
                 canBeRenewedByMember
                 sendSelfRenewalNotification
-                canChangeExpirationDate
-                sendAutoRenewalNotification"/>
+                canChangeExpirationDate"/>
         <require
             permission="launchpad.Edit"
             attributes="

=== modified file 'lib/lp/registry/doc/teammembership-email-notification.txt'
--- lib/lp/registry/doc/teammembership-email-notification.txt	2012-04-10 14:01:17 +0000
+++ lib/lp/registry/doc/teammembership-email-notification.txt	2012-07-31 16:46:22 +0000
@@ -599,96 +599,6 @@
     ----------------------------------------
 
 
-Membership expiration notification
-----------------------------------
-
-For teams with a renewal policy other than AUTOMATIC, if a membership is
-not renewed before its expiration date it'll be flagged as expired and a
-notification is sent to the team admins and to the member whose
-membership expired. If the renewal policy is AUTOMATIC, though, the
-memberships that should expire will retain their status and have their
-dateexpires update. A notification is also sent to the member and to
-team admins when a membership is automatically renewed.
-
-    >>> from zope.security.proxy import removeSecurityProxy
-    >>> utc_now = datetime.now(pytz.timezone('UTC'))
-    >>> lp_admins = personset.getByName('admins')
-    >>> print lp_admins.renewal_policy.title
-    invite them to apply for renewal
-
-    >>> mark_on_admins = membershipset.getByPersonAndTeam(mark, lp_admins)
-
-    # Need to cheat here and set the expiry date manually because the expiry
-    # date given to setExpirationDate() must be in the future.
-
-    >>> removeSecurityProxy(mark_on_admins).dateexpires = utc_now
-
-    >>> ubuntu_team = personset.getByName('ubuntu-team')
-    >>> ubuntu_team.renewal_policy = TeamMembershipRenewalPolicy.AUTOMATIC
-    >>> ubuntu_team.defaultrenewalperiod = 365
-    >>> jdub = personset.getByName('jdub')
-    >>> jdub_on_ubuntu_team = membershipset.getByPersonAndTeam(
-    ...     jdub, ubuntu_team)
-    >>> removeSecurityProxy(jdub_on_ubuntu_team).dateexpires = utc_now
-    >>> flush_database_updates()
-
-    >>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities
-    >>> membershipset.handleMembershipsExpiringToday(
-    ...     reviewer=getUtility(ILaunchpadCelebrities).janitor)
-    >>> flush_database_updates()
-    >>> run_mail_jobs()
-
-    >>> len(stub.test_emails)
-    8
-
-    >>> print_distinct_emails()
-    From: Ubuntu Team <noreply@xxxxxxxxxxxxx>
-    To: colin.watson@xxxxxxxxxxxxxxx, foo.bar@xxxxxxxxxxxxx,
-        limi@xxxxxxxxx, mark@xxxxxxxxxxx
-    Subject: jdub renewed automatically
-    <BLANKLINE>
-    The membership of Jeff Waugh (jdub) in the Ubuntu Team (ubuntu-team)
-    team has been automatically renewed until ...
-    <http://launchpad.dev/~ubuntu-team>
-    <BLANKLINE>
-    Regards,
-    The Launchpad team
-    ----------------------------------------
-    From: Launchpad Administrators <noreply@xxxxxxxxxxxxx>
-    To: foo.bar@xxxxxxxxxxxxx, guilherme.salgado@xxxxxxxxxxxxx
-    Subject: mark expired from team
-    <BLANKLINE>
-    The membership of Mark Shuttleworth (mark) in the Launchpad
-    Administrators (admins) team has expired.
-    <http://launchpad.dev/~admins>
-    <BLANKLINE>
-    Regards,
-    The Launchpad team
-    ----------------------------------------
-    From: Launchpad Administrators <noreply@xxxxxxxxxxxxx>
-    To: mark@xxxxxxxxxxx
-    Subject: mark expired from team
-    <BLANKLINE>
-    Your membership in the Launchpad Administrators (admins) team has
-    expired.
-    <http://launchpad.dev/~admins>
-    <BLANKLINE>
-    Regards,
-    The Launchpad team
-    ----------------------------------------
-    From: Ubuntu Team <noreply@xxxxxxxxxxxxx>
-    To: jeff.waugh@xxxxxxxxxxxxxxx
-    Subject: jdub renewed automatically
-    <BLANKLINE>
-    Your membership in the Ubuntu Team (ubuntu-team) team has been
-    automatically renewed until ...
-    <http://launchpad.dev/~ubuntu-team>
-    <BLANKLINE>
-    Regards,
-    The Launchpad team
-    ----------------------------------------
-
-
 Memberships renewed by the members themselves
 ---------------------------------------------
 

=== modified file 'lib/lp/registry/doc/teammembership.txt'
--- lib/lp/registry/doc/teammembership.txt	2012-06-06 13:44:50 +0000
+++ lib/lp/registry/doc/teammembership.txt	2012-07-31 16:46:22 +0000
@@ -637,96 +637,6 @@
      (u'name12', u'landscape-developers')]
 
 
-The getMembershipsToExpire() method also accepts an optional
-'exclude_autorewals' argument.  When that argument is provided,
-memberships in teams that are configured to renew the membership
-automatically will be excluded. In that case, there is no reason to send
-a warning email several days before the expiration. The user will just
-be notified that the membership has already been automatically renewed
-on the expiration day.
-
-    >>> autorenewal_team = factory.makeTeam(name="autorenewal-team")
-    >>> autorenewal_team.renewal_policy = (
-    ...     TeamMembershipRenewalPolicy.AUTOMATIC)
-    >>> autorenewal_team.defaultrenewalperiod = 73
-    >>> otto = factory.makePerson(name='otto')
-    >>> ignore = autorenewal_team.addMember(otto, salgado)
-    >>> otto_membership = otto.team_memberships[0]
-    >>> otto_membership.setExpirationDate(utc_now, salgado)
-    >>> original_otto_date_expires = otto_membership.dateexpires
-
-    >>> do_not_warn = factory.makePerson(name='do-not-warn')
-    >>> ignore = autorenewal_team.addMember(do_not_warn, salgado)
-    >>> do_not_warn.team_memberships[0].setExpirationDate(
-    ...     tomorrow, salgado)
-
-    # Not excluding teams with automatic renewals.
-    >>> [(membership.person.name, membership.team.name)
-    ...     for membership in membershipset.getMembershipsToExpire()
-    ...     if membership.team.name == 'autorenewal-team']
-    [(u'otto', u'autorenewal-team')]
-
-    # Excluding teams with automatic renewals.
-    >>> [(membership.person.name, membership.team.name)
-    ...     for membership in membershipset.getMembershipsToExpire(
-    ...         exclude_autorenewals=True)
-    ...     if membership.team.name == 'autorenewal-team']
-    []
-
-Now we commit the changes and run the cronscript.
-XXX: flush_database_updates() shouldn't be needed. This seems to be
-Bug 3989 -- StuartBishop 20060713
-
-    >>> flush_database_updates()
-    >>> transaction.commit()
-
-    >>> import subprocess
-    >>> process = subprocess.Popen(
-    ...     'cronscripts/flag-expired-memberships.py -v', shell=True,
-    ...     stdin=subprocess.PIPE, stdout=subprocess.PIPE,
-    ...     stderr=subprocess.PIPE)
-    >>> (out, err) = process.communicate()
-    >>> print out
-
-A warning email should not have been sent to otto because it was renewed
-inside the cronscript, and it should not be sent to do_not_warn, because
-teams with automatic renewal don't need warnings.
-
-    >>> print '\n'.join(
-    ...     line for line in err.split('\n') if 'INFO' not in line)
-    DEBUG   ...
-    DEBUG   Sent warning email to name16 in launchpad-buildd-admins team.
-    DEBUG   Sent warning email to name12 in landscape-developers team.
-    DEBUG   flag-expired-memberships ran in ...s (excl. load & lock)
-    DEBUG   Removing lock file: ...launchpad-flag-expired-memberships.lock
-    >>> process.returncode
-    0
-    >>> transaction.abort()
-
-Here we can see that the membership that was active is now flagged as expired
-while the one that was inactive hasn't changed.
-
-    >>> foobar_on_admins = membershipset.getByPersonAndTeam(
-    ...     personset.getByName('name16'), personset.getByName('admins'))
-    >>> foobar_on_admins.status.title
-    'Expired'
-    >>> foobar_on_admins.last_changed_by.name
-    u'janitor'
-
-    >>> sp_on_ubuntu_translators = membershipset.getByPersonAndTeam(
-    ...     personset.getByName('name12'),
-    ...     personset.getByName('ubuntu-translators'))
-    >>> sp_on_ubuntu_translators.status.title
-    'Deactivated'
-
-    >>> otto_on_autorenewal_team = membershipset.getByPersonAndTeam(
-    ...     otto, autorenewal_team)
-    >>> otto_on_autorenewal_team.status.title
-    'Approved'
-    >>> otto_on_autorenewal_team.dateexpires - original_otto_date_expires
-    datetime.timedelta(73)
-
-
 Renewing team memberships
 -------------------------
 

=== removed file 'lib/lp/registry/emailtemplates/membership-auto-renewed-bulk.txt'
--- lib/lp/registry/emailtemplates/membership-auto-renewed-bulk.txt	2011-03-09 18:18:02 +0000
+++ lib/lp/registry/emailtemplates/membership-auto-renewed-bulk.txt	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-Hello %(recipient_name)s,
-
-The membership of %(member_name)s in the %(team_name)s team has been automatically renewed until %(dateexpires)s.
-<%(team_url)s>
-
-Regards,
-The Launchpad team

=== removed file 'lib/lp/registry/emailtemplates/membership-auto-renewed-personal.txt'
--- lib/lp/registry/emailtemplates/membership-auto-renewed-personal.txt	2011-03-09 18:18:02 +0000
+++ lib/lp/registry/emailtemplates/membership-auto-renewed-personal.txt	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-Hello %(recipient_name)s,
-
-Your membership in the %(team_name)s team has been automatically renewed until %(dateexpires)s.
-<%(team_url)s>
-
-Regards,
-The Launchpad team

=== modified file 'lib/lp/registry/interfaces/person.py'
--- lib/lp/registry/interfaces/person.py	2012-07-26 20:48:38 +0000
+++ lib/lp/registry/interfaces/person.py	2012-07-31 16:46:22 +0000
@@ -423,13 +423,6 @@
         workflow for joining the team.
         """)
 
-    AUTOMATIC = DBItem(30, """
-        renew their membership automatically, also notifying the admins
-
-        Memberships are automatically renewed when they expire and a note is
-        sent to the member and to team admins.
-        """)
-
 
 class TeamSubscriptionPolicy(DBEnumeratedType):
     """Team Subscription Policies
@@ -1918,9 +1911,7 @@
         renewal_period = person.defaultrenewalperiod
         is_required_value_missing = (
             renewal_period is None
-            and renewal_policy in [
-                TeamMembershipRenewalPolicy.AUTOMATIC,
-                TeamMembershipRenewalPolicy.ONDEMAND])
+            and renewal_policy == TeamMembershipRenewalPolicy.ONDEMAND)
         out_of_range = (
             renewal_period is not None
             and (renewal_period <= 0 or renewal_period > 3650))
@@ -1961,13 +1952,10 @@
         exported_as='default_membership_period')
 
     defaultrenewalperiod = exported(
-        Int(title=_('Renewal period'), required=False,
+        Int(title=_('Self renewal period'), required=False,
             description=_(
-                "Number of days a subscription lasts after being renewed. "
-                "The number can be from 1 to 3650 (10 years). "
-                "You can customize the lengths of individual renewals, but "
-                "this is what's used for auto-renewed and user-renewed "
-                "memberships.")),
+                "Number of days members can renew their own membership. "
+                "The number can be from 1 to 3650 (10 years).")),
         exported_as='default_renewal_period')
 
     defaultexpirationdate = Attribute(

=== modified file 'lib/lp/registry/interfaces/teammembership.py'
--- lib/lp/registry/interfaces/teammembership.py	2011-12-24 16:54:44 +0000
+++ lib/lp/registry/interfaces/teammembership.py	2012-07-31 16:46:22 +0000
@@ -223,14 +223,6 @@
         ONDEMAND.
         """
 
-    def sendAutoRenewalNotification():
-        """Send an email to the member and to team admins notifying that this
-        membership has been automatically renewed.
-
-        This method must not be called if the team's renewal policy is not
-        AUTOMATIC.
-        """
-
     def sendExpirationWarningEmail():
         """Send the member an email warning that the membership will expire.
 

=== modified file 'lib/lp/registry/model/teammembership.py'
--- lib/lp/registry/model/teammembership.py	2012-06-29 02:27:31 +0000
+++ lib/lp/registry/model/teammembership.py	2012-07-31 16:46:22 +0000
@@ -157,45 +157,6 @@
                 template % replacements, force_wrap=True)
             simple_sendmail(from_addr, address, subject, msg)
 
-    def sendAutoRenewalNotification(self):
-        """See `ITeamMembership`."""
-        team = self.team
-        member = self.person
-        assert team.renewal_policy == TeamMembershipRenewalPolicy.AUTOMATIC
-
-        from_addr = format_address(
-            team.displayname, config.canonical.noreply_from_address)
-        replacements = {'member_name': member.unique_displayname,
-                        'team_name': team.unique_displayname,
-                        'team_url': canonical_url(team),
-                        'dateexpires': self.dateexpires.strftime('%Y-%m-%d')}
-        subject = '%s renewed automatically' % member.name
-
-        if member.is_team:
-            member_addrs = get_contact_email_addresses(member.teamowner)
-            template_name = 'membership-auto-renewed-bulk.txt'
-        else:
-            template_name = 'membership-auto-renewed-personal.txt'
-            member_addrs = get_contact_email_addresses(member)
-        template = get_email_template(template_name, app='registry')
-        for address in member_addrs:
-            recipient = getUtility(IPersonSet).getByEmail(address)
-            replacements['recipient_name'] = recipient.displayname
-            msg = MailWrapper().format(
-                template % replacements, force_wrap=True)
-            simple_sendmail(from_addr, address, subject, msg)
-
-        template_name = 'membership-auto-renewed-bulk.txt'
-        admins_addrs = self.team.getTeamAdminsEmailAddresses()
-        admins_addrs = set(admins_addrs).difference(member_addrs)
-        template = get_email_template(template_name, app='registry')
-        for address in admins_addrs:
-            recipient = getUtility(IPersonSet).getByEmail(address)
-            replacements['recipient_name'] = recipient.displayname
-            msg = MailWrapper().format(
-                template % replacements, force_wrap=True)
-            simple_sendmail(from_addr, address, subject, msg)
-
     def canChangeStatusSilently(self, user):
         """Ensure that the user is in the Launchpad Administrators group.
 
@@ -232,12 +193,6 @@
             raise AssertionError(
                 '%s in team %s has no membership expiration date.' %
                 (self.person.name, self.team.name))
-        if self.team.renewal_policy == TeamMembershipRenewalPolicy.AUTOMATIC:
-            # An email will be sent later by handleMembershipsExpiringToday()
-            # when the membership is automatically renewed.
-            raise AssertionError(
-                'Team %s with automatic renewals should not send expiration '
-                'warnings.' % self.team.name)
         if self.dateexpires < datetime.now(pytz.timezone('UTC')):
             # The membership has reached expiration. Silently return because
             # there is nothing to do. The member will have received emails
@@ -461,25 +416,13 @@
         """See `ITeamMembershipSet`."""
         memberships = self.getMembershipsToExpire()
         for membership in memberships:
-            team = membership.team
-            if team.renewal_policy == TeamMembershipRenewalPolicy.AUTOMATIC:
-                # Keep the same status, change the expiration date and send a
-                # notification explaining the membership has been renewed.
-                assert (team.defaultrenewalperiod is not None
-                        and team.defaultrenewalperiod > 0), (
-                    'Teams with a renewal policy of AUTOMATIC must specify '
-                    'a default renewal period greater than 0.')
-                membership.dateexpires += timedelta(
-                    days=team.defaultrenewalperiod)
-                membership.sendAutoRenewalNotification()
-            else:
-                membership.setStatus(TeamMembershipStatus.EXPIRED, reviewer)
+            membership.setStatus(TeamMembershipStatus.EXPIRED, reviewer)
 
     def getByPersonAndTeam(self, person, team):
         """See `ITeamMembershipSet`."""
         return TeamMembership.selectOneBy(person=person, team=team)
 
-    def getMembershipsToExpire(self, when=None, exclude_autorenewals=False):
+    def getMembershipsToExpire(self, when=None):
         """See `ITeamMembershipSet`."""
         if when is None:
             when = datetime.now(pytz.timezone('UTC'))
@@ -488,13 +431,6 @@
             TeamMembership.status.is_in(
                 [TeamMembershipStatus.ADMIN, TeamMembershipStatus.APPROVED]),
             ]
-        if exclude_autorenewals:
-            # Avoid circular import.
-            from lp.registry.model.person import Person
-            conditions.append(TeamMembership.team == Person.id)
-            conditions.append(
-                Person.renewal_policy !=
-                    TeamMembershipRenewalPolicy.AUTOMATIC)
         return IStore(TeamMembership).find(TeamMembership, *conditions)
 
     def deactivateActiveMemberships(self, team, comment, reviewer):

=== modified file 'lib/lp/registry/tests/test_team.py'
--- lib/lp/registry/tests/test_team.py	2012-06-10 13:14:04 +0000
+++ lib/lp/registry/tests/test_team.py	2012-07-31 16:46:22 +0000
@@ -225,11 +225,6 @@
         self.team.defaultrenewalperiod = period
         ITeamPublic.validateInvariants(self.team)
 
-    def test_policy_automatic_period_none(self):
-        # Automatic policy cannot have a none day period.
-        self.assertInvalid(
-            TeamMembershipRenewalPolicy.AUTOMATIC, None)
-
     def test_policy_ondemand_period_none(self):
         # Ondemand policy cannot have a none day period.
         self.assertInvalid(
@@ -241,24 +236,24 @@
             TeamMembershipRenewalPolicy.NONE, None)
 
     def test_policy_requres_period_below_minimum(self):
-        # Automatic and ondemand policy cannot have a zero day period.
+        # Ondemand policy cannot have a zero day period.
         self.assertInvalid(
-            TeamMembershipRenewalPolicy.AUTOMATIC, 0)
+            TeamMembershipRenewalPolicy.ONDEMAND, 0)
 
     def test_policy_requres_period_minimum(self):
-        # Automatic and ondemand policy can have a 1 day period.
+        # Ondemand policy can have a 1 day period.
         self.assertValid(
-            TeamMembershipRenewalPolicy.AUTOMATIC, 1)
+            TeamMembershipRenewalPolicy.ONDEMAND, 1)
 
     def test_policy_requres_period_maximum(self):
-        # Automatic and ondemand policy cannot have a 3650 day max value.
+        # Ondemand policy cannot have a 3650 day max value.
         self.assertValid(
-            TeamMembershipRenewalPolicy.AUTOMATIC, 3650)
+            TeamMembershipRenewalPolicy.ONDEMAND, 3650)
 
     def test_policy_requres_period_over_maximum(self):
-        # Automatic and ondemand policy cannot have a 3650 day max value.
+        # Ondemand policy cannot have a 3650 day max value.
         self.assertInvalid(
-            TeamMembershipRenewalPolicy.AUTOMATIC, 3651)
+            TeamMembershipRenewalPolicy.ONDEMAND, 3651)
 
 
 class TestDefaultMembershipPeriod(TestCaseWithFactory):

=== modified file 'lib/lp/registry/tests/test_teammembership.py'
--- lib/lp/registry/tests/test_teammembership.py	2012-07-17 06:34:59 +0000
+++ lib/lp/registry/tests/test_teammembership.py	2012-07-31 16:46:22 +0000
@@ -102,7 +102,7 @@
         adminteam.setContactAddress(None)
         team = self.factory.makeTeam(owner=adminteam)
         with person_logged_in(team.teamowner):
-            team.renewal_policy = TeamMembershipRenewalPolicy.AUTOMATIC
+            team.renewal_policy = TeamMembershipRenewalPolicy.ONDEMAND
             team.defaultrenewalperiod = 10
 
         # Create a person to be in the control team.
@@ -1077,19 +1077,6 @@
         self.assertRaisesWithContent(
             AssertionError, message, self.tm.sendExpirationWarningEmail)
 
-    def test_error_raised_for_team_with_automatic_renewal(self):
-        # An exception is raised if the team's TeamMembershipRenewalPolicy
-        # is AUTOMATIC.
-        self.team.renewal_policy = TeamMembershipRenewalPolicy.AUTOMATIC
-        self.team.defaultrenewalperiod = 365
-        tomorrow = datetime.now(pytz.UTC) + timedelta(days=1)
-        removeSecurityProxy(self.tm).dateexpires = tomorrow
-        message = (
-            'Team red with automatic renewals should not send '
-            'expiration warnings.')
-        self.assertRaisesWithContent(
-            AssertionError, message, self.tm.sendExpirationWarningEmail)
-
     def test_message_sent_for_future_expiration(self):
         # An email is sent to the user whose membership will expire.
         tomorrow = datetime.now(pytz.UTC) + timedelta(days=1)


Follow ups