Here are the examples of the python api mock.call.write taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
5
Example 1
Project: flaky Source File: test_flaky_nose_plugin.py
def _test_flaky_plugin_report(self, expected_stream_value):
self._assert_flaky_plugin_configured()
mock_stream = Mock()
self._mock_stream.getvalue.return_value = expected_stream_value
self._flaky_plugin.report(mock_stream)
self.assertEqual(
mock_stream.mock_calls,
[
mock.call.write('===Flaky Test Report===\n\n'),
mock.call.write(expected_stream_value),
mock.call.write('\n===End Flaky Test Report===\n'),
],
)
3
Example 2
Project: ceres Source File: test_ceres.py
@patch('ceres.CeresSlice.create', new=Mock())
def test_write_within_first_slice_with_gaps(self):
datapoints = [(1200, 0.0), (1320, 2.0)]
with patch('ceres.CeresNode.slices', new=self.ceres_slices):
self.ceres_node.write(datapoints)
# sorted most recent first
calls = [call.write([datapoints[1]]), call.write([datapoints[0]])]
self.ceres_slices[0].assert_has_calls(calls)
3
Example 3
Project: ceres Source File: test_ceres.py
@patch('ceres.CeresSlice.create', new=Mock())
def test_write_within_previous_slice_with_gaps(self):
datapoints = [(720, 0.0), (840, 2.0)]
with patch('ceres.CeresNode.slices', new=self.ceres_slices):
self.ceres_node.write(datapoints)
calls = [call.write([datapoints[1]]), call.write([datapoints[0]])]
self.ceres_slices[1].assert_has_calls(calls)
0
Example 4
Project: DLRN Source File: test_utils.py
def test_noretry(self):
# SUCCESS
commit = db.getLastProcessedCommit(self.session, 'python-pysaml2')
# FAILED
commit2 = db.getLastProcessedCommit(self.session, 'python-alembic')
# SUCCESS, RETRY (should be ignored)
commit3 = \
db.getLastProcessedCommit(self.session, 'python-tripleoclient')
mock_fp = MagicMock()
utils.dumpshas2file(mock_fp, commit, "a", "b", commit.status, 0,
['python-saml2-1.0-1.el7.src.rpm'])
utils.dumpshas2file(mock_fp, commit2, "a", "b", commit2.status, 1,
['python-alembic-1.0-2.el7.src.rpm'])
utils.dumpshas2file(mock_fp, commit3, "a", "b", commit3.status, 2,
['file1-1.2-3.el7.noarch.rpm',
'file2-1.2-3.el7.src.rpm'])
expected = [
call.write(u'python-pysaml2,a,3a9326f251b9a4162eb0dfa9f1c924ef47c'
'2c55a,b,024e24f0cf4366c2290c22f24e42de714d1addd1'
',SUCCESS,0,python-saml2-1.0-1.el7\n'),
call.write(u'python-alembic,a,459549c9ab7fef91b2dc8986bc0643bb2f6'
'ec0c8,b,885e80778edb6cbb8ee4d8909623be8062369a04'
',FAILED,1,python-alembic-1.0-2.el7\n'),
call.write(u'python-tripleoclient,a,1da7b10e55abf8c518e8f61ee7966'
'188f0405f59,b,0b1ce934e5b2e7d45a448f6555d24036f9aeca51'
',SUCCESS,2,file2-1.2-3.el7\n')
]
self.assertEqual(mock_fp.mock_calls, expected)