class_docstr: Test Google Cloud Platform utilities.
class_docstr_tok: ["Test","Google","Cloud","Platform","utilities","."]
docstr: Test get_bucket_files basic cases.
docstr_tok: ["Test","get_bucket_files","basic","cases","."]
code: def test_get_bucket_files(self, gcsfs_mod):
      """Test get_bucket_files basic cases."""
      from satpy.demo._google_cloud_platform import get_bucket_files
  
      gcsfs_mod.GCSFileSystem = mock.MagicMock()
      gcsfs_inst = mock.MagicMock()
      gcsfs_mod.GCSFileSystem.return_value = gcsfs_inst
      gcsfs_inst.glob.return_value = ["a.nc", "b.nc"]
      filenames = get_bucket_files("*.nc", ".")
      expected = [os.path.join(".", "a.nc"), os.path.join(".", "b.nc")]
      assert expected == filenames
  
      gcsfs_inst.glob.side_effect = _GlobHelper(10)
      filenames = get_bucket_files(
          ["*.nc", "*.txt"], ".", pattern_slice=slice(2, 5)
      )
      assert len(filenames) == 3 * 2
      gcsfs_inst.glob.side_effect = None  # reset mock side effect
  
      gcsfs_inst.glob.return_value = ["a.nc", "b.nc"]
      with pytest.raises(
          OSError, match="Directory does not exist: does_not_exist"
      ):
          get_bucket_files("*.nc", "does_not_exist")
  
      open("a.nc", "w").close()  # touch the file
      gcsfs_inst.get.reset_mock()
      gcsfs_inst.glob.return_value = ["a.nc"]
      filenames = get_bucket_files("*.nc", ".")
      assert [os.path.join(".", "a.nc")] == filenames
      gcsfs_inst.get.assert_not_called()
  
      # force redownload
      gcsfs_inst.get.reset_mock()
      gcsfs_inst.glob.return_value = ["a.nc"]
      filenames = get_bucket_files("*.nc", ".", force=True)
      assert [os.path.join(".", "a.nc")] == filenames
      gcsfs_inst.get.assert_called_once()
  
      # if we don't get any results then we expect an exception
      gcsfs_inst.get.reset_mock()
      gcsfs_inst.glob.return_value = []
      with pytest.raises(
          OSError, match="No files could be found or downloaded."
      ):
          get_bucket_files("*.nc", ".")
  
imports: from __future__ import annotations
  import contextlib
  import io
  import os
  import sys
  import tarfile
  import unittest
  from collections import defaultdict
  from unittest import mock
  import pytest
label_desc: Use image node_id 2 for calling the TestGCPUtils obj's underlying member method code with example usage: obj.test_get_bucket_files(gcsfs_mod) without return types