move-coop / parsons

A python library of connectors for the progressive community.
Other
254 stars 125 forks source link

[Bug] Tests and test documention use nonexistent method "MagicMock().called_with()` leading to erroneous test passes #1071

Open austinweisgrau opened 4 weeks ago

austinweisgrau commented 4 weeks ago

called_with is not a real test method on MagicMock, so it returns a MagicMock instance by default, which is truthy and evaluates to true.

Tests using this method assert MagicMock().called_with() are essentially running assert MagicMock() which is the same as assert True. These tests aren't checking for anything and pass no matter what actually happens in the code.

The documentation on how to write tests incorrectly advocates using this syntax:

docs/write_tests.rst
136:    assert self.sf._client.query_all.called_with('FAKESOQL')