@@ -251,6 +251,7 @@ def test_update(data_client):
251
251
elasticsearch_repo = Repository .get ('elasticsearch-dsl-py' )
252
252
v = elasticsearch_repo .meta .version
253
253
254
+ old_seq_no = elasticsearch_repo .meta .seq_no
254
255
elasticsearch_repo .update (owner = {'new_name' : 'elastic' }, new_field = 'testing-update' )
255
256
256
257
assert 'elastic' == elasticsearch_repo .owner .new_name
@@ -263,24 +264,26 @@ def test_update(data_client):
263
264
assert 'testing-update' == new_version .new_field
264
265
assert 'elastic' == new_version .owner .new_name
265
266
assert 'elasticsearch' == new_version .owner .name
267
+ assert 'seq_no' in new_version .meta
268
+ assert new_version .meta .seq_no != old_seq_no
269
+ assert 'primary_term' in new_version .meta
266
270
267
271
268
272
def test_save_updates_existing_doc (data_client ):
269
273
elasticsearch_repo = Repository .get ('elasticsearch-dsl-py' )
270
274
271
275
elasticsearch_repo .new_field = 'testing-save'
272
- v = elasticsearch_repo .meta .version
276
+ old_seq_no = elasticsearch_repo .meta .seq_no
273
277
assert 'updated' == elasticsearch_repo .save ()
274
278
275
- # assert version has been updated
276
- assert elasticsearch_repo .meta .version == v + 1
277
-
278
279
new_repo = data_client .get (index = 'git' , id = 'elasticsearch-dsl-py' )
279
280
assert 'testing-save' == new_repo ['_source' ]['new_field' ]
281
+ assert new_repo ['_seq_no' ] != old_seq_no
282
+ assert new_repo ['_seq_no' ] == elasticsearch_repo .meta .seq_no
280
283
281
- def test_save_automatically_uses_versions (data_client ):
284
+ def test_save_automatically_uses_seq_no_and_primary_term (data_client ):
282
285
elasticsearch_repo = Repository .get ('elasticsearch-dsl-py' )
283
- elasticsearch_repo .meta .version += 1
286
+ elasticsearch_repo .meta .seq_no += 1
284
287
285
288
with raises (ConflictError ):
286
289
elasticsearch_repo .save ()
@@ -292,31 +295,25 @@ def assert_doc_equals(expected, actual):
292
295
293
296
def test_can_save_to_different_index (write_client ):
294
297
test_repo = Repository (description = 'testing' , meta = {'id' : 42 })
295
- test_repo .meta .version_type = 'external'
296
- test_repo .meta .version = 3
297
298
assert test_repo .save (index = 'test-document' )
298
299
299
300
assert_doc_equals ({
300
301
'found' : True ,
301
302
'_index' : 'test-document' ,
302
303
'_id' : '42' ,
303
- '_version' : 3 ,
304
304
'_source' : {'description' : 'testing' },
305
305
},
306
306
write_client .get (index = 'test-document' , id = 42 )
307
307
)
308
308
309
309
def test_save_without_skip_empty_will_include_empty_fields (write_client ):
310
310
test_repo = Repository (field_1 = [], field_2 = None , field_3 = {}, meta = {'id' : 42 })
311
- test_repo .meta .version_type = 'external'
312
- test_repo .meta .version = 3
313
311
assert test_repo .save (index = 'test-document' , skip_empty = False )
314
312
315
313
assert_doc_equals ({
316
314
'found' : True ,
317
315
'_index' : 'test-document' ,
318
316
'_id' : '42' ,
319
- '_version' : 3 ,
320
317
'_source' : {
321
318
"field_1" : [],
322
319
"field_2" : None ,
0 commit comments