|
0
|
1 |
from django.test import TestCase |
|
|
2 |
from django.test.client import Client |
|
|
3 |
from django.core import management |
|
|
4 |
|
|
|
5 |
from cm.models import * |
|
|
6 |
|
|
|
7 |
class StructureTest(TestCase): |
|
|
8 |
fixtures = ['test_comments',] |
|
|
9 |
|
|
|
10 |
def test_edit_text(self): |
|
|
11 |
self.assertEqual(TextVersion.objects.count(), 1) |
|
|
12 |
self.assertEqual(Comment.objects.count(), 8) |
|
|
13 |
|
|
|
14 |
# edit with duplication, without changing content |
|
|
15 |
text = Text.objects.all()[0] |
|
|
16 |
new_text = text.edit(new_title='my title', |
|
|
17 |
new_format='html', |
|
|
18 |
new_content=text.get_latest_version().content, |
|
|
19 |
keep_comments = True, |
|
103
|
20 |
cancel_modified_scopes=False, |
|
0
|
21 |
new_version = True) |
|
|
22 |
self.assertEqual(TextVersion.objects.count(), 2) |
|
|
23 |
self.assertEqual(Comment.objects.count(), 16) |
|
|
24 |
|
|
|
25 |
# edit with duplication changing content |
|
|
26 |
new_text = text.edit(new_title='my title', |
|
|
27 |
new_format='html', |
|
278
|
28 |
new_content=u'simple text <p>simple text</p> <p>simple text</p> ', |
|
0
|
29 |
keep_comments = True, |
|
103
|
30 |
cancel_modified_scopes=False, |
|
0
|
31 |
new_version = True) |
|
|
32 |
self.assertEqual(TextVersion.objects.count(), 3) |
|
|
33 |
self.assertEqual(Comment.objects.count(), 17) # 22 |
|
|
34 |
|
|
|
35 |
# edit without duplication, completely changing content |
|
|
36 |
new_text = text.edit(new_title='my title', |
|
|
37 |
new_format='html', |
|
278
|
38 |
new_content=u'xxxxxx', |
|
0
|
39 |
keep_comments = True, |
|
103
|
40 |
cancel_modified_scopes=False, |
|
0
|
41 |
new_version = False) |
|
|
42 |
self.assertEqual(TextVersion.objects.count(), 3) |
|
|
43 |
self.assertEqual(Comment.objects.count(), 16) # 21 |
|
|
44 |
|
|
|
45 |
def test_edit_text2(self): |
|
|
46 |
self.assertEqual(TextVersion.objects.count(), 1) |
|
|
47 |
self.assertEqual(Comment.objects.count(), 8) |
|
|
48 |
text = Text.objects.all()[0] |
|
|
49 |
new_text = text.edit(new_title='my title', |
|
|
50 |
new_format='html', |
|
278
|
51 |
new_content=u'xxxxxx', |
|
0
|
52 |
keep_comments = False, |
|
103
|
53 |
cancel_modified_scopes=False, |
|
0
|
54 |
new_version = False) |
|
|
55 |
self.assertEqual(TextVersion.objects.count(), 1) |
|
|
56 |
self.assertEqual(Comment.objects.count(), 0) |
|
|
57 |
|
|
|
58 |
def test_edit_text3(self): |
|
|
59 |
self.assertEqual(TextVersion.objects.count(), 1) |
|
|
60 |
self.assertEqual(Comment.objects.count(), 8) |
|
|
61 |
text = Text.objects.all()[0] |
|
|
62 |
new_text = text.edit(new_title='my title', |
|
|
63 |
new_format='html', |
|
278
|
64 |
new_content=u'xxxxxx', |
|
0
|
65 |
keep_comments = False, |
|
103
|
66 |
cancel_modified_scopes=False, |
|
0
|
67 |
new_version = True) |
|
|
68 |
self.assertEqual(TextVersion.objects.count(), 2) |
|
|
69 |
self.assertEqual(Comment.objects.count(), 8) |
|
|
70 |
|