title: python unit test patch mock method not returning the return values
body: <p>I am trying to write a test case <code>test_is_user_present()</code> which calls another function <code>execute_redshift_sql()</code> from <code>redshift_util.py</code> script </p>
  
  <p>I set the expected return value from the function execute_redshift_sql() to <code>1</code> . But I never get this value returned from result after the function is called ! I also printed some values for debugging purpose</p>
  
  <p>You can take a look at test case below</p>
  
  <pre><code>from mock import patch, Mock, MagicMock
  from cia_admin_operations.redshift_util import  execute_redshift_sql
      @patch('cia_admin_operations.redshift_util.execute_redshift_sql')
      def test_is_user_present(mock_execute_redshift_sql):
          ldap_user = "dummy_user"
          mock_out = Mock()
  
          user_check_sql = "SELECT COUNT(1) FROM pg_user WHERE usename = '{}';".format(ldap_user)
  
          mock_execute_redshift_sql.return_value = 1
          print(mock_execute_redshift_sql())
  
          result = execute_redshift_sql(mock_out, user_check_sql)
          print(result)
          print(result())
  &gt;       assert result() == 1
  E       AssertionError: assert &lt;Mock name='m...749067684720'&gt; == 1
  E         -&lt;Mock name='mock.query().getresult()()' id='139749067684720'&gt;
  E         +1
  
  test/test_cia_admin_operations.py:51: AssertionError
  ----------------------------- Captured stdout call -----------------------------
  1
  &lt;Mock name='mock.query().getresult()' id='139749067684776'&gt;
  &lt;Mock name='mock.query().getresult()()' id='139749067684720'&gt;
  </code></pre>
  
  <p>redshift_util.py</p>
  
  <pre><code>def execute_redshift_sql(connection, sqlQuery):
      """Executes redshift query"""
  
      logger.info("Executing following SQL query :\n %s" % sqlQuery)
  
      try:
          result = connection.query(sqlQuery)
          logger.info("Redshift query is successfully executed.")
      except Exception as e:
          logger.error("Query not executed : %s" % e)
          return None
      # return only if the result has some data
      if result:
          logger.info("Query result :\n %s" % result)
          return result.getresult()
      else:
          return 0
  </code></pre>