title: mock s3 connection and boto.S3key to check set_content_from_string method
body: <p>I am doing unit test with python mock. I've gone through blogs and python docs related to mocking but confuse about mocking the test case.
  Here is the snippet for which I want to write test case.
  The agenda is to test the method "set_contents_from_string()" using mock.</p>
  
  <pre><code>def write_to_customer_registry(customer):
  
      # establish a connection with S3
      conn = _connect_to_s3()
  
      # build customer registry dict and convert it to json
      customer_registry_dict = json.dumps(build_customer_registry_dict(customer))
  
      # attempt to access requested bucket
      bucket = _get_customer_bucket(conn)
  
      s3_key = _get_customer_key(bucket, customer)
      s3_key.set_metadata('Content-Type', 'application/json')
      s3_key.set_contents_from_string(customer_registry_dict)
      return s3_key
  </code></pre>