Esempio n. 1
0
 def test_multiple_notifiers(self):
     p = self.project
     self.assertFalse(p.has_notifier)
     
     # create mail notifier
     mn = MailNotifier(project=p, name="notify by email")
     mn.save()
     self.assertEqual(1, p.notifier_set.count())
     self.assertEqual(unicode(mn), "notify by email")
     self.assertTrue(p.has_notifier)
     
     # create web notifier
     wn = WebNotifier(project=p, name="waterfall page")
     wn.save()
     self.assertEqual(2, p.notifier_set.count())
     self.assertEqual(unicode(wn), "waterfall page")
     
     # check that models can downcast properly
     expect = [_("mail notifier"), _("web notifier")]
     for i,n in enumerate(p.notifier_set.all()):
         # calling method on parent class should raise exception
         self.assertRaises(NotImplementedError, n.get_config_type)
         self.assertRaises(NotImplementedError, n.get_config_class)
         self.assertRaises(NotImplementedError, n.get_config_args)
         # should work with .cast()
         self.assertEqual(expect[i], n.cast().get_config_type())
 def test_simple_creation(self):
     """
     Basic Web Notifier creation
     """
     wn = WebNotifier(project=self.project, name="waterfall")
     wn.save()
     self.assertNotEqual(wn.id, None)
     self.assertEqual(unicode(wn), "waterfall")
     self.assertEqual(wn.cast().get_config_type(), _("web notifier"))
         
     args = wn.cast().get_config_args() 
     self.assertEqual(args.get("http_port", None), settings.DEFAULT_WEBSTATUS_PORT)
     
     # check that the config object can be instantiated
     self.assert_valid_buildbot_config(wn.cast().get_config_class(), args)
     
     # check authentication class
     self.assertEqual(wn.cast().get_auth_class(), None)
     self.assertEqual(wn.cast().get_auth_args(), None)
     
     # Check that the resulting config string is sensible
     self.assert_config_string_executable(wn.cast())
     self.assertEqual(None, wn.cast().get_auth_str())
Esempio n. 3
0
 def test_name_uniqueness(self):
     """
     Ensure that a project cannot have multiple notifiers with the same name
     """
     p = self.project
     n = MailNotifier(project=p, name="notifier1")
     n.save()
     
     n2 = WebNotifier(project=p, name="notifier1")
     self.assertRaises(IntegrityError, n2.save)
     self.assertEqual(n2.id, None)
     
     # the same name can be used in a different project
     p2 = Project(name="another p", owner=self.user)
     p2.save()
     n2.project = p2
     n2.save()
     self.assertNotEqual(n2.id, None)
     
         
     
     
     
    def test_with_auth(self):
        """
        Test Web notifier with admin interface enabled (default options)
        """
        wn = WebNotifier(project=self.project, name="waterfall2",
            port = 8765,
            enable_admin_interface = True,
        )
        wn.save()
        
        # check additional config args
        args = wn.cast().get_config_args()
        self.assertEqual(args.get("http_port", None), 8765)

        # check authentication class
        self.assertNotEqual(wn.cast().get_auth_class(), None)
        self.assertNotEqual(wn.cast().get_auth_args(), None)
        
        args = wn.cast().get_auth_args() # now look at auth module args
        self.assertEqual(args.get("forceBuild", None), True)
        self.assertEqual(args.get("forceAllBuilds", None), True)
        self.assertEqual(args.get("pingBuilder", None), True)
        self.assertEqual(args.get("gracefulShutdown", None), False)
        self.assertEqual(args.get("stopBuild", None), True)
        self.assertEqual(args.get("stopAllBuilds", None), True)
        self.assertEqual(args.get("cancelPendingBuild", None), False)
        self.assertEqual(args.get("cleanShutdown", None), False)

        # Make sure changes to object are reflected in args
        wn.allow_ping_slave = False
        wn.save()
        self.assertEqual(wn.cast().get_auth_args().get("pingBuilder", None), False)
        wn.allow_shutdown_slave = True
        wn.save()
        self.assertEqual(wn.cast().get_auth_args().get("gracefulShutdown", None), True)
        wn.allow_shutdown_master = True
        wn.save()
        self.assertEqual(wn.cast().get_auth_args().get("cleanShutdown", None), True)
        wn.allow_force_build = False
        wn.save()
        self.assertEqual(wn.cast().get_auth_args().get("forceBuild", None), False)
        self.assertEqual(wn.cast().get_auth_args().get("forceAllBuilds", None), False)
        wn.allow_stop_build = False
        wn.save()
        self.assertEqual(wn.cast().get_auth_args().get("stopBuild", None), False)
        self.assertEqual(wn.cast().get_auth_args().get("stopAllBuilds", None), False)
        wn.allow_cancel_pending_build = True
        wn.save()
        self.assertEqual(wn.cast().get_auth_args().get("cancelPendingBuild", None), True)
       
        # check that the auth object can be instantiated
        args = wn.cast().get_auth_args() # now look at auth module args
        self.assert_valid_buildbot_config(wn.cast().get_auth_class(), args)

        # Check that the resulting config string is sensible
        self.assert_config_string_executable(wn.cast())