def aget_job(self, name): self.load() url = self.rest.job(name) try: data = yield from url.api.python.aget() except aiohttp.errors.HttpProcessingError as e: if 404 == e.code: raise UnknownJob() raise instance = JenkinsJob(data['url'], data['name'], self._instance) instance._data = data payload = yield from url('config.xml').aget() instance._config = payload.data return Job.factory(instance)
def aget_job(self, name): self.load() url = self.rest.job(name) try: data = yield from url.api.python.aget() except aiohttp.errors.HttpProcessingError as e: if 404 == e.code: raise UnknownJob() raise instance = JenkinsJob(data['url'], data['name'], self._instance) instance._data = data payload = yield from url('config.xml').aget() instance._config = payload.data return Job.factory(instance)
def test__add_missing_builds_not_all_loaded(jenkins, monkeypatch): def fake_get_data(cls, url, tree): # pylint: disable=unused-argument return configs.JOB_DATA.copy() monkeypatch.setattr(JenkinsBase, 'get_data', fake_get_data) job = Job('http://halob:8080/job/foo/', 'foo', jenkins) # to test this function we change data to not have one build # and set it to mark that firstBuild was not loaded # in that condition function will call j.get_data # and will use syntetic field 'allBuilds' to # repopulate 'builds' field with all builds mock_data = configs.JOB_DATA.copy() mock_data['firstBuild'] = {'number': 1} del mock_data['builds'][-1] job._data = mock_data assert len(mock_data['builds']) == 2 new_data = job._add_missing_builds(mock_data) assert len(new_data['builds']) == 3
def test__add_missing_builds_not_all_loaded(jenkins, monkeypatch): def fake_get_data(cls, url, tree): # pylint: disable=unused-argument return configs.JOB_DATA.copy() monkeypatch.setattr(JenkinsBase, 'get_data', fake_get_data) job = Job('http://halob:8080/job/foo/', 'foo', jenkins) # to test this function we change data to not have one build # and set it to mark that firstBuild was not loaded # in that condition function will call j.get_data # and will use syntetic field 'allBuilds' to # repopulate 'builds' field with all builds mock_data = configs.JOB_DATA.copy() mock_data['firstBuild'] = {'number': 1} del mock_data['builds'][-1] job._data = mock_data assert len(mock_data['builds']) == 2 new_data = job._add_missing_builds(mock_data) assert len(new_data['builds']) == 3