Beispiel #1
0
    def setUp(self, _poll):
        _poll.return_value = self.DATA

        # def __init__(self, baseurl, labelname, jenkins_obj):

        self.J = mock.MagicMock()  # Jenkins object
        self.n = Label('http://jtest:8080', 'jenkins-slave', self.J)
Beispiel #2
0
 def _get_labels(self, add_host_label=True):
     if self._element_tree is None:
         self.load_config()
     self._labels = []
     le_text = self._element_tree.find("label").text
     if le_text:
         for label_name in self._element_tree.find('label').text.split(' '):
             self._labels.append(Label(label_name, self.jenkins))
     if add_host_label:
         self._labels.append(Label(self.name, self.jenkins))
Beispiel #3
0
    def setUp(self, _poll):
        _poll.return_value = self.DATA

        # def __init__(self, baseurl, labelname, jenkins_obj):

        self.J = mock.MagicMock()  # Jenkins object
        self.n = Label('http://jtest:8080', 'jenkins-slave', self.J)
Beispiel #4
0
def label(monkeypatch, mocker):
    def fake_poll(cls, tree=None):  # pylint: disable=unused-argument
        return DATA

    monkeypatch.setattr(Label, '_poll', fake_poll)
    jenkins = mocker.MagicMock()

    return Label('http://foo:8080', 'jenkins-slave', jenkins)
Beispiel #5
0
 def get_label(self, label_name):
     label_url = '%s/label/%s' % (self.baseurl, label_name)
     return Label(label_url, label_name, jenkins_obj=self)
Beispiel #6
0
class TestLabel(unittest.TestCase):

    DATA = {"actions":[],
             "busyExecutors":0,
             "clouds":[],
             "description":None,
             "idleExecutors":0,
             "loadStatistics":{},
             "name":"jenkins-slave",
             "nodes":[],
             "offline":True,
             "tiedJobs":[
                    {"name":"test_job1",
                    "url":"http://*****:*****@mock.patch.object(Label, '_poll')
    def setUp(self, _poll):
        _poll.return_value = self.DATA

        # def __init__(self, baseurl, labelname, jenkins_obj):

        self.J = mock.MagicMock()  # Jenkins object
        self.n = Label('http://*****:*****@mock.patch.object(Label, '_poll')
    def test_get_tied_job_names(self, _poll):
        _poll.return_value = self.DATA
        return self.assertEquals(self.n.get_tied_job_names(), self.DATA_JOBS)

    @mock.patch.object(Label, '_poll')
    def test_online(self, _poll):
        _poll.return_value = self.DATA
        return self.assertEquals(self.n.is_online(), False)
Beispiel #7
0
class TestLabel(unittest.TestCase):

    DATA = {
        "actions": [],
        "busyExecutors":
        0,
        "clouds": [],
        "description":
        None,
        "idleExecutors":
        0,
        "loadStatistics": {},
        "name":
        "jenkins-slave",
        "nodes": [],
        "offline":
        True,
        "tiedJobs": [{
            "name": "test_job1",
            "url": "http://*****:*****@mock.patch.object(Label, '_poll')
    def setUp(self, _poll):
        _poll.return_value = self.DATA

        # def __init__(self, baseurl, labelname, jenkins_obj):

        self.J = mock.MagicMock()  # Jenkins object
        self.n = Label('http://*****:*****@mock.patch.object(Label, '_poll')
    def test_get_tied_job_names(self, _poll):
        _poll.return_value = self.DATA
        return self.assertEquals(self.n.get_tied_job_names(), self.DATA_JOBS)

    @mock.patch.object(Label, '_poll')
    def test_online(self, _poll):
        _poll.return_value = self.DATA
        return self.assertEquals(self.n.is_online(), False)
Beispiel #8
0
    def setUp(self, _poll):
        _poll.return_value = self.LABEL

        self.J = mock.MagicMock()
        self.J.baseurl = "http://"
        self.l = Label('label_testLabel', self.J)