@@ -303,8 +303,10 @@ def test_create_diff_checkpoint(diff_project):
303303 assert file_diff and os .path .exists (file_diff .abs_path )
304304
305305 basefile , diffs = FileHistory .diffs_chain (file_path_id , 32 )
306+ # count checkpoints since we introduced diffs at v11
307+ checkpoints = Checkpoint .get_checkpoints (11 , 32 )
306308 assert basefile .project_version_name == 9
307- assert len (diffs ) == 3
309+ assert len (diffs ) == len ( checkpoints )
308310 # also a lower diff rank was created
309311 lower_diff = FileDiff .query .filter_by (version = 24 , rank = 1 ).first ()
310312 assert os .path .exists (lower_diff .abs_path )
@@ -320,9 +322,12 @@ def test_create_diff_checkpoint(diff_project):
320322
321323 basefile , diffs = FileHistory .diffs_chain (file_path_id , 20 )
322324 assert basefile .project_version_name == 9
323- # individual diff v12 + (v13-v16) + (v17-v20) as the last one
324- assert len (diffs ) == 3
325- assert diffs [- 1 ] == diff
325+ # individual diffs v11, v12 + (v13-v16) + (v17-v20) as the last one
326+ assert len (diffs ) == 4
327+ assert diffs [0 ].version == 11 and diffs [0 ].rank == 0
328+ assert diffs [1 ].version == 12 and diffs [1 ].rank == 0
329+ assert diffs [2 ].version == 16 and diffs [2 ].rank == 1
330+ assert diffs [3 ].version == 20 and diffs [3 ].rank == 1
326331
327332 # repeat - nothing to do
328333 mtime = os .path .getmtime (diff .abs_path )
@@ -397,9 +402,9 @@ def test_can_create_checkpoint(diff_project):
397402 # for zero rank diffs we can always create a checkpoint (but that should already exist)
398403 assert FileDiff .can_create_checkpoint (file_path_id , Checkpoint (0 , 4 )) is True
399404
400- # there are diffs in both ranges, v1-v4 and v5-v8
401- assert FileDiff .can_create_checkpoint (file_path_id , Checkpoint (1 , 1 )) is True
402- assert FileDiff .can_create_checkpoint (file_path_id , Checkpoint (1 , 2 )) is True
405+ # there are diffs in both ranges, v1-v4 and v5-v8 but both contain basefile
406+ assert FileDiff .can_create_checkpoint (file_path_id , Checkpoint (1 , 1 )) is False
407+ assert FileDiff .can_create_checkpoint (file_path_id , Checkpoint (1 , 2 )) is False
403408
404409 # higher ranks cannot be created as file was removed at v9
405410 assert FileDiff .can_create_checkpoint (file_path_id , Checkpoint (2 , 1 )) is False
0 commit comments