title: Mock same method with different return value called twice in a function in python
body: <p>I have a method to be tested using pytest. The method is calling same database model twice.</p>
  
  <pre><code> def function:
      ids = database_model.object.filter(user="user1").filter(group="admin").values_list(ids, flat=True).allow_filtering()
      response_list = []
      unquie_ids = list(set(ids))
      for ids in unique_ids:
          response = database_model.object.filter(ids=ids).limit(1)
          for res in response:
              temp_dict = {}
              temp_dict['name'] = res.name
              temp_dict['description'] = res.description
              response_list.append(temp_dict)
     return response_list
  </code></pre>
  
  <p>This works well. I am tring to write unit test case for this.
  As the same database_model requires return value twice. It does not work for me.</p>
  
  <pre><code>  @patch('database_model')
    def test_function(mock_model):
        mock_model.objects.filter.return_value.filter.return_value.values_list.return_value.allow_filtering_return_value = [Mock_id]
        mock_model.objects.filter.limit.return_value = mock_dict
  
        response = function()
  
        assert len(response) &gt; 0
  </code></pre>
  
  <p>mock_id and mock_dict are values created for test case.
  My question is first time i am assigning a return_value to mock_model.objects.filter.return_value.filter.return_value.values_list.return_value.allow_filtering.return_value to [Mock_id] which gets assigned properly. But the next line i am trying to assign a return_value again to the same method. This takes as a magic mock object. So my test case fails because it is getting a empty list. I would like to know how can i assign two different return_values to the same method.</p>