title: Mocking filter parameter of sqlalchemy and pytest patching
body: <p>I want to write a test cases to mock filter() for sqlalchemy .using session here to fire a query on the Object .Session is being created in config file .I am able to mock the session.query(FleetEquipment) but how can i mock the filter parameter as well .</p>
  
  <pre><code>def get_fleet_equipment_from_thirdparty(self, unit_address, thirdparty_company_id):
              result = session.query(FleetEquipment).filter(
                  FleetEquipment.ThirdPartyUnitNumber == unit_address
                  and FleetEquipment.ThirdPartyCompanyID == thirdparty_company_id)[:]
  </code></pre>
  
  <p>way i am mocking the session.query paramater is </p>
  
  <pre><code>@patch("dao.db_config.session.query",fleetEquipmentMock)
  </code></pre>
  
  <p>and this is how i am creating this mock object </p>
  
  <pre><code>fleetEquipment = FleetEquipment(1,123,3,1,1,1)
  fleetEquipmentMock = Mock()
  fleetEquipmentMock.return_value = fleetEquipment
  </code></pre>
  
  <p>how can i achieve the same .</p>
  
  <p>if i try to mock everything together like </p>
  
  <pre><code>@patch("dao.db_config.session.query.filter",fleetEquipmentMock)
  </code></pre>
  
  <p>following exception is observed :</p>
  
  <pre><code>AttributeError: &lt;bound method Session.query of &lt;sqlalchemy.orm.session.Session object at 0x00000239F059E198&gt;&gt; does not have the attribute 'filter'
  </code></pre>