Browse Source

add check revisions length + do commit in copy test

Guénaël Muller 6 years ago
parent
commit
20384a7cb7
1 changed files with 15 additions and 4 deletions
  1. 15 4
      tracim/tracim/tests/library/test_content_api.py

+ 15 - 4
tracim/tracim/tests/library/test_content_api.py View File

419
             new_label='test_file_copy'
419
             new_label='test_file_copy'
420
         )
420
         )
421
 
421
 
422
+        transaction.commit()
422
         text_file_copy = api2.get_one_by_label_and_parent(
423
         text_file_copy = api2.get_one_by_label_and_parent(
423
             'test_file_copy',
424
             'test_file_copy',
424
-            folderb
425
+            folderb,
425
         )
426
         )
427
+
426
         assert text_file != text_file_copy
428
         assert text_file != text_file_copy
427
         assert text_file_copy.content_id != text_file.content_id
429
         assert text_file_copy.content_id != text_file.content_id
428
         assert text_file_copy.workspace_id == workspace2.workspace_id
430
         assert text_file_copy.workspace_id == workspace2.workspace_id
436
         assert text_file_copy.file_extension == text_file.file_extension
438
         assert text_file_copy.file_extension == text_file.file_extension
437
         assert text_file_copy.file_mimetype == text_file.file_mimetype
439
         assert text_file_copy.file_mimetype == text_file.file_mimetype
438
         assert text_file_copy.revision_type == ActionDescription.COPY
440
         assert text_file_copy.revision_type == ActionDescription.COPY
441
+        assert len(text_file_copy.revisions) == len(text_file.revisions) + 1
439
 
442
 
440
     def test_unit_copy_file__same_label_different_parent_ok(self):
443
     def test_unit_copy_file__same_label_different_parent_ok(self):
441
         uapi = UserApi(None)
444
         uapi = UserApi(None)
499
             'folder b',
502
             'folder b',
500
             True
503
             True
501
         )
504
         )
502
-
503
         api2.copy(
505
         api2.copy(
504
             item=text_file,
506
             item=text_file,
505
             new_parent=folderb,
507
             new_parent=folderb,
506
         )
508
         )
507
 
509
 
508
-        text_file_copy = api2.get_one_by_label_and_parent('test_file', folderb)
510
+        transaction.commit()
511
+        text_file_copy = api2.get_one_by_label_and_parent(
512
+            'test_file',
513
+            folderb,
514
+        )
515
+
509
         assert text_file != text_file_copy
516
         assert text_file != text_file_copy
510
         assert text_file_copy.content_id != text_file.content_id
517
         assert text_file_copy.content_id != text_file.content_id
511
         assert text_file_copy.workspace_id == workspace2.workspace_id
518
         assert text_file_copy.workspace_id == workspace2.workspace_id
519
         assert text_file_copy.file_extension == text_file.file_extension
526
         assert text_file_copy.file_extension == text_file.file_extension
520
         assert text_file_copy.file_mimetype == text_file.file_mimetype
527
         assert text_file_copy.file_mimetype == text_file.file_mimetype
521
         assert text_file_copy.revision_type == ActionDescription.COPY
528
         assert text_file_copy.revision_type == ActionDescription.COPY
529
+        assert len(text_file_copy.revisions) == len(text_file.revisions) + 1
522
 
530
 
523
     def test_unit_copy_file_different_label_same_parent_ok(self):
531
     def test_unit_copy_file_different_label_same_parent_ok(self):
524
         uapi = UserApi(None)
532
         uapi = UserApi(None)
581
             new_label='test_file_copy'
589
             new_label='test_file_copy'
582
         )
590
         )
583
 
591
 
592
+        transaction.commit()
584
         text_file_copy = api2.get_one_by_label_and_parent(
593
         text_file_copy = api2.get_one_by_label_and_parent(
585
             'test_file_copy',
594
             'test_file_copy',
586
-            foldera
595
+            foldera,
587
         )
596
         )
597
+
588
         assert text_file != text_file_copy
598
         assert text_file != text_file_copy
589
         assert text_file_copy.content_id != text_file.content_id
599
         assert text_file_copy.content_id != text_file.content_id
590
         assert text_file_copy.workspace_id == workspace.workspace_id
600
         assert text_file_copy.workspace_id == workspace.workspace_id
598
         assert text_file_copy.file_extension == text_file.file_extension
608
         assert text_file_copy.file_extension == text_file.file_extension
599
         assert text_file_copy.file_mimetype == text_file.file_mimetype
609
         assert text_file_copy.file_mimetype == text_file.file_mimetype
600
         assert text_file_copy.revision_type == ActionDescription.COPY
610
         assert text_file_copy.revision_type == ActionDescription.COPY
611
+        assert len(text_file_copy.revisions) == len(text_file.revisions) + 1
601
 
612
 
602
     def test_mark_read__workspace(self):
613
     def test_mark_read__workspace(self):
603
         uapi = UserApi(None)
614
         uapi = UserApi(None)