Example #1
0
    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 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()
Example #3
0
 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"})
Example #4
0
 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"})
Example #5
0
 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"})