예제 #1
0
 def test_limited_find_registerable(self):
     """Test that find_registerable doesn't find anything when limited."""
     import satpy
     from satpy.aux_download import find_registerable_files
     file_registry = {}
     with satpy.config.set(config_path=[self.tmpdir]), \
          mock.patch('satpy.aux_download._FILE_REGISTRY', file_registry):
         found_files = find_registerable_files(
             readers=[], writers=[], composite_sensors=[],
         )
         assert not found_files
예제 #2
0
 def test_retrieve(self):
     """Test retrieving a single file."""
     import satpy
     from satpy.aux_download import find_registerable_files, retrieve
     file_registry = {}
     with satpy.config.set(config_path=[self.tmpdir], data_dir=str(self.tmpdir)), \
          mock.patch('satpy.aux_download._FILE_REGISTRY', file_registry):
         comp_file = 'composites/README.rst'
         found_files = find_registerable_files()
         assert comp_file in found_files
         assert not self.tmpdir.join(comp_file).exists()
         retrieve(comp_file)
         assert self.tmpdir.join(comp_file).exists()
예제 #3
0
    def test_find_registerable(self, readers, writers, comp_sensors):
        """Test that find_registerable finds some things."""
        import satpy
        from satpy.aux_download import find_registerable_files
        with satpy.config.set(config_path=[self.tmpdir]), \
             mock.patch('satpy.aux_download._FILE_REGISTRY', {}):
            found_files = find_registerable_files(
                readers=readers, writers=writers,
                composite_sensors=comp_sensors,
            )

            _assert_reader_files_downloaded(readers, found_files)
            _assert_writer_files_downloaded(writers, found_files)
            _assert_comp_files_downloaded(comp_sensors, found_files)
            _assert_mod_files_downloaded(comp_sensors, found_files)
예제 #4
0
    def test_find_registerable(self, readers, writers, comp_sensors):
        """Test that find_registerable finds some things."""
        import satpy
        from satpy.aux_download import find_registerable_files
        with satpy.config.set(config_path=[self.tmpdir]), \
             mock.patch('satpy.aux_download._FILE_REGISTRY', {}):
            found_files = find_registerable_files(
                readers=readers, writers=writers,
                composite_sensors=comp_sensors,
            )

            r_cond1, r_cond2 = _get_reader_find_conditions(readers, found_files)
            assert r_cond1
            assert r_cond2
            w_cond1, w_cond2 = _get_writer_find_conditions(writers, found_files)
            assert w_cond1
            assert w_cond2
            comp_cond = _get_comp_find_conditions(comp_sensors, found_files)
            assert comp_cond
예제 #5
0
    def test_offline_retrieve(self):
        """Test retrieving a single file when offline."""
        import satpy
        from satpy.aux_download import find_registerable_files, retrieve
        file_registry = {}
        with satpy.config.set(config_path=[self.tmpdir], data_dir=str(self.tmpdir), download_aux=True), \
             mock.patch('satpy.aux_download._FILE_REGISTRY', file_registry):
            comp_file = 'composites/README.rst'
            found_files = find_registerable_files()
            assert comp_file in found_files

            # the file doesn't exist, we can't download it
            assert not self.tmpdir.join(comp_file).exists()
            with satpy.config.set(download_aux=False):
                pytest.raises(RuntimeError, retrieve, comp_file)

            # allow downloading and get it
            retrieve(comp_file)
            assert self.tmpdir.join(comp_file).exists()

            # turn off downloading and make sure we get local file
            with satpy.config.set(download_aux=False):
                local_file = retrieve(comp_file)
                assert local_file