+ def subscribe_in_mailman3(self):
+ # emulate browser to login and subscribe user
+ br = mechanize.Browser()
+ br.open(settings.NEWSLETTER_MAILMAN3_LIST_URL)
+ br.follow_link(url_regex=re.compile('/accounts/login'))
+ br.select_form(action=lambda x: '/login/' in x)
+ br['login'] = settings.NEWSLETTER_MAILMAN3_LOGIN
+ br['password'] = settings.NEWSLETTER_MAILMAN3_PASSWORD
+ response = br.submit()
+ assert br.find_link(url_regex=re.compile('/accounts/logout'))
+ br.open(settings.NEWSLETTER_MAILMAN3_LIST_URL + 'mass_subscribe/')
+ br.select_form(action=lambda x: '/mass_subscribe/' in x)
+ br['emails'] = self.email
+ br['pre_confirmed'] = ['on']
+ br['pre_approved'] = ['on']
+ br['pre_verified'] = ['on']
+ br['send_welcome_message'] = ['False']
+ response = br.submit()
+ self.is_registered = True
+ self.save()
+