Removing calls to mock.assert_called_once_with (#3896)

If a mock's assert_called_once_with method is misspelled (e.g. asert_called_once_with) then the test will appear as passing.  Therefore, this commit removes all instances of assert_called_once_with calls and replaces them with two assertions:

        self.assertEqual(mock.call_count, 1)
        self.assertEqual(mock.call_args, mock.call(call_args))
This commit is contained in:
Rob Capellini authored and Paulus Schoutsen committed 2016-10-16 16:13:27 -07:00
1 parent 10c9132046
commit 4891ca1610
18 files changed
+308 -109

No files matched your search

+8 -3
View File
@@ -94,7 +94,12 @@ class TestSplunk(unittest.TestCase):
payload = {'host': 'http://host:8088/services/collector/event',
'event': body}
self.handler_method(event)
self.mock_post.assert_called_once_with(
payload['host'], data=payload,
headers={'Authorization': 'Splunk secret'})
self.assertEqual(self.mock_post.call_count, 1)
self.assertEqual(
self.mock_post.call_args,
mock.call(
payload['host'], data=payload,
headers={'Authorization': 'Splunk secret'}
)
)
self.mock_post.reset_mock()