|
40 | 40 | 2012-11-09 17:06:11.040 | 3.0""")
|
41 | 41 |
|
42 | 42 | symbol = 'TS1'
|
| 43 | +symbol2 = 'TS2' |
| 44 | +symbol3 = 'TS3' |
43 | 45 |
|
44 | 46 |
|
45 | 47 | def test_ArcticTransaction_can_do_first_writes(library):
|
@@ -118,6 +120,46 @@ def test_metadata_changes_writes(library):
|
118 | 120 | assert library.read(symbol, audit_log[0]['new_v']).metadata == {'some': 'data', 'original': 'data'}
|
119 | 121 |
|
120 | 122 |
|
| 123 | + |
| 124 | +def test_audit_read(library): |
| 125 | + with ArcticTransaction(library, symbol3, 'u3', 'foo') as mt: |
| 126 | + mt.write(symbol3, ts1) |
| 127 | + |
| 128 | + with ArcticTransaction(library, symbol, 'u1', 'l1') as mt: |
| 129 | + mt.write(symbol, ts1) |
| 130 | + |
| 131 | + with ArcticTransaction(library, symbol, 'u2', 'l2') as mt: |
| 132 | + mt.write(symbol, ts2) |
| 133 | + |
| 134 | + with ArcticTransaction(library, symbol2, 'u2', 'l2') as mt: |
| 135 | + mt.write(symbol2, ts2) |
| 136 | + |
| 137 | + |
| 138 | + l2_audit_log = library.read_audit_log(message='l2') |
| 139 | + |
| 140 | + assert l2_audit_log == [{u'new_v': 1, u'symbol': u'TS2', u'message': u'l2', u'user': u'u2', u'orig_v': 0}, |
| 141 | + {u'new_v': 2, u'symbol': u'TS1', u'message': u'l2', u'user': u'u2', u'orig_v': 1}, |
| 142 | + ] |
| 143 | + |
| 144 | + symbol_audit_log = library.read_audit_log(symbol=symbol) |
| 145 | + |
| 146 | + assert symbol_audit_log == [{u'new_v': 2, u'symbol': u'TS1', u'message': u'l2', u'user': u'u2', u'orig_v': 1}, |
| 147 | + {u'new_v': 1, u'symbol': u'TS1', u'message': u'l1', u'user': u'u1', u'orig_v': 0}] |
| 148 | + |
| 149 | + |
| 150 | + symbols_audit_log = library.read_audit_log(symbol=[symbol, symbol2]) |
| 151 | + |
| 152 | + assert symbols_audit_log == [{u'new_v': 1, u'symbol': u'TS2', u'message': u'l2', u'user': u'u2', u'orig_v': 0}, |
| 153 | + {u'new_v': 2, u'symbol': u'TS1', u'message': u'l2', u'user': u'u2', u'orig_v': 1}, |
| 154 | + {u'new_v': 1, u'symbol': u'TS1', u'message': u'l1', u'user': u'u1', u'orig_v': 0}] |
| 155 | + |
| 156 | + |
| 157 | + symbol_message_audit_log = library.read_audit_log(symbol=symbol, message='l2') |
| 158 | + |
| 159 | + assert symbol_message_audit_log == [{u'new_v': 2, u'symbol': u'TS1', u'message': u'l2', u'user': u'u2', u'orig_v': 1}, ] |
| 160 | + |
| 161 | + |
| 162 | + |
121 | 163 | def test_cleanup_orphaned_versions_integration(library):
|
122 | 164 | _id = ObjectId.from_datetime(dt(2013, 1, 1))
|
123 | 165 | with patch('bson.ObjectId', return_value=_id):
|
|
0 commit comments