def _assert_package_status(self, package, required_status): status = self.get_package_info(package)['status'] if status != required_status: if status == PackageDeploymentState.NOTDEPLOYED: raise NotFound(json.dumps({'status': status})) else: raise ConflictingState(json.dumps({'status': status}))
def _assert_application_status(self, application, required_status): app_info = self.get_application_info(application) status = app_info['status'] if (isinstance(required_status, list) and status not in required_status) \ or (not isinstance(required_status, list) and status != required_status): if status == ApplicationState.NOTCREATED: raise NotFound(json.dumps({'status': status})) else: raise ConflictingState(json.dumps({'status': status}))
def make_rest_get_request(self, path, expected_codes=None): if not expected_codes: expected_codes = [200] url = self.api_url + path logging.debug("GET: " + url) response = requests.get(url, timeout=120) logging.debug("response code: " + str(response.status_code)) if (404 not in expected_codes) and (response.status_code == 404): raise NotFound(path) assert response.status_code in expected_codes return response
def _assert_application_status(self, application, required_status): logging.debug("Checking %s is %s", application, json.dumps(required_status)) app_info = self.get_application_info(application) status = app_info['status'] logging.debug("Found %s is %s", application, status) if (isinstance(required_status, list) and status not in required_status) \ or (not isinstance(required_status, list) and status != required_status): if status == ApplicationState.NOTCREATED: raise NotFound(json.dumps({'status': status})) else: raise ConflictingState(json.dumps({'status': status})) logging.debug("Status for %s is OK", application)
def _assert_application_exists(self, application): status = self.get_application_info(application)['status'] if status == ApplicationState.NOTCREATED: raise NotFound(json.dumps({'status': status}))