title: python 3: mock a method of the boto3 S3 client
body: <p>I want to unit test some code that calls a method of the <code>boto3</code> <code>s3</code> client. 
  I can't use <code>moto</code> because this particular method (<code>put_bucket_lifecycle_configuration</code>) is not yet implemented in <code>moto</code>. 
  I want to mock the S3 client and assure that this method was called with specific parameters. </p>
  
  <p>The code I want to test looks something like this:</p>
  
  <pre class="lang-python prettyprint-override"><code># sut.py
  import boto3
  
  class S3Bucket(object):
      def __init__(self, name, lifecycle_config):
          self.name = name
          self.lifecycle_config = lifecycle_config
  
      def create(self):
          client = boto3.client("s3") 
          client.create_bucket(Bucket=self.name)
          rules = # some code that computes rules from self.lifecycle_config
          # I want to test that `rules` is correct in the following call:
          client.put_bucket_lifecycle_configuration(Bucket=self.name, \
            LifecycleConfiguration={"Rules": rules})
  
  def create_a_bucket(name):
      lifecycle_policy = # a dict with a bunch of key/value pairs
      bucket = S3Bucket(name, lifecycle_policy)
      bucket.create()
      return bucket
  </code></pre>
  
  <p>In my test, I'd like to call <code>create_a_bucket()</code> (though instantiating an <code>S3Bucket</code> directly is also an option) and make sure that the call to <code>put_bucket_lifecycle_configuration</code> was made with the correct parameters.</p>
  
  <p>I have messed around with <code>unittest.mock</code> and <code>botocore.stub.Stubber</code> but have not managed to crack this. Unless otherwise urged, I am not posting my attempts since they have not been successful so far. </p>
  
  <p>I am open to suggestions on restructuring the code I'm trying to test in order to make it easier to test. </p>