src/cm/tests/test_structure.py
changeset 103 61fd17f9ab78
parent 0 40c8f766c9b8
child 278 3d25afbd78ff
equal deleted inserted replaced
78:dda94db1149a 103:61fd17f9ab78
    15         text = Text.objects.all()[0]
    15         text = Text.objects.all()[0]
    16         new_text = text.edit(new_title='my title', 
    16         new_text = text.edit(new_title='my title', 
    17                   new_format='html', 
    17                   new_format='html', 
    18                   new_content=text.get_latest_version().content, 
    18                   new_content=text.get_latest_version().content, 
    19                   keep_comments = True, 
    19                   keep_comments = True, 
       
    20                   cancel_modified_scopes=False,                  
    20                   new_version = True)
    21                   new_version = True)
    21         self.assertEqual(TextVersion.objects.count(), 2)
    22         self.assertEqual(TextVersion.objects.count(), 2)
    22         self.assertEqual(Comment.objects.count(), 16)
    23         self.assertEqual(Comment.objects.count(), 16)
    23         
    24         
    24         # edit with duplication changing content
    25         # edit with duplication changing content
    25         new_text = text.edit(new_title='my title', 
    26         new_text = text.edit(new_title='my title', 
    26                   new_format='html', 
    27                   new_format='html', 
    27                   new_content='simple text <p>simple text</p> <p>simple text</p> ', 
    28                   new_content='simple text <p>simple text</p> <p>simple text</p> ', 
    28                   keep_comments = True, 
    29                   keep_comments = True, 
       
    30                   cancel_modified_scopes=False,                  
    29                   new_version = True)
    31                   new_version = True)
    30         self.assertEqual(TextVersion.objects.count(), 3)
    32         self.assertEqual(TextVersion.objects.count(), 3)
    31         self.assertEqual(Comment.objects.count(), 17) # 22
    33         self.assertEqual(Comment.objects.count(), 17) # 22
    32 
    34 
    33         # edit without duplication, completely changing content
    35         # edit without duplication, completely changing content
    34         new_text = text.edit(new_title='my title', 
    36         new_text = text.edit(new_title='my title', 
    35                   new_format='html', 
    37                   new_format='html', 
    36                   new_content='xxxxxx', 
    38                   new_content='xxxxxx', 
    37                   keep_comments = True, 
    39                   keep_comments = True, 
       
    40                   cancel_modified_scopes=False,                  
    38                   new_version = False)
    41                   new_version = False)
    39         self.assertEqual(TextVersion.objects.count(), 3)
    42         self.assertEqual(TextVersion.objects.count(), 3)
    40         self.assertEqual(Comment.objects.count(), 16) # 21
    43         self.assertEqual(Comment.objects.count(), 16) # 21
    41 
    44 
    42     def test_edit_text2(self):
    45     def test_edit_text2(self):
    45         text = Text.objects.all()[0]
    48         text = Text.objects.all()[0]
    46         new_text = text.edit(new_title='my title', 
    49         new_text = text.edit(new_title='my title', 
    47                   new_format='html', 
    50                   new_format='html', 
    48                   new_content='xxxxxx', 
    51                   new_content='xxxxxx', 
    49                   keep_comments = False, 
    52                   keep_comments = False, 
       
    53                   cancel_modified_scopes=False,                  
    50                   new_version = False)
    54                   new_version = False)
    51         self.assertEqual(TextVersion.objects.count(), 1)
    55         self.assertEqual(TextVersion.objects.count(), 1)
    52         self.assertEqual(Comment.objects.count(), 0)
    56         self.assertEqual(Comment.objects.count(), 0)
    53 
    57 
    54     def test_edit_text3(self):
    58     def test_edit_text3(self):
    57         text = Text.objects.all()[0]
    61         text = Text.objects.all()[0]
    58         new_text = text.edit(new_title='my title', 
    62         new_text = text.edit(new_title='my title', 
    59                   new_format='html', 
    63                   new_format='html', 
    60                   new_content='xxxxxx', 
    64                   new_content='xxxxxx', 
    61                   keep_comments = False, 
    65                   keep_comments = False, 
       
    66                   cancel_modified_scopes=False,                  
    62                   new_version = True)
    67                   new_version = True)
    63         self.assertEqual(TextVersion.objects.count(), 2)
    68         self.assertEqual(TextVersion.objects.count(), 2)
    64         self.assertEqual(Comment.objects.count(), 8)
    69         self.assertEqual(Comment.objects.count(), 8)
    65 
    70