def generate_exception(self,space,type_response,e): request = self.fake_request(space,type_response) if space == 'workspace': middleware = WorkspaceExceptionManagerMiddleWare() if space == 'microsites': middleware = MicrositesExceptionManagerMiddleWare() ObjHttpResponse = middleware.process_exception(request,e) self.process_exception(ObjHttpResponse,e,request)
def generate_exception(self, space, type_response, e): request = self.fake_request(space, type_response) if space == 'workspace': middleware = WorkspaceExceptionManagerMiddleWare() if space == 'microsites': middleware = MicrositesExceptionManagerMiddleWare() ObjHttpResponse = middleware.process_exception(request, e) self.process_exception(ObjHttpResponse, e, request)
def process(self, e, space, type_response): request = self.fake_request(space,type_response) if space == 'workspace': middleware = WorkspaceExceptionManagerMiddleWare() if space == 'microsites': middleware = MicrositesExceptionManagerMiddleWare() response = middleware.process_exception(request,e) self.assert_contains(response, unicode(e.title), unicode(e.description), e.status_code)
def process(self, e, space, type_response): request = self.fake_request(space, type_response) if space == 'workspace': middleware = WorkspaceExceptionManagerMiddleWare() if space == 'microsites': middleware = MicrositesExceptionManagerMiddleWare() response = middleware.process_exception(request, e) self.assert_contains(response, unicode(e.title), unicode(e.description), e.status_code)
def handle(self, *args, **options): settings.TEMPLATE_DIRS = list(settings.TEMPLATE_DIRS) settings.TEMPLATE_DIRS.append(os.path.join(settings.PROJECT_PATH, 'workspace', 'templates')) settings.TEMPLATE_DIRS.append(os.path.join(settings.PROJECT_PATH, 'microsites', 'templates')) settings.TEMPLATE_DIRS = tuple(settings.TEMPLATE_DIRS) settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) settings.INSTALLED_APPS.append('microsites') settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) print Colors.HEADER + "\_/ Testing expection \_/" + Colors.END ''' Instance generic Objects for test ''' InstancedForm = DatasetFormFactory(0).create() argument = Object() if options['exception']: self.print_titulo(options['exception']) e = Exception.__new__(eval(options['exception'])) space = 'microsites' type_response = 'text/html' request = self.fake_request(space,type_response) if space == 'workspace': middleware = WorkspaceExceptionManagerMiddleWare() if space == 'microsites': middleware = MicrositesExceptionManagerMiddleWare() ObjHttpResponse = middleware.process_exception(request,e) self.process_exception(ObjHttpResponse,e,request) if options['all']: self.print_titulo("DATALException") e = DATALException() space = 'workspace' type_response = 'text/html' self.generate_exception(space,type_response,e) self.print_titulo("LifeCycleException") space = 'workspace' type_response ='text/html' e = LifeCycleException() self.generate_exception(space,type_response,e) self.print_titulo("ChildNotApprovedException") space = 'workspace' type_response ='text/html' e = ChildNotApprovedException(argument) self.generate_exception(space,type_response,e) self.print_titulo("SaveException") space = 'workspace' type_response = 'text/html' if InstancedForm.is_valid(): print Colors.FAIL + "Valid form, no expection generated." + Colors.END else: e = SaveException(InstancedForm) self.generate_exception(space,type_response,e) self.print_titulo("DatastreamSaveException") space = 'workspace' type_response ='text/html' if InstancedForm.is_valid(): print "Valid form, no expection generated." else: e = DatastreamSaveException(InstancedForm) self.generate_exception(space,type_response,e) self.print_titulo("VisualizationSaveException") space = 'workspace' type_response ='text/html' if InstancedForm.is_valid(): print "Valid form, no expection generated." else: e = VisualizationSaveException(InstancedForm) self.generate_exception(space,type_response,e) self.print_titulo("DatasetNotFoundException") space = 'workspace' type_response ='text/html' e = DatasetNotFoundException() self.generate_exception(space,type_response,e) self.print_titulo("DataStreamNotFoundException") space = 'workspace' type_response ='text/html' e = DataStreamNotFoundException() self.generate_exception(space,type_response,e) self.print_titulo("VisualizationNotFoundException") space = 'workspace' type_response ='text/html' e = VisualizationNotFoundException() self.generate_exception(space,type_response,e) self.print_titulo("VisualizationRequiredException") space = 'workspace' type_response ='text/html' e = VisualizationRequiredException() self.generate_exception(space,type_response,e) self.print_titulo("IllegalStateException") space = 'workspace' type_response ='text/html' e = IllegalStateException() self.generate_exception(space,type_response,e) self.print_titulo("ApplicationException") space = 'workspace' type_response ='text/html' e = ApplicationException() self.generate_exception(space,type_response,e) self.print_titulo("DatastoreNotFoundException") space = 'workspace' type_response ='text/html' e = DatastoreNotFoundException() self.generate_exception(space,type_response,e) self.print_titulo("MailServiceNotFoundException") space = 'workspace' type_response ='text/html' e = MailServiceNotFoundException() self.generate_exception(space,type_response,e) self.print_titulo("SearchIndexNotFoundException") space = 'workspace' type_response ='text/html' e = SearchIndexNotFoundException() self.generate_exception(space,type_response,e) self.print_titulo("S3CreateException") space = 'workspace' type_response ='text/html' e = S3CreateException("Descripcion error class in __init__") self.generate_exception(space,type_response,e) self.print_titulo("S3UpdateException") space = 'workspace' type_response ='text/html' e = S3UpdateException("Descripcion error class in __init__") self.generate_exception(space,type_response,e) self.print_titulo("ParentNotPublishedException") space = 'workspace' type_response ='text/html' e = ParentNotPublishedException("Descripcion error class in __init__") self.generate_exception(space,type_response,e) self.print_titulo("DatastreamParentNotPublishedException") space = 'workspace' type_response ='text/html' request = self.fake_request(space, type_response) e = DatastreamParentNotPublishedException(argument) self.generate_exception(space,type_response,e) self.print_titulo("VisualizationParentNotPublishedException") space = 'workspace' type_response ='text/html' e = VisualizationParentNotPublishedException() self.generate_exception(space,type_response,e) self.print_titulo("ResourceRequiredException") space = 'workspace' type_response ='text/html' e = ResourceRequiredException() self.generate_exception(space,type_response,e) self.print_titulo("AnyResourceRequiredException") space = 'workspace' type_response ='text/html' e = AnyResourceRequiredException() self.generate_exception(space,type_response,e) self.print_titulo("DatasetRequiredException") space = 'workspace' type_response ='text/html' e = DatasetRequiredException() self.generate_exception(space,type_response,e) self.print_titulo("DatastreamRequiredException") space = 'workspace' type_response ='text/html' e = DatastreamRequiredException() self.generate_exception(space,type_response,e) self.print_titulo("AnyDatasetRequiredException") space = 'workspace' type_response ='text/html' e = AnyDatasetRequiredException() self.generate_exception(space,type_response,e) self.print_titulo("AnyDatastreamRequiredException") space = 'workspace' type_response ='text/html' e = AnyDatastreamRequiredException() self.generate_exception(space,type_response,e) self.print_titulo("InsufficientPrivilegesException") space = 'workspace' type_response ='text/html' e = InsufficientPrivilegesException() self.generate_exception(space,type_response,e) self.print_titulo("RequiresReviewException") space = 'workspace' type_response ='text/html' e = RequiresReviewException() self.generate_exception(space,type_response,e) ''' Test microsites exceptions ''' self.print_titulo("VisualizationRevisionDoesNotExist") space = 'microsites' type_response ='text/html' e = VisualizationRevisionDoesNotExist() self.generate_exception(space,type_response,e) self.print_titulo("VisualizationDoesNotExist") space = 'microsites' type_response ='text/html' e = VisualizationDoesNotExist() self.generate_exception(space,type_response,e) self.print_titulo("AccountDoesNotExist") space = 'microsites' type_response ='text/html' e = AccountDoesNotExist() self.generate_exception(space,type_response,e) self.print_titulo("InvalidPage") space = 'microsites' type_response ='text/html' e = InvalidPage() self.generate_exception(space,type_response,e) self.print_titulo("DataStreamDoesNotExist") space = 'microsites' type_response ='text/html' e = DataStreamDoesNotExist() self.generate_exception(space,type_response,e) self.print_titulo("DatasetDoesNotExist") space = 'microsites' type_response ='text/html' e = DatasetDoesNotExist() self.generate_exception(space,type_response,e) self.print_titulo("DatsetError") space = 'microsites' type_response ='text/html' e = DatsetError() self.generate_exception(space,type_response,e) self.print_titulo("NotAccesVisualization") space = 'microsites' type_response ='text/html' e = NotAccesVisualization() self.generate_exception(space,type_response,e) print "\n" print Colors.BLUE + " \~ END TEST \~" + Colors.END
def handle(self, *args, **options): settings.TEMPLATE_DIRS = list(settings.TEMPLATE_DIRS) settings.TEMPLATE_DIRS.append( os.path.join(settings.PROJECT_PATH, 'workspace', 'templates')) settings.TEMPLATE_DIRS.append( os.path.join(settings.PROJECT_PATH, 'microsites', 'templates')) settings.TEMPLATE_DIRS = tuple(settings.TEMPLATE_DIRS) settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) settings.INSTALLED_APPS.append('microsites') settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) print Colors.HEADER + "\_/ Testing expection \_/" + Colors.END ''' Instance generic Objects for test ''' InstancedForm = DatasetFormFactory(0).create() argument = Object() if options['exception']: self.print_titulo(options['exception']) e = Exception.__new__(eval(options['exception'])) space = 'microsites' type_response = 'text/html' request = self.fake_request(space, type_response) if space == 'workspace': middleware = WorkspaceExceptionManagerMiddleWare() if space == 'microsites': middleware = MicrositesExceptionManagerMiddleWare() ObjHttpResponse = middleware.process_exception(request, e) self.process_exception(ObjHttpResponse, e, request) if options['all']: self.print_titulo("DATALException") e = DATALException() space = 'workspace' type_response = 'text/html' self.generate_exception(space, type_response, e) self.print_titulo("LifeCycleException") space = 'workspace' type_response = 'text/html' e = LifeCycleException() self.generate_exception(space, type_response, e) self.print_titulo("ChildNotApprovedException") space = 'workspace' type_response = 'text/html' e = ChildNotApprovedException(argument) self.generate_exception(space, type_response, e) self.print_titulo("SaveException") space = 'workspace' type_response = 'text/html' if InstancedForm.is_valid(): print Colors.FAIL + "Valid form, no expection generated." + Colors.END else: e = SaveException(InstancedForm) self.generate_exception(space, type_response, e) self.print_titulo("DatastreamSaveException") space = 'workspace' type_response = 'text/html' if InstancedForm.is_valid(): print "Valid form, no expection generated." else: e = DatastreamSaveException(InstancedForm) self.generate_exception(space, type_response, e) self.print_titulo("VisualizationSaveException") space = 'workspace' type_response = 'text/html' if InstancedForm.is_valid(): print "Valid form, no expection generated." else: e = VisualizationSaveException(InstancedForm) self.generate_exception(space, type_response, e) self.print_titulo("DatasetNotFoundException") space = 'workspace' type_response = 'text/html' e = DatasetNotFoundException() self.generate_exception(space, type_response, e) self.print_titulo("DataStreamNotFoundException") space = 'workspace' type_response = 'text/html' e = DataStreamNotFoundException() self.generate_exception(space, type_response, e) self.print_titulo("VisualizationNotFoundException") space = 'workspace' type_response = 'text/html' e = VisualizationNotFoundException() self.generate_exception(space, type_response, e) self.print_titulo("VisualizationRequiredException") space = 'workspace' type_response = 'text/html' e = VisualizationRequiredException() self.generate_exception(space, type_response, e) self.print_titulo("IllegalStateException") space = 'workspace' type_response = 'text/html' e = IllegalStateException() self.generate_exception(space, type_response, e) self.print_titulo("ApplicationException") space = 'workspace' type_response = 'text/html' e = ApplicationException() self.generate_exception(space, type_response, e) self.print_titulo("DatastoreNotFoundException") space = 'workspace' type_response = 'text/html' e = DatastoreNotFoundException() self.generate_exception(space, type_response, e) self.print_titulo("MailServiceNotFoundException") space = 'workspace' type_response = 'text/html' e = MailServiceNotFoundException() self.generate_exception(space, type_response, e) self.print_titulo("SearchIndexNotFoundException") space = 'workspace' type_response = 'text/html' e = SearchIndexNotFoundException() self.generate_exception(space, type_response, e) self.print_titulo("S3CreateException") space = 'workspace' type_response = 'text/html' e = S3CreateException("Descripcion error class in __init__") self.generate_exception(space, type_response, e) self.print_titulo("S3UpdateException") space = 'workspace' type_response = 'text/html' e = S3UpdateException("Descripcion error class in __init__") self.generate_exception(space, type_response, e) self.print_titulo("ParentNotPublishedException") space = 'workspace' type_response = 'text/html' e = ParentNotPublishedException( "Descripcion error class in __init__") self.generate_exception(space, type_response, e) self.print_titulo("DatastreamParentNotPublishedException") space = 'workspace' type_response = 'text/html' request = self.fake_request(space, type_response) e = DatastreamParentNotPublishedException(argument) self.generate_exception(space, type_response, e) self.print_titulo("VisualizationParentNotPublishedException") space = 'workspace' type_response = 'text/html' e = VisualizationParentNotPublishedException() self.generate_exception(space, type_response, e) self.print_titulo("ResourceRequiredException") space = 'workspace' type_response = 'text/html' e = ResourceRequiredException() self.generate_exception(space, type_response, e) self.print_titulo("AnyResourceRequiredException") space = 'workspace' type_response = 'text/html' e = AnyResourceRequiredException() self.generate_exception(space, type_response, e) self.print_titulo("DatasetRequiredException") space = 'workspace' type_response = 'text/html' e = DatasetRequiredException() self.generate_exception(space, type_response, e) self.print_titulo("DatastreamRequiredException") space = 'workspace' type_response = 'text/html' e = DatastreamRequiredException() self.generate_exception(space, type_response, e) self.print_titulo("AnyDatasetRequiredException") space = 'workspace' type_response = 'text/html' e = AnyDatasetRequiredException() self.generate_exception(space, type_response, e) self.print_titulo("AnyDatastreamRequiredException") space = 'workspace' type_response = 'text/html' e = AnyDatastreamRequiredException() self.generate_exception(space, type_response, e) self.print_titulo("InsufficientPrivilegesException") space = 'workspace' type_response = 'text/html' e = InsufficientPrivilegesException() self.generate_exception(space, type_response, e) self.print_titulo("RequiresReviewException") space = 'workspace' type_response = 'text/html' e = RequiresReviewException() self.generate_exception(space, type_response, e) ''' Test microsites exceptions ''' self.print_titulo("VisualizationRevisionDoesNotExist") space = 'microsites' type_response = 'text/html' e = VisualizationRevisionDoesNotExist() self.generate_exception(space, type_response, e) self.print_titulo("VisualizationDoesNotExist") space = 'microsites' type_response = 'text/html' e = VisualizationDoesNotExist() self.generate_exception(space, type_response, e) self.print_titulo("AccountDoesNotExist") space = 'microsites' type_response = 'text/html' e = AccountDoesNotExist() self.generate_exception(space, type_response, e) self.print_titulo("InvalidPage") space = 'microsites' type_response = 'text/html' e = InvalidPage() self.generate_exception(space, type_response, e) self.print_titulo("DataStreamDoesNotExist") space = 'microsites' type_response = 'text/html' e = DataStreamDoesNotExist() self.generate_exception(space, type_response, e) self.print_titulo("DatasetDoesNotExist") space = 'microsites' type_response = 'text/html' e = DatasetDoesNotExist() self.generate_exception(space, type_response, e) self.print_titulo("DatsetError") space = 'microsites' type_response = 'text/html' e = DatsetError() self.generate_exception(space, type_response, e) self.print_titulo("NotAccesVisualization") space = 'microsites' type_response = 'text/html' e = NotAccesVisualization() self.generate_exception(space, type_response, e) print "\n" print Colors.BLUE + " \~ END TEST \~" + Colors.END