def test_set_write_concern_as_w_deprecationwarning(self): ("Test that `set_write_concern_as_w()` triggers " "`DeprecationWarning`.") with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') set_write_concern_as_w({'safe': True}, 0) self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) expected = 'safe has been deprecated. Please use w instead.' actual = str(w[-1].message) self.assertEqual(actual, expected)
def test_set_write_concern_as_w_with_safe(self): """Test the `set_write_concern_as_w()` method with `safe`.""" options = {'safe': True} set_write_concern_as_w(options, 0) self.assertEqual(options, {'w': 1}) options = {'safe': 0} set_write_concern_as_w(options, 0) self.assertEqual(options, {'w': 0}) options = {'safe': 0} set_write_concern_as_w(options, 2) self.assertEqual(options, {'w': 2})
def test_set_write_concern_as_w(self): """Test the `set_write_concern_as_w()` method.""" options = {'w': 2} set_write_concern_as_w(options, 0) self.assertEqual(options, {'w': 2}) options = {'w': 0} set_write_concern_as_w(options, 0) self.assertEqual(options, {'w': 0}) options = {'w': 0} set_write_concern_as_w(options, 2) self.assertEqual(options, {'w': 2})