def test_set(self, key): x = CouchBackend(app=self.app) x._connection = Mock() x._set_with_state(key, 'value', states.SUCCESS) x._connection.save.assert_called_once_with({'_id': '1f3fab', 'value': 'value'})
def test_set_with_conflict(self, key): x = CouchBackend(app=self.app) x._connection = Mock() x._connection.save.side_effect = (pycouchdb.exceptions.Conflict, None) get = x._connection.get = MagicMock() x._set_with_state(key, 'value', states.SUCCESS) x._connection.get.assert_called_once_with('1f3fab') x._connection.get('1f3fab').__setitem__.assert_called_once_with( 'value', 'value') x._connection.save.assert_called_with(get('1f3fab')) assert x._connection.save.call_count == 2