title: Unit testing Mock GCS
body: <p>I have a hard time to find a way to make a unit test for the <code>read</code> and <code>write</code> methods present in this class. I am trying to create a mock with the mock patch library in order to avoid calling Google Storage but I have a hard time figure out how to do it.</p>
  <pre><code>from google.cloud import storage
  
  
  class GCSObject(str):
      
  
      def __init__(self, uri=&quot;&quot;):
          self.base, self.bucket, self.path = self.parse_uri(uri)
  
  
      def parse_uri(self, uri):
          uri = uri.lstrip(&quot;gs://&quot;).replace(&quot;//&quot;, &quot;/&quot;).split(&quot;/&quot;, 1)
          if len(uri) &gt; 1:
              return (&quot;gs://&quot;, uri[0], uri[1])
          else:
              return (&quot;gs://&quot;, uri[0], &quot;&quot;)
  
      def read(self) -&gt; bytes:
          storage_client = storage.Client()
          bucket = storage_client.bucket(self.bucket)
          return bucket.blob(self.path).download_as_string()
  
      def write(self, content: bytes):
          storage_client = storage.Client()
          bucket = storage_client.get_bucket(self.bucket)
          blob = bucket.blob(self.path)
          blob.upload_from_string(content)
  </code></pre>
  <p><strong>What I am currently trying to do</strong></p>
  <pre><code>@mock.patch(&quot;packages.pyGCP.pyGCP.gcs.storage.Client&quot;)
  def test_upload(client):
      gcs_path = GCSObject(&quot;fake_path&quot;)
      reader = gcs_path.read()  
      #  confused what I should assert 
  </code></pre>