Skip to content

Commit

Permalink
Replace deprecated mongodb methods
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Kanakarakis <[email protected]>
  • Loading branch information
c00kiemon5ter committed Nov 6, 2019
1 parent 7b13859 commit 265355e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/pyop/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __setitem__(self, key, value):
'data': value,
'modified_ts': time()
}
self._coll.update({'lookup_key': key}, doc, upsert=True)
self._coll.replace_one({'lookup_key': key}, doc, upsert=True)

def __getitem__(self, key):
doc = self._coll.find_one({'lookup_key': key})
Expand All @@ -28,10 +28,10 @@ def __getitem__(self, key):
return doc['data']

def __delitem__(self, key):
self._coll.remove({'lookup_key': key})
self._coll.delete_one({'lookup_key': key})

def __contains__(self, key):
count = self._coll.count({'lookup_key': key})
count = self._coll.count_documents({'lookup_key': key})
return bool(count)

def items(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/pyop/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_instance(cls):

def __init__(self):
self._tmpdir = tempfile.mkdtemp()
self._port = random.randint(40000, 50000)
self._port = 27017
self._process = subprocess.Popen(['mongod', '--bind_ip', 'localhost',
'--port', str(self._port),
'--dbpath', self._tmpdir,
Expand Down

0 comments on commit 265355e

Please sign in to comment.