Ejemplo n.º 1
0
    def test_build_job_with_build_id(self):
        """
        If we provide a build_id, this should be sent as parameter.
        """
        job = JobFactory.create(server=self.server)
        with mock.patch("jenkins.models.Jenkins", spec=jenkinsapi.jenkins.Jenkins) as mock_jenkins:
            build_job(job.pk, "20140312.1")

        mock_jenkins.assert_called_with(self.server.url, username=u"root", password=u"testing")
        mock_jenkins.return_value.build_job.assert_called_with(job.name, params={"BUILD_ID": "20140312.1"})
Ejemplo n.º 2
0
    def test_build_job_with_params(self):
        """
        If we provide parameters, then they should be passed with the job build
        request.
        """
        job = JobFactory.create(server=self.server)
        with mock.patch("jenkins.models.Jenkins", spec=jenkinsapi.jenkins.Jenkins) as mock_jenkins:
            build_job(job.pk, params={"MYTEST": "500"})

        mock_jenkins.assert_called_with(self.server.url, username=u"root", password=u"testing")
        mock_jenkins.return_value.build_job.assert_called_with(job.name, params={"MYTEST": "500"})
Ejemplo n.º 3
0
    def test_build_job(self):
        """
        The build_job task should find the associated server, and request that
        the job be built.
        """
        job = JobFactory.create(server=self.server)
        with mock.patch("jenkins.models.Jenkins", spec=jenkinsapi.jenkins.Jenkins) as mock_jenkins:
            build_job(job.pk)

        mock_jenkins.assert_called_with(self.server.url, username=u"root", password=u"testing")
        mock_jenkins.return_value.build_job.assert_called_with(job.name, params={})
Ejemplo n.º 4
0
    def test_build_job_with_params_and_build_id(self):
        """
        If we provide parameters and a build_id, we should get both in the
        parameters.
        """
        job = JobFactory.create(server=self.server)
        with mock.patch("jenkins.models.Jenkins", spec=jenkins.Jenkins) as mock_jenkins:
            build_job(job.pk, "20140312.1", params={"MYTEST": "500"})

        mock_jenkins.assert_called_with(
            self.server.url, username=u"root", password=u"testing")
        mock_jenkins.return_value.build_job.assert_called_with(
            job.name, params={"MYTEST": "500", "BUILD_ID": "20140312.1"})
Ejemplo n.º 5
0
    def test_build_job_with_build_id(self):
        """
        If we provide a build_id, this should be sent as parameter.
        """
        job = JobFactory.create(server=self.server)
        with mock.patch("jenkins.models.Jenkins",
                        spec=jenkinsapi.jenkins.Jenkins) as mock_jenkins:
            build_job(job.pk, "20140312.1")

        mock_jenkins.assert_called_with(self.server.url,
                                        username=u"root",
                                        password=u"testing")
        mock_jenkins.return_value.build_job.assert_called_with(
            job.name, params={"BUILD_ID": "20140312.1"})
Ejemplo n.º 6
0
    def test_build_job_with_params(self):
        """
        If we provide parameters, then they should be passed with the job build
        request.
        """
        job = JobFactory.create(server=self.server)
        with mock.patch("jenkins.models.Jenkins",
                        spec=jenkinsapi.jenkins.Jenkins) as mock_jenkins:
            build_job(job.pk, params={"MYTEST": "500"})

        mock_jenkins.assert_called_with(self.server.url,
                                        username=u"root",
                                        password=u"testing")
        mock_jenkins.return_value.build_job.assert_called_with(
            job.name, params={"MYTEST": "500"})
Ejemplo n.º 7
0
    def test_build_job(self):
        """
        The build_job task should find the associated server, and request that
        the job be built.
        """
        job = JobFactory.create(server=self.server)
        with mock.patch("jenkins.models.Jenkins",
                        spec=jenkinsapi.jenkins.Jenkins) as mock_jenkins:
            build_job(job.pk)

        mock_jenkins.assert_called_with(self.server.url,
                                        username=u"root",
                                        password=u"testing")
        mock_jenkins.return_value.build_job.assert_called_with(job.name,
                                                               params={})
Ejemplo n.º 8
0
    def test_build_job_with_params_and_build_id(self):
        """
        If we provide parameters and a build_id, we should get both in the
        parameters.
        """
        job = JobFactory.create(server=self.server)
        with mock.patch("jenkins.models.Jenkins",
                        spec=jenkinsapi.jenkins.Jenkins) as mock_jenkins:
            build_job(job.pk, "20140312.1", params={"MYTEST": "500"})

        mock_jenkins.assert_called_with(self.server.url,
                                        username=u"root",
                                        password=u"testing")
        mock_jenkins.return_value.build_job.assert_called_with(job.name,
                                                               params={
                                                                   "MYTEST":
                                                                   "500",
                                                                   "BUILD_ID":
                                                                   "20140312.1"
                                                               })