Skip to content

Commit 265355e

Browse files
committed
Replace deprecated mongodb methods
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 7b13859 commit 265355e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/pyop/storage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __setitem__(self, key, value):
1919
'data': value,
2020
'modified_ts': time()
2121
}
22-
self._coll.update({'lookup_key': key}, doc, upsert=True)
22+
self._coll.replace_one({'lookup_key': key}, doc, upsert=True)
2323

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

3030
def __delitem__(self, key):
31-
self._coll.remove({'lookup_key': key})
31+
self._coll.delete_one({'lookup_key': key})
3232

3333
def __contains__(self, key):
34-
count = self._coll.count({'lookup_key': key})
34+
count = self._coll.count_documents({'lookup_key': key})
3535
return bool(count)
3636

3737
def items(self):

tests/pyop/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_instance(cls):
2727

2828
def __init__(self):
2929
self._tmpdir = tempfile.mkdtemp()
30-
self._port = random.randint(40000, 50000)
30+
self._port = 27017
3131
self._process = subprocess.Popen(['mongod', '--bind_ip', 'localhost',
3232
'--port', str(self._port),
3333
'--dbpath', self._tmpdir,

0 commit comments

Comments
 (0)