def test_state_checkers(self): build_response = BuildResponse({ 'status': { 'phase': 'Complete' } }) build_response.status = 'complete' assert build_response.is_finished() assert build_response.is_succeeded() assert not build_response.is_failed() assert not build_response.is_cancelled() assert not build_response.is_running() assert not build_response.is_pending() assert not build_response.is_in_progress() build_response.status = 'failed' assert build_response.is_failed() assert build_response.is_finished() assert not build_response.is_succeeded() assert not build_response.is_cancelled() assert not build_response.is_running() assert not build_response.is_pending() assert not build_response.is_in_progress() build_response.status = 'cancelled' assert build_response.is_cancelled() assert build_response.is_failed() assert build_response.is_finished() assert not build_response.is_succeeded() assert not build_response.is_running() assert not build_response.is_pending() assert not build_response.is_in_progress() build_response.status = 'running' assert build_response.is_running() assert build_response.is_in_progress() assert not build_response.is_cancelled() assert not build_response.is_failed() assert not build_response.is_finished() assert not build_response.is_succeeded() assert not build_response.is_pending() build_response.status = 'pending' assert build_response.is_pending() assert build_response.is_in_progress() assert not build_response.is_running() assert not build_response.is_cancelled() assert not build_response.is_failed() assert not build_response.is_finished() assert not build_response.is_succeeded()
def cancel_build(self, build_id): response = self.get_build(build_id) br = BuildResponse(response.json()) br.status = BUILD_CANCELLED_STATE url = self._build_url("builds/%s/" % build_id) return self._put(url, data=json.dumps(br.json), headers={"Content-Type": "application/json"})
def cancel_build(self, build_id, namespace=DEFAULT_NAMESPACE): response = self.get_build(build_id, namespace=namespace) br = BuildResponse(response) br.status = BUILD_CANCELLED_STATE url = self._build_url("namespaces/%s/builds/%s/" % (namespace, build_id)) return self._put(url, data=json.dumps(br.json), headers={"Content-Type": "application/json"})