def test_simple_creation(self): """ Basic Mail Notifier creation """ mn = MailNotifier(project=self.project, name="mail me") mn.save() self.assertNotEqual(mn.id, None) self.assertEqual(unicode(mn), "mail me") self.assertEqual(mn.cast().get_config_type(), _("mail notifier")) self.assertNotEqual(len(mn.cast().get_mode_str()), 0) admin = BuildAdmin( project = self.project, name = "admin", email = "*****@*****.**", receive_build_events = True, ) admin.save() args = mn.cast().get_config_args() # check default arguments self.assertEqual(args.get("fromaddr", None), settings.DEFAULT_MAIL_FROM_ADDR) self.assertEqual(args.get("relayhost", None), settings.DEFAULT_MAIL_SMTP_HOST) self.assertEqual(args.get("smtpPort", None), settings.DEFAULT_MAIL_SMTP_PORT) self.assertEqual(args.get("lookup", None), settings.DEFAULT_MAIL_RCPT_DOMAIN) self.assertEqual(args.get("mode", None), "problem") self.assertEqual(args.get("useTls", None), False) self.assertEqual(args.get("sendToInterestedUsers", None), True) er = args.get("extraRecipients", None) self.assertEqual(type(er), list) self.assertEqual(len(er), 1) self.assertEqual(er[0], "*****@*****.**") # check that the config object can be instantiated self.assert_valid_buildbot_config(mn.cast().get_config_class(), args) # Check that the resulting config string is sensible self.assert_config_string_executable(mn.cast())
def test_with_more_options(self): """ Filling in optional args during object creation """ mn = MailNotifier(project=self.project, name="mail me 2", mode = "all", from_address = "*****@*****.**", rcpt_domain = "svndomain.com", smtp_host = "smtp.mydomain.com", smtp_port = 52, smtp_use_tls = True, smtp_username = "******", smtp_password = "******", ) mn.save() # check additional args args = mn.cast().get_config_args() self.assertEqual(args.get("fromaddr", None), "*****@*****.**") self.assertEqual(args.get("relayhost", None), "smtp.mydomain.com") self.assertEqual(args.get("smtpPort", None), 52) self.assertEqual(args.get("lookup", None), "svndomain.com") self.assertEqual(args.get("mode", None), "all") self.assertEqual(args.get("smtpUser", None), "smtpuser") self.assertEqual(args.get("smtpPassword", None), "sekrit") self.assertEqual(args.get("sendToInterestedUsers", None), True) self.assertEqual(mn.cast().get_mode_str(), unicode(_("(all) build completes, pass or fail."))) # check that the config object can be instantiated self.assert_valid_buildbot_config(mn.cast().get_config_class(), args) # Check that the resulting config string is sensible self.assert_config_string_executable(mn.cast())