~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/mailman/testing/__init__.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-12-14 20:20:18 UTC
  • mfrom: (12060.1.2 testfix-mailman)
  • Revision ID: launchpad@pqm.canonical.com-20101214202018-gkt4ook5q0tfov08
[testfix][rs=sinzui][ui=none] MailmanTestCase always cleans up lists
        and archives that may have been left behind in a failed or
        aborted run.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
        # This utility is based on mailman/tests/TestBase.py.
59
59
        mlist = MailList.MailList()
60
60
        team = lp_mailing_list.team
 
61
        self.cleanMailmanList(None, team.name)
61
62
        owner_email = removeSecurityProxy(team.teamowner).preferredemail.email
62
63
        mlist.Create(team.name, owner_email, 'password')
63
64
        mlist.host_name = 'lists.launchpad.dev'
66
67
        mlist.addNewMember(owner_email)
67
68
        return mlist
68
69
 
69
 
    def cleanMailmanList(self, mlist):
 
70
    def cleanMailmanList(self, mlist, list_name=None):
70
71
        # This utility is based on mailman/tests/TestBase.py.
71
 
        mlist.Unlock()
72
 
        listname = mlist.internal_name()
 
72
        if mlist is not None:
 
73
            mlist.Unlock()
 
74
            list_name = mlist.internal_name()
73
75
        paths = [
74
76
            'lists/%s',
75
77
            'archives/private/%s',
78
80
            'archives/public/%s.mbox',
79
81
            ]
80
82
        for dirtmpl in paths:
81
 
            list_dir = os.path.join(mm_cfg.VAR_PREFIX, dirtmpl % listname)
 
83
            list_dir = os.path.join(mm_cfg.VAR_PREFIX, dirtmpl % list_name)
82
84
            if os.path.islink(list_dir):
83
85
                os.unlink(list_dir)
84
86
            elif os.path.isdir(list_dir):