Skip to content

Commit 7e48102

Browse files
author
Richard Bounds
committed
Make read_audit_log work with mongo 2.x
1 parent 1834002 commit 7e48102

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

arctic/store/version_store.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,11 @@ def read_audit_log(self, symbol=None, message=None):
215215
if message is not None:
216216
query['message'] = message
217217

218-
return list(self._audit.find(query, sort=[('_id', -1)],
219-
projection={'_id': False}))
218+
def _pop_id(x):
219+
x.pop('_id')
220+
return x
221+
222+
return [_pop_id(x) for x in self._audit.find(query, sort=[('_id', -1)])]
220223

221224
def list_versions(self, symbol=None, snapshot=None, latest_only=False):
222225
"""

tests/integration/store/test_version_store_audit.py

+7
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,14 @@ def test_audit_read(library):
133133

134134
with ArcticTransaction(library, symbol2, 'u2', 'l2') as mt:
135135
mt.write(symbol2, ts2)
136+
137+
audit_log = library.read_audit_log()
136138

139+
assert audit_log == [{u'new_v': 1, u'symbol': u'TS2', u'message': u'l2', u'user': u'u2', u'orig_v': 0},
140+
{u'new_v': 2, u'symbol': u'TS1', u'message': u'l2', u'user': u'u2', u'orig_v': 1},
141+
{u'new_v': 1, u'symbol': u'TS1', u'message': u'l1', u'user': u'u1', u'orig_v': 0},
142+
{u'new_v': 1, u'symbol': u'TS3', u'message': u'foo', u'user': u'u3', u'orig_v': 0},
143+
]
137144

138145
l2_audit_log = library.read_audit_log(message='l2')
139146

0 commit comments

Comments
 (0)