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 _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)