def test_get_non_existent_key(self): x = CouchBackend(app=self.app) x._connection = Mock() get = x._connection.get = MagicMock() get.side_effect = pycouchdb.exceptions.NotFound assert x.get('1f3fab') is None x._connection.get.assert_called_once_with('1f3fab')
def test_get(self): """test_get CouchBackend.get should return and take two params db conn to couchdb is mocked. """ x = CouchBackend(app=self.app) x._connection = Mock() get = x._connection.get = MagicMock() assert x.get('1f3fab') == get.return_value['value'] x._connection.get.assert_called_once_with('1f3fab')
def test_get(self): """test_get CouchBackend.get should return and take two params db conn to couchdb is mocked. TODO Should test on key not exists """ x = CouchBackend(app=self.app) x._connection = Mock() mocked_get = x._connection.get = Mock() mocked_get.return_value = sentinel.retval # should return None self.assertEqual(x.get('1f3fab'), sentinel.retval) x._connection.get.assert_called_once_with('1f3fab')