Пример #1
0
class VOSpaceErrorHandlerTest(unittest.TestCase):
    def setUp(self):
        app = Mock(spec=ValidationApplication)
        view = Mock(spec=ApplicationView)
        app.get_view.return_value = view

        self.downloadable_item = Mock(spec=DownloadRequest)

        self.error_handler = DownloadErrorHandler(app)
        self.view = view

    def test_handle_certificate_problem(self):
        message = "Your certificate is expired."
        error = OSError(message)
        error.errno = errno.EACCES

        self.error_handler.handle_error(error, self.downloadable_item)

        self.view.show_certificate_dialog.assert_called_once_with(
            self.error_handler, message)

    def test_handle_connection_timeout(self):
        message = "Connection timed out."
        error = IOError(message)
        error.errno = errno.ECONNREFUSED

        self.error_handler.handle_error(error, self.downloadable_item)

        self.view.show_retry_download_dialog.assert_called_once_with(
            self.error_handler, message)
Пример #2
0
class VOSpaceErrorHandlerTest(unittest.TestCase):
    def setUp(self):
        app = Mock(spec=ValidationApplication)
        view = Mock(spec=ApplicationView)
        app.get_view.return_value = view

        self.downloadable_item = Mock(spec=DownloadRequest)

        self.error_handler = DownloadErrorHandler(app)
        self.view = view

    def test_handle_certificate_problem(self):
        message = "Your certificate is expired."
        error = OSError(message)
        error.errno = errno.EACCES

        self.error_handler.handle_error(error, self.downloadable_item)

        self.view.show_certificate_dialog.assert_called_once_with(
            self.error_handler, message)

    def test_handle_connection_timeout(self):
        message = "Connection timed out."
        error = IOError(message)
        error.errno = errno.ECONNREFUSED

        self.error_handler.handle_error(error, self.downloadable_item)

        self.view.show_retry_download_dialog.assert_called_once_with(
            self.error_handler, message)
Пример #3
0
    def setUp(self):
        app = Mock(spec=ValidationApplication)
        view = Mock(spec=ApplicationView)
        app.get_view.return_value = view

        self.downloadable_item = Mock(spec=DownloadRequest)

        self.error_handler = DownloadErrorHandler(app)
        self.view = view
Пример #4
0
    def __init__(self, taskname, working_directory):
        wx_app = wx.App(False)

        debug_mode = config.read("DEBUG")
        if debug_mode:
            wx.lib.inspection.InspectionTool().Show()

        try:
            factory = self.task_name_mapping[taskname]()
        except KeyError:
            raise ValueError("Unknown task: %s" % taskname)

        parser = AstromParser()
        error_handler = DownloadErrorHandler(self)
        downloader = ImageSliceDownloader()
        download_manager = AsynchronousImageDownloadManager(
            downloader, error_handler)

        directory_context = DirectoryContext(working_directory)
        progress_manager = ProgressManager(directory_context)
        builder = factory.create_workunit_builder(parser, progress_manager)
        workunit_provider = WorkUnitProvider(tasks.get_suffix(taskname),
                                             directory_context,
                                             progress_manager, builder)
        model = UIModel(workunit_provider, progress_manager, download_manager)
        controller = factory.create_controller(model)

        self.model = model
        self.view = controller.get_view()

        wx_app.MainLoop()
Пример #5
0
    def setUp(self):
        app = Mock(spec=ValidationApplication)
        view = Mock(spec=ApplicationView)
        app.get_view.return_value = view

        self.downloadable_item = Mock(spec=DownloadRequest)

        self.error_handler = DownloadErrorHandler(app)
        self.view = view
Пример #6
0
    def _create_image_manager(self):
        error_handler = DownloadErrorHandler(self)

        def read(slice_config):
            return config.read("CUTOUTS.%s" % slice_config)

        singlet_downloader = ImageCutoutDownloader(
            slice_rows=read("SINGLETS.SLICE_ROWS"),
            slice_cols=read("SINGLETS.SLICE_COLS"))

        singlet_download_manager = AsynchronousDownloadManager(
            singlet_downloader, error_handler)

        triplet_downloader = ImageCutoutDownloader(
            slice_rows=read("TRIPLETS.SLICE_ROWS"),
            slice_cols=read("TRIPLETS.SLICE_COLS"))

        triplet_download_manager = AsynchronousDownloadManager(
            triplet_downloader, error_handler)

        return ImageManager(singlet_download_manager, triplet_download_manager)