Пример #1
0
    def test_jobs_updated___ReturnsEventFromConstructor(self):

        self.mocks.ReplayAll()

        model = Model(self.jenkins, self.logger, self.event)

        self.assertTrue(self.event is model.jobs_updated_event())
Пример #2
0
    def test_enable_job___Jenkins_returns_true___Dont_log_error(self):

        self.jenkins.enable_job('spam').AndReturn(True)
        self.mocks.ReplayAll()

        model = Model(self.jenkins, self.logger)
        model.enable_job('spam')

        mox.Verify(self.logger)
Пример #3
0
    def test_disable_job___Jenkins_returns_true___Dont_log_error(self):

        self.jenkins.disable_job('baked beans').AndReturn(True)
        self.mocks.ReplayAll()

        model = Model(self.jenkins, self.logger)
        model.disable_job('baked beans')

        mox.Verify(self.logger)
Пример #4
0
    def test_disable_job___Jenkins_returns_false___Log_error(self):

        self.jenkins.disable_job('baked beans').AndReturn(False)
        self.logger.log_error("Failed to disable job 'baked beans', check username and/or password")
        self.mocks.ReplayAll()

        model = Model(self.jenkins, self.logger)
        model.disable_job('baked beans')

        mox.Verify(self.logger)
Пример #5
0
    def test__update_jobs__First_call__Fire_jobs_updated_event_with_no_ignores(self):

        jobOne = Job('job1', JobStatus.OK)
        jobTwo = Job('job2', JobStatus.FAILING)
        self.jenkins.list_jobs().AndReturn([jobOne, jobTwo])
        self.event.fire([JobModel(jobOne, False), JobModel(jobTwo, False)])
        self.mocks.ReplayAll()

        model = Model(self.jenkins, self.logger, self.event)
        model.update_jobs()

        mox.Verify(self.event)
Пример #6
0
    def test_update_jobs___Ignore_job2_before_update___JobModel_ignored_on_event_fired(self):

        jobOne = Job('job1', JobStatus.OK)
        jobTwo = Job('job2', JobStatus.FAILING)
        self.jenkins.list_jobs().AndReturn([jobOne, jobTwo])
        self.event.fire([JobModel(jobOne, False), JobModel(jobTwo, True)])
        self.mocks.ReplayAll()

        model = Model(self.jenkins, self.logger, self.event)
        model.ignore_job('job2')
        model.update_jobs()

        mox.Verify(self.event)
Пример #7
0
    def test_update_jobs___Ignore_job2_then_unignore_before_update___JobModel_not_ignored_on_event_fired(self):

        jobOne = Job('job1', JobStatus.OK)
        jobTwo = Job('job2', JobStatus.FAILING)
        self.jenkins.list_jobs().AndReturn([jobOne, jobTwo])
        self.event.fire([JobModel(jobOne, False), JobModel(jobTwo, False)])
        self.mocks.ReplayAll()

        model = Model(self.jenkins, self.logger, self.event)
        model.ignore_job('job2')
        model.unignore_job('job2')
        model.update_jobs()

        mox.Verify(self.event)
Пример #8
0
    def test_update_jobs___Ignore_job2_after_update___event_fired_with_new_ignore_status(self):

        jobOne = Job('job1', JobStatus.OK)
        jobTwo = Job('job2', JobStatus.FAILING)
        self.jenkins.list_jobs().AndReturn([jobOne, jobTwo])
        self.jenkins.list_jobs().AndReturn([jobOne, jobTwo])
        self.event.fire([JobModel(jobOne, False), JobModel(jobTwo, False)])
        self.event.fire([JobModel(jobOne, False), JobModel(jobTwo, True)])
        self.mocks.ReplayAll()

        model = Model(self.jenkins, self.logger, self.event)
        model.update_jobs()
        model.ignore_job('job2')

        mox.Verify(self.event)