Show More
@@ -1,313 +1,313 b'' | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
2 |
|
2 | |||
3 | ARCHIVE_SPECS = { |
|
3 | ARCHIVE_SPECS = { | |
4 | '.tar.bz2': ('application/x-bzip2', 'tbz2', ''), |
|
4 | '.tar.bz2': ('application/x-bzip2', 'tbz2', ''), | |
5 | '.tar.gz': ('application/x-gzip', 'tgz', ''), |
|
5 | '.tar.gz': ('application/x-gzip', 'tgz', ''), | |
6 | '.zip': ('application/zip', 'zip', ''), |
|
6 | '.zip': ('application/zip', 'zip', ''), | |
7 | } |
|
7 | } | |
8 |
|
8 | |||
9 | class TestFilesController(TestController): |
|
9 | class TestFilesController(TestController): | |
10 |
|
10 | |||
11 | def test_index(self): |
|
11 | def test_index(self): | |
12 | self.log_user() |
|
12 | self.log_user() | |
13 | response = self.app.get(url(controller='files', action='index', |
|
13 | response = self.app.get(url(controller='files', action='index', | |
14 | repo_name=HG_REPO, |
|
14 | repo_name=HG_REPO, | |
15 | revision='tip', |
|
15 | revision='tip', | |
16 | f_path='/')) |
|
16 | f_path='/')) | |
17 | # Test response... |
|
17 | # Test response... | |
18 | assert '<a class="browser-dir" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/docs">docs</a>' in response.body, 'missing dir' |
|
18 | assert '<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/docs">docs</a>' in response.body, 'missing dir' | |
19 | assert '<a class="browser-dir" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/tests">tests</a>' in response.body, 'missing dir' |
|
19 | assert '<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/tests">tests</a>' in response.body, 'missing dir' | |
20 | assert '<a class="browser-dir" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/vcs">vcs</a>' in response.body, 'missing dir' |
|
20 | assert '<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/vcs">vcs</a>' in response.body, 'missing dir' | |
21 | assert '<a class="browser-file" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/.hgignore">.hgignore</a>' in response.body, 'missing file' |
|
21 | assert '<a class="browser-file ypjax-link" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/.hgignore">.hgignore</a>' in response.body, 'missing file' | |
22 | assert '<a class="browser-file" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/MANIFEST.in">MANIFEST.in</a>' in response.body, 'missing file' |
|
22 | assert '<a class="browser-file ypjax-link" href="/vcs_test_hg/files/27cd5cce30c96924232dffcd24178a07ffeb5dfc/MANIFEST.in">MANIFEST.in</a>' in response.body, 'missing file' | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | def test_index_revision(self): |
|
25 | def test_index_revision(self): | |
26 | self.log_user() |
|
26 | self.log_user() | |
27 |
|
27 | |||
28 | response = self.app.get(url(controller='files', action='index', |
|
28 | response = self.app.get(url(controller='files', action='index', | |
29 | repo_name=HG_REPO, |
|
29 | repo_name=HG_REPO, | |
30 | revision='7ba66bec8d6dbba14a2155be32408c435c5f4492', |
|
30 | revision='7ba66bec8d6dbba14a2155be32408c435c5f4492', | |
31 | f_path='/')) |
|
31 | f_path='/')) | |
32 |
|
32 | |||
33 |
|
33 | |||
34 |
|
34 | |||
35 | #Test response... |
|
35 | #Test response... | |
36 |
|
36 | |||
37 | assert '<a class="browser-dir" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/docs">docs</a>' in response.body, 'missing dir' |
|
37 | assert '<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/docs">docs</a>' in response.body, 'missing dir' | |
38 | assert '<a class="browser-dir" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/tests">tests</a>' in response.body, 'missing dir' |
|
38 | assert '<a class="browser-dir ypjax-link" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/tests">tests</a>' in response.body, 'missing dir' | |
39 | assert '<a class="browser-file" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/README.rst">README.rst</a>' in response.body, 'missing file' |
|
39 | assert '<a class="browser-file ypjax-link" href="/vcs_test_hg/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/README.rst">README.rst</a>' in response.body, 'missing file' | |
40 | assert '1.1 KiB' in response.body, 'missing size of setup.py' |
|
40 | assert '1.1 KiB' in response.body, 'missing size of setup.py' | |
41 | assert 'text/x-python' in response.body, 'missing mimetype of setup.py' |
|
41 | assert 'text/x-python' in response.body, 'missing mimetype of setup.py' | |
42 |
|
42 | |||
43 |
|
43 | |||
44 |
|
44 | |||
45 | def test_index_different_branch(self): |
|
45 | def test_index_different_branch(self): | |
46 | self.log_user() |
|
46 | self.log_user() | |
47 |
|
47 | |||
48 | response = self.app.get(url(controller='files', action='index', |
|
48 | response = self.app.get(url(controller='files', action='index', | |
49 | repo_name=HG_REPO, |
|
49 | repo_name=HG_REPO, | |
50 | revision='97e8b885c04894463c51898e14387d80c30ed1ee', |
|
50 | revision='97e8b885c04894463c51898e14387d80c30ed1ee', | |
51 | f_path='/')) |
|
51 | f_path='/')) | |
52 |
|
52 | |||
53 |
|
53 | |||
54 |
|
54 | |||
55 | assert """<span style="text-transform: uppercase;"><a href="#">branch: git</a></span>""" in response.body, 'missing or wrong branch info' |
|
55 | assert """<span style="text-transform: uppercase;"><a href="#">branch: git</a></span>""" in response.body, 'missing or wrong branch info' | |
56 |
|
56 | |||
57 |
|
57 | |||
58 |
|
58 | |||
59 | def test_index_paging(self): |
|
59 | def test_index_paging(self): | |
60 | self.log_user() |
|
60 | self.log_user() | |
61 |
|
61 | |||
62 | for r in [(73, 'a066b25d5df7016b45a41b7e2a78c33b57adc235'), |
|
62 | for r in [(73, 'a066b25d5df7016b45a41b7e2a78c33b57adc235'), | |
63 | (92, 'cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e'), |
|
63 | (92, 'cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e'), | |
64 | (109, '75feb4c33e81186c87eac740cee2447330288412'), |
|
64 | (109, '75feb4c33e81186c87eac740cee2447330288412'), | |
65 | (1, '3d8f361e72ab303da48d799ff1ac40d5ac37c67e'), |
|
65 | (1, '3d8f361e72ab303da48d799ff1ac40d5ac37c67e'), | |
66 | (0, 'b986218ba1c9b0d6a259fac9b050b1724ed8e545')]: |
|
66 | (0, 'b986218ba1c9b0d6a259fac9b050b1724ed8e545')]: | |
67 |
|
67 | |||
68 | response = self.app.get(url(controller='files', action='index', |
|
68 | response = self.app.get(url(controller='files', action='index', | |
69 | repo_name=HG_REPO, |
|
69 | repo_name=HG_REPO, | |
70 | revision=r[1], |
|
70 | revision=r[1], | |
71 | f_path='/')) |
|
71 | f_path='/')) | |
72 |
|
72 | |||
73 | assert """@ r%s:%s""" % (r[0], r[1][:12]) in response.body, 'missing info about current revision' |
|
73 | assert """@ r%s:%s""" % (r[0], r[1][:12]) in response.body, 'missing info about current revision' | |
74 |
|
74 | |||
75 | def test_file_source(self): |
|
75 | def test_file_source(self): | |
76 | self.log_user() |
|
76 | self.log_user() | |
77 | response = self.app.get(url(controller='files', action='index', |
|
77 | response = self.app.get(url(controller='files', action='index', | |
78 | repo_name=HG_REPO, |
|
78 | repo_name=HG_REPO, | |
79 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', |
|
79 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', | |
80 | f_path='vcs/nodes.py')) |
|
80 | f_path='vcs/nodes.py')) | |
81 |
|
81 | |||
82 | #test or history |
|
82 | #test or history | |
83 | assert """<optgroup label="Changesets"> |
|
83 | assert """<optgroup label="Changesets"> | |
84 | <option selected="selected" value="8911406ad776fdd3d0b9932a2e89677e57405a48">r167:8911406ad776</option> |
|
84 | <option selected="selected" value="8911406ad776fdd3d0b9932a2e89677e57405a48">r167:8911406ad776</option> | |
85 | <option value="aa957ed78c35a1541f508d2ec90e501b0a9e3167">r165:aa957ed78c35</option> |
|
85 | <option value="aa957ed78c35a1541f508d2ec90e501b0a9e3167">r165:aa957ed78c35</option> | |
86 | <option value="48e11b73e94c0db33e736eaeea692f990cb0b5f1">r140:48e11b73e94c</option> |
|
86 | <option value="48e11b73e94c0db33e736eaeea692f990cb0b5f1">r140:48e11b73e94c</option> | |
87 | <option value="adf3cbf483298563b968a6c673cd5bde5f7d5eea">r126:adf3cbf48329</option> |
|
87 | <option value="adf3cbf483298563b968a6c673cd5bde5f7d5eea">r126:adf3cbf48329</option> | |
88 | <option value="6249fd0fb2cfb1411e764129f598e2cf0de79a6f">r113:6249fd0fb2cf</option> |
|
88 | <option value="6249fd0fb2cfb1411e764129f598e2cf0de79a6f">r113:6249fd0fb2cf</option> | |
89 | <option value="75feb4c33e81186c87eac740cee2447330288412">r109:75feb4c33e81</option> |
|
89 | <option value="75feb4c33e81186c87eac740cee2447330288412">r109:75feb4c33e81</option> | |
90 | <option value="9a4dc232ecdc763ef2e98ae2238cfcbba4f6ad8d">r108:9a4dc232ecdc</option> |
|
90 | <option value="9a4dc232ecdc763ef2e98ae2238cfcbba4f6ad8d">r108:9a4dc232ecdc</option> | |
91 | <option value="595cce4efa21fda2f2e4eeb4fe5f2a6befe6fa2d">r107:595cce4efa21</option> |
|
91 | <option value="595cce4efa21fda2f2e4eeb4fe5f2a6befe6fa2d">r107:595cce4efa21</option> | |
92 | <option value="4a8bd421fbc2dfbfb70d85a3fe064075ab2c49da">r104:4a8bd421fbc2</option> |
|
92 | <option value="4a8bd421fbc2dfbfb70d85a3fe064075ab2c49da">r104:4a8bd421fbc2</option> | |
93 | <option value="57be63fc8f85e65a0106a53187f7316f8c487ffa">r102:57be63fc8f85</option> |
|
93 | <option value="57be63fc8f85e65a0106a53187f7316f8c487ffa">r102:57be63fc8f85</option> | |
94 | <option value="5530bd87f7e2e124a64d07cb2654c997682128be">r101:5530bd87f7e2</option> |
|
94 | <option value="5530bd87f7e2e124a64d07cb2654c997682128be">r101:5530bd87f7e2</option> | |
95 | <option value="e516008b1c93f142263dc4b7961787cbad654ce1">r99:e516008b1c93</option> |
|
95 | <option value="e516008b1c93f142263dc4b7961787cbad654ce1">r99:e516008b1c93</option> | |
96 | <option value="41f43fc74b8b285984554532eb105ac3be5c434f">r93:41f43fc74b8b</option> |
|
96 | <option value="41f43fc74b8b285984554532eb105ac3be5c434f">r93:41f43fc74b8b</option> | |
97 | <option value="cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e">r92:cc66b61b8455</option> |
|
97 | <option value="cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e">r92:cc66b61b8455</option> | |
98 | <option value="73ab5b616b3271b0518682fb4988ce421de8099f">r91:73ab5b616b32</option> |
|
98 | <option value="73ab5b616b3271b0518682fb4988ce421de8099f">r91:73ab5b616b32</option> | |
99 | <option value="e0da75f308c0f18f98e9ce6257626009fdda2b39">r82:e0da75f308c0</option> |
|
99 | <option value="e0da75f308c0f18f98e9ce6257626009fdda2b39">r82:e0da75f308c0</option> | |
100 | <option value="fb2e41e0f0810be4d7103bc2a4c7be16ee3ec611">r81:fb2e41e0f081</option> |
|
100 | <option value="fb2e41e0f0810be4d7103bc2a4c7be16ee3ec611">r81:fb2e41e0f081</option> | |
101 | <option value="602ae2f5e7ade70b3b66a58cdd9e3e613dc8a028">r76:602ae2f5e7ad</option> |
|
101 | <option value="602ae2f5e7ade70b3b66a58cdd9e3e613dc8a028">r76:602ae2f5e7ad</option> | |
102 | <option value="a066b25d5df7016b45a41b7e2a78c33b57adc235">r73:a066b25d5df7</option> |
|
102 | <option value="a066b25d5df7016b45a41b7e2a78c33b57adc235">r73:a066b25d5df7</option> | |
103 | <option value="637a933c905958ce5151f154147c25c1c7b68832">r61:637a933c9059</option> |
|
103 | <option value="637a933c905958ce5151f154147c25c1c7b68832">r61:637a933c9059</option> | |
104 | <option value="0c21004effeb8ce2d2d5b4a8baf6afa8394b6fbc">r60:0c21004effeb</option> |
|
104 | <option value="0c21004effeb8ce2d2d5b4a8baf6afa8394b6fbc">r60:0c21004effeb</option> | |
105 | <option value="a1f39c56d3f1d52d5fb5920370a2a2716cd9a444">r59:a1f39c56d3f1</option> |
|
105 | <option value="a1f39c56d3f1d52d5fb5920370a2a2716cd9a444">r59:a1f39c56d3f1</option> | |
106 | <option value="97d32df05c715a3bbf936bf3cc4e32fb77fe1a7f">r58:97d32df05c71</option> |
|
106 | <option value="97d32df05c715a3bbf936bf3cc4e32fb77fe1a7f">r58:97d32df05c71</option> | |
107 | <option value="08eaf14517718dccea4b67755a93368341aca919">r57:08eaf1451771</option> |
|
107 | <option value="08eaf14517718dccea4b67755a93368341aca919">r57:08eaf1451771</option> | |
108 | <option value="22f71ad265265a53238359c883aa976e725aa07d">r56:22f71ad26526</option> |
|
108 | <option value="22f71ad265265a53238359c883aa976e725aa07d">r56:22f71ad26526</option> | |
109 | <option value="97501f02b7b4330924b647755663a2d90a5e638d">r49:97501f02b7b4</option> |
|
109 | <option value="97501f02b7b4330924b647755663a2d90a5e638d">r49:97501f02b7b4</option> | |
110 | <option value="86ede6754f2b27309452bb11f997386ae01d0e5a">r47:86ede6754f2b</option> |
|
110 | <option value="86ede6754f2b27309452bb11f997386ae01d0e5a">r47:86ede6754f2b</option> | |
111 | <option value="014c40c0203c423dc19ecf94644f7cac9d4cdce0">r45:014c40c0203c</option> |
|
111 | <option value="014c40c0203c423dc19ecf94644f7cac9d4cdce0">r45:014c40c0203c</option> | |
112 | <option value="ee87846a61c12153b51543bf860e1026c6d3dcba">r30:ee87846a61c1</option> |
|
112 | <option value="ee87846a61c12153b51543bf860e1026c6d3dcba">r30:ee87846a61c1</option> | |
113 | <option value="9bb326a04ae5d98d437dece54be04f830cf1edd9">r26:9bb326a04ae5</option> |
|
113 | <option value="9bb326a04ae5d98d437dece54be04f830cf1edd9">r26:9bb326a04ae5</option> | |
114 | <option value="536c1a19428381cfea92ac44985304f6a8049569">r24:536c1a194283</option> |
|
114 | <option value="536c1a19428381cfea92ac44985304f6a8049569">r24:536c1a194283</option> | |
115 | <option value="dc5d2c0661b61928834a785d3e64a3f80d3aad9c">r8:dc5d2c0661b6</option> |
|
115 | <option value="dc5d2c0661b61928834a785d3e64a3f80d3aad9c">r8:dc5d2c0661b6</option> | |
116 | <option value="3803844fdbd3b711175fc3da9bdacfcd6d29a6fb">r7:3803844fdbd3</option> |
|
116 | <option value="3803844fdbd3b711175fc3da9bdacfcd6d29a6fb">r7:3803844fdbd3</option> | |
117 | </optgroup> |
|
117 | </optgroup> | |
118 | <optgroup label="Branches"> |
|
118 | <optgroup label="Branches"> | |
119 | <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">default</option> |
|
119 | <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">default</option> | |
120 | <option value="97e8b885c04894463c51898e14387d80c30ed1ee">git</option> |
|
120 | <option value="97e8b885c04894463c51898e14387d80c30ed1ee">git</option> | |
121 | <option value="2e6a2bf9356ca56df08807f4ad86d480da72a8f4">web</option> |
|
121 | <option value="2e6a2bf9356ca56df08807f4ad86d480da72a8f4">web</option> | |
122 | </optgroup> |
|
122 | </optgroup> | |
123 | <optgroup label="Tags"> |
|
123 | <optgroup label="Tags"> | |
124 | <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">tip</option> |
|
124 | <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">tip</option> | |
125 | <option value="fd4bdb5e9b2a29b4393a4ac6caef48c17ee1a200">0.1.4</option> |
|
125 | <option value="fd4bdb5e9b2a29b4393a4ac6caef48c17ee1a200">0.1.4</option> | |
126 | <option value="17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">0.1.3</option> |
|
126 | <option value="17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">0.1.3</option> | |
127 | <option value="a7e60bff65d57ac3a1a1ce3b12a70f8a9e8a7720">0.1.2</option> |
|
127 | <option value="a7e60bff65d57ac3a1a1ce3b12a70f8a9e8a7720">0.1.2</option> | |
128 | <option value="eb3a60fc964309c1a318b8dfe26aa2d1586c85ae">0.1.1</option> |
|
128 | <option value="eb3a60fc964309c1a318b8dfe26aa2d1586c85ae">0.1.1</option> | |
129 | </optgroup>""" in response.body |
|
129 | </optgroup>""" in response.body | |
130 |
|
130 | |||
131 |
|
131 | |||
132 | assert """<div class="commit">"Partially implemented #16. filecontent/commit message/author/node name are safe_unicode now. |
|
132 | assert """<div class="commit">"Partially implemented #16. filecontent/commit message/author/node name are safe_unicode now. | |
133 | In addition some other __str__ are unicode as well |
|
133 | In addition some other __str__ are unicode as well | |
134 | Added test for unicode |
|
134 | Added test for unicode | |
135 | Improved test to clone into uniq repository. |
|
135 | Improved test to clone into uniq repository. | |
136 | removed extra unicode conversion in diff."</div>""" in response.body |
|
136 | removed extra unicode conversion in diff."</div>""" in response.body | |
137 |
|
137 | |||
138 | assert """<span style="text-transform: uppercase;"><a href="#">branch: default</a></span>""" in response.body, 'missing or wrong branch info' |
|
138 | assert """<span style="text-transform: uppercase;"><a href="#">branch: default</a></span>""" in response.body, 'missing or wrong branch info' | |
139 |
|
139 | |||
140 | def test_file_annotation(self): |
|
140 | def test_file_annotation(self): | |
141 | self.log_user() |
|
141 | self.log_user() | |
142 | response = self.app.get(url(controller='files', action='annotate', |
|
142 | response = self.app.get(url(controller='files', action='annotate', | |
143 | repo_name=HG_REPO, |
|
143 | repo_name=HG_REPO, | |
144 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', |
|
144 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', | |
145 | f_path='vcs/nodes.py')) |
|
145 | f_path='vcs/nodes.py')) | |
146 |
|
146 | |||
147 | print response.body |
|
147 | print response.body | |
148 | assert """<optgroup label="Changesets"> |
|
148 | assert """<optgroup label="Changesets"> | |
149 | <option selected="selected" value="8911406ad776fdd3d0b9932a2e89677e57405a48">r167:8911406ad776</option> |
|
149 | <option selected="selected" value="8911406ad776fdd3d0b9932a2e89677e57405a48">r167:8911406ad776</option> | |
150 | <option value="aa957ed78c35a1541f508d2ec90e501b0a9e3167">r165:aa957ed78c35</option> |
|
150 | <option value="aa957ed78c35a1541f508d2ec90e501b0a9e3167">r165:aa957ed78c35</option> | |
151 | <option value="48e11b73e94c0db33e736eaeea692f990cb0b5f1">r140:48e11b73e94c</option> |
|
151 | <option value="48e11b73e94c0db33e736eaeea692f990cb0b5f1">r140:48e11b73e94c</option> | |
152 | <option value="adf3cbf483298563b968a6c673cd5bde5f7d5eea">r126:adf3cbf48329</option> |
|
152 | <option value="adf3cbf483298563b968a6c673cd5bde5f7d5eea">r126:adf3cbf48329</option> | |
153 | <option value="6249fd0fb2cfb1411e764129f598e2cf0de79a6f">r113:6249fd0fb2cf</option> |
|
153 | <option value="6249fd0fb2cfb1411e764129f598e2cf0de79a6f">r113:6249fd0fb2cf</option> | |
154 | <option value="75feb4c33e81186c87eac740cee2447330288412">r109:75feb4c33e81</option> |
|
154 | <option value="75feb4c33e81186c87eac740cee2447330288412">r109:75feb4c33e81</option> | |
155 | <option value="9a4dc232ecdc763ef2e98ae2238cfcbba4f6ad8d">r108:9a4dc232ecdc</option> |
|
155 | <option value="9a4dc232ecdc763ef2e98ae2238cfcbba4f6ad8d">r108:9a4dc232ecdc</option> | |
156 | <option value="595cce4efa21fda2f2e4eeb4fe5f2a6befe6fa2d">r107:595cce4efa21</option> |
|
156 | <option value="595cce4efa21fda2f2e4eeb4fe5f2a6befe6fa2d">r107:595cce4efa21</option> | |
157 | <option value="4a8bd421fbc2dfbfb70d85a3fe064075ab2c49da">r104:4a8bd421fbc2</option> |
|
157 | <option value="4a8bd421fbc2dfbfb70d85a3fe064075ab2c49da">r104:4a8bd421fbc2</option> | |
158 | <option value="57be63fc8f85e65a0106a53187f7316f8c487ffa">r102:57be63fc8f85</option> |
|
158 | <option value="57be63fc8f85e65a0106a53187f7316f8c487ffa">r102:57be63fc8f85</option> | |
159 | <option value="5530bd87f7e2e124a64d07cb2654c997682128be">r101:5530bd87f7e2</option> |
|
159 | <option value="5530bd87f7e2e124a64d07cb2654c997682128be">r101:5530bd87f7e2</option> | |
160 | <option value="e516008b1c93f142263dc4b7961787cbad654ce1">r99:e516008b1c93</option> |
|
160 | <option value="e516008b1c93f142263dc4b7961787cbad654ce1">r99:e516008b1c93</option> | |
161 | <option value="41f43fc74b8b285984554532eb105ac3be5c434f">r93:41f43fc74b8b</option> |
|
161 | <option value="41f43fc74b8b285984554532eb105ac3be5c434f">r93:41f43fc74b8b</option> | |
162 | <option value="cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e">r92:cc66b61b8455</option> |
|
162 | <option value="cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e">r92:cc66b61b8455</option> | |
163 | <option value="73ab5b616b3271b0518682fb4988ce421de8099f">r91:73ab5b616b32</option> |
|
163 | <option value="73ab5b616b3271b0518682fb4988ce421de8099f">r91:73ab5b616b32</option> | |
164 | <option value="e0da75f308c0f18f98e9ce6257626009fdda2b39">r82:e0da75f308c0</option> |
|
164 | <option value="e0da75f308c0f18f98e9ce6257626009fdda2b39">r82:e0da75f308c0</option> | |
165 | <option value="fb2e41e0f0810be4d7103bc2a4c7be16ee3ec611">r81:fb2e41e0f081</option> |
|
165 | <option value="fb2e41e0f0810be4d7103bc2a4c7be16ee3ec611">r81:fb2e41e0f081</option> | |
166 | <option value="602ae2f5e7ade70b3b66a58cdd9e3e613dc8a028">r76:602ae2f5e7ad</option> |
|
166 | <option value="602ae2f5e7ade70b3b66a58cdd9e3e613dc8a028">r76:602ae2f5e7ad</option> | |
167 | <option value="a066b25d5df7016b45a41b7e2a78c33b57adc235">r73:a066b25d5df7</option> |
|
167 | <option value="a066b25d5df7016b45a41b7e2a78c33b57adc235">r73:a066b25d5df7</option> | |
168 | <option value="637a933c905958ce5151f154147c25c1c7b68832">r61:637a933c9059</option> |
|
168 | <option value="637a933c905958ce5151f154147c25c1c7b68832">r61:637a933c9059</option> | |
169 | <option value="0c21004effeb8ce2d2d5b4a8baf6afa8394b6fbc">r60:0c21004effeb</option> |
|
169 | <option value="0c21004effeb8ce2d2d5b4a8baf6afa8394b6fbc">r60:0c21004effeb</option> | |
170 | <option value="a1f39c56d3f1d52d5fb5920370a2a2716cd9a444">r59:a1f39c56d3f1</option> |
|
170 | <option value="a1f39c56d3f1d52d5fb5920370a2a2716cd9a444">r59:a1f39c56d3f1</option> | |
171 | <option value="97d32df05c715a3bbf936bf3cc4e32fb77fe1a7f">r58:97d32df05c71</option> |
|
171 | <option value="97d32df05c715a3bbf936bf3cc4e32fb77fe1a7f">r58:97d32df05c71</option> | |
172 | <option value="08eaf14517718dccea4b67755a93368341aca919">r57:08eaf1451771</option> |
|
172 | <option value="08eaf14517718dccea4b67755a93368341aca919">r57:08eaf1451771</option> | |
173 | <option value="22f71ad265265a53238359c883aa976e725aa07d">r56:22f71ad26526</option> |
|
173 | <option value="22f71ad265265a53238359c883aa976e725aa07d">r56:22f71ad26526</option> | |
174 | <option value="97501f02b7b4330924b647755663a2d90a5e638d">r49:97501f02b7b4</option> |
|
174 | <option value="97501f02b7b4330924b647755663a2d90a5e638d">r49:97501f02b7b4</option> | |
175 | <option value="86ede6754f2b27309452bb11f997386ae01d0e5a">r47:86ede6754f2b</option> |
|
175 | <option value="86ede6754f2b27309452bb11f997386ae01d0e5a">r47:86ede6754f2b</option> | |
176 | <option value="014c40c0203c423dc19ecf94644f7cac9d4cdce0">r45:014c40c0203c</option> |
|
176 | <option value="014c40c0203c423dc19ecf94644f7cac9d4cdce0">r45:014c40c0203c</option> | |
177 | <option value="ee87846a61c12153b51543bf860e1026c6d3dcba">r30:ee87846a61c1</option> |
|
177 | <option value="ee87846a61c12153b51543bf860e1026c6d3dcba">r30:ee87846a61c1</option> | |
178 | <option value="9bb326a04ae5d98d437dece54be04f830cf1edd9">r26:9bb326a04ae5</option> |
|
178 | <option value="9bb326a04ae5d98d437dece54be04f830cf1edd9">r26:9bb326a04ae5</option> | |
179 | <option value="536c1a19428381cfea92ac44985304f6a8049569">r24:536c1a194283</option> |
|
179 | <option value="536c1a19428381cfea92ac44985304f6a8049569">r24:536c1a194283</option> | |
180 | <option value="dc5d2c0661b61928834a785d3e64a3f80d3aad9c">r8:dc5d2c0661b6</option> |
|
180 | <option value="dc5d2c0661b61928834a785d3e64a3f80d3aad9c">r8:dc5d2c0661b6</option> | |
181 | <option value="3803844fdbd3b711175fc3da9bdacfcd6d29a6fb">r7:3803844fdbd3</option> |
|
181 | <option value="3803844fdbd3b711175fc3da9bdacfcd6d29a6fb">r7:3803844fdbd3</option> | |
182 | </optgroup> |
|
182 | </optgroup> | |
183 | <optgroup label="Branches"> |
|
183 | <optgroup label="Branches"> | |
184 | <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">default</option> |
|
184 | <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">default</option> | |
185 | <option value="97e8b885c04894463c51898e14387d80c30ed1ee">git</option> |
|
185 | <option value="97e8b885c04894463c51898e14387d80c30ed1ee">git</option> | |
186 | <option value="2e6a2bf9356ca56df08807f4ad86d480da72a8f4">web</option> |
|
186 | <option value="2e6a2bf9356ca56df08807f4ad86d480da72a8f4">web</option> | |
187 | </optgroup> |
|
187 | </optgroup> | |
188 | <optgroup label="Tags"> |
|
188 | <optgroup label="Tags"> | |
189 | <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">tip</option> |
|
189 | <option value="27cd5cce30c96924232dffcd24178a07ffeb5dfc">tip</option> | |
190 | <option value="fd4bdb5e9b2a29b4393a4ac6caef48c17ee1a200">0.1.4</option> |
|
190 | <option value="fd4bdb5e9b2a29b4393a4ac6caef48c17ee1a200">0.1.4</option> | |
191 | <option value="17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">0.1.3</option> |
|
191 | <option value="17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">0.1.3</option> | |
192 | <option value="a7e60bff65d57ac3a1a1ce3b12a70f8a9e8a7720">0.1.2</option> |
|
192 | <option value="a7e60bff65d57ac3a1a1ce3b12a70f8a9e8a7720">0.1.2</option> | |
193 | <option value="eb3a60fc964309c1a318b8dfe26aa2d1586c85ae">0.1.1</option> |
|
193 | <option value="eb3a60fc964309c1a318b8dfe26aa2d1586c85ae">0.1.1</option> | |
194 | </optgroup>""" in response.body, 'missing or wrong history in annotation' |
|
194 | </optgroup>""" in response.body, 'missing or wrong history in annotation' | |
195 |
|
195 | |||
196 | assert """<span style="text-transform: uppercase;"><a href="#">branch: default</a></span>""" in response.body, 'missing or wrong branch info' |
|
196 | assert """<span style="text-transform: uppercase;"><a href="#">branch: default</a></span>""" in response.body, 'missing or wrong branch info' | |
197 |
|
197 | |||
198 |
|
198 | |||
199 |
|
199 | |||
200 | def test_archival(self): |
|
200 | def test_archival(self): | |
201 | self.log_user() |
|
201 | self.log_user() | |
202 |
|
202 | |||
203 | for arch_ext, info in ARCHIVE_SPECS.items(): |
|
203 | for arch_ext, info in ARCHIVE_SPECS.items(): | |
204 | fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext |
|
204 | fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext | |
205 | filename = '%s-%s' % (HG_REPO, fname) |
|
205 | filename = '%s-%s' % (HG_REPO, fname) | |
206 |
|
206 | |||
207 | response = self.app.get(url(controller='files', action='archivefile', |
|
207 | response = self.app.get(url(controller='files', action='archivefile', | |
208 | repo_name=HG_REPO, |
|
208 | repo_name=HG_REPO, | |
209 | fname=fname)) |
|
209 | fname=fname)) | |
210 |
|
210 | |||
211 | assert response.status == '200 OK', 'wrong response code' |
|
211 | assert response.status == '200 OK', 'wrong response code' | |
212 | assert response.response._headers.items() == [('Pragma', 'no-cache'), |
|
212 | assert response.response._headers.items() == [('Pragma', 'no-cache'), | |
213 | ('Cache-Control', 'no-cache'), |
|
213 | ('Cache-Control', 'no-cache'), | |
214 | ('Content-Type', '%s; charset=utf-8' % info[0]), |
|
214 | ('Content-Type', '%s; charset=utf-8' % info[0]), | |
215 | ('Content-Disposition', 'attachment; filename=%s' % filename), ], 'wrong headers' |
|
215 | ('Content-Disposition', 'attachment; filename=%s' % filename), ], 'wrong headers' | |
216 |
|
216 | |||
217 | def test_archival_wrong_ext(self): |
|
217 | def test_archival_wrong_ext(self): | |
218 | self.log_user() |
|
218 | self.log_user() | |
219 |
|
219 | |||
220 | for arch_ext in ['tar', 'rar', 'x', '..ax', '.zipz']: |
|
220 | for arch_ext in ['tar', 'rar', 'x', '..ax', '.zipz']: | |
221 | fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext |
|
221 | fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext | |
222 |
|
222 | |||
223 | response = self.app.get(url(controller='files', action='archivefile', |
|
223 | response = self.app.get(url(controller='files', action='archivefile', | |
224 | repo_name=HG_REPO, |
|
224 | repo_name=HG_REPO, | |
225 | fname=fname)) |
|
225 | fname=fname)) | |
226 | assert 'Unknown archive type' in response.body |
|
226 | assert 'Unknown archive type' in response.body | |
227 |
|
227 | |||
228 |
|
228 | |||
229 | def test_archival_wrong_revision(self): |
|
229 | def test_archival_wrong_revision(self): | |
230 | self.log_user() |
|
230 | self.log_user() | |
231 |
|
231 | |||
232 | for rev in ['00x000000', 'tar', 'wrong', '@##$@$424213232', '232dffcd']: |
|
232 | for rev in ['00x000000', 'tar', 'wrong', '@##$@$424213232', '232dffcd']: | |
233 | fname = '%s.zip' % rev |
|
233 | fname = '%s.zip' % rev | |
234 |
|
234 | |||
235 | response = self.app.get(url(controller='files', action='archivefile', |
|
235 | response = self.app.get(url(controller='files', action='archivefile', | |
236 | repo_name=HG_REPO, |
|
236 | repo_name=HG_REPO, | |
237 | fname=fname)) |
|
237 | fname=fname)) | |
238 | assert 'Unknown revision' in response.body |
|
238 | assert 'Unknown revision' in response.body | |
239 |
|
239 | |||
240 | #========================================================================== |
|
240 | #========================================================================== | |
241 | # RAW FILE |
|
241 | # RAW FILE | |
242 | #========================================================================== |
|
242 | #========================================================================== | |
243 | def test_raw_file_ok(self): |
|
243 | def test_raw_file_ok(self): | |
244 | self.log_user() |
|
244 | self.log_user() | |
245 | response = self.app.get(url(controller='files', action='rawfile', |
|
245 | response = self.app.get(url(controller='files', action='rawfile', | |
246 | repo_name=HG_REPO, |
|
246 | repo_name=HG_REPO, | |
247 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', |
|
247 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', | |
248 | f_path='vcs/nodes.py')) |
|
248 | f_path='vcs/nodes.py')) | |
249 |
|
249 | |||
250 | assert response.content_disposition == "attachment; filename=nodes.py" |
|
250 | assert response.content_disposition == "attachment; filename=nodes.py" | |
251 | assert response.content_type == "text/x-python" |
|
251 | assert response.content_type == "text/x-python" | |
252 |
|
252 | |||
253 | def test_raw_file_wrong_cs(self): |
|
253 | def test_raw_file_wrong_cs(self): | |
254 | self.log_user() |
|
254 | self.log_user() | |
255 | rev = u'ERRORce30c96924232dffcd24178a07ffeb5dfc' |
|
255 | rev = u'ERRORce30c96924232dffcd24178a07ffeb5dfc' | |
256 | f_path = 'vcs/nodes.py' |
|
256 | f_path = 'vcs/nodes.py' | |
257 |
|
257 | |||
258 | response = self.app.get(url(controller='files', action='rawfile', |
|
258 | response = self.app.get(url(controller='files', action='rawfile', | |
259 | repo_name=HG_REPO, |
|
259 | repo_name=HG_REPO, | |
260 | revision=rev, |
|
260 | revision=rev, | |
261 | f_path=f_path)) |
|
261 | f_path=f_path)) | |
262 |
|
262 | |||
263 | assert """Revision %r does not exist for this repository""" % (rev) in response.session['flash'][0][1], 'No flash message' |
|
263 | assert """Revision %r does not exist for this repository""" % (rev) in response.session['flash'][0][1], 'No flash message' | |
264 | assert """%s""" % (HG_REPO) in response.session['flash'][0][1], 'No flash message' |
|
264 | assert """%s""" % (HG_REPO) in response.session['flash'][0][1], 'No flash message' | |
265 |
|
265 | |||
266 |
|
266 | |||
267 |
|
267 | |||
268 | def test_raw_file_wrong_f_path(self): |
|
268 | def test_raw_file_wrong_f_path(self): | |
269 | self.log_user() |
|
269 | self.log_user() | |
270 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
270 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
271 | f_path = 'vcs/ERRORnodes.py' |
|
271 | f_path = 'vcs/ERRORnodes.py' | |
272 | response = self.app.get(url(controller='files', action='rawfile', |
|
272 | response = self.app.get(url(controller='files', action='rawfile', | |
273 | repo_name=HG_REPO, |
|
273 | repo_name=HG_REPO, | |
274 | revision=rev, |
|
274 | revision=rev, | |
275 | f_path=f_path)) |
|
275 | f_path=f_path)) | |
276 | assert "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12]) in response.session['flash'][0][1], 'No flash message' |
|
276 | assert "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12]) in response.session['flash'][0][1], 'No flash message' | |
277 |
|
277 | |||
278 | #========================================================================== |
|
278 | #========================================================================== | |
279 | # RAW RESPONSE - PLAIN |
|
279 | # RAW RESPONSE - PLAIN | |
280 | #========================================================================== |
|
280 | #========================================================================== | |
281 | def test_raw_ok(self): |
|
281 | def test_raw_ok(self): | |
282 | self.log_user() |
|
282 | self.log_user() | |
283 | response = self.app.get(url(controller='files', action='raw', |
|
283 | response = self.app.get(url(controller='files', action='raw', | |
284 | repo_name=HG_REPO, |
|
284 | repo_name=HG_REPO, | |
285 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', |
|
285 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', | |
286 | f_path='vcs/nodes.py')) |
|
286 | f_path='vcs/nodes.py')) | |
287 |
|
287 | |||
288 | assert response.content_type == "text/plain" |
|
288 | assert response.content_type == "text/plain" | |
289 |
|
289 | |||
290 | def test_raw_wrong_cs(self): |
|
290 | def test_raw_wrong_cs(self): | |
291 | self.log_user() |
|
291 | self.log_user() | |
292 | rev = u'ERRORcce30c96924232dffcd24178a07ffeb5dfc' |
|
292 | rev = u'ERRORcce30c96924232dffcd24178a07ffeb5dfc' | |
293 | f_path = 'vcs/nodes.py' |
|
293 | f_path = 'vcs/nodes.py' | |
294 |
|
294 | |||
295 | response = self.app.get(url(controller='files', action='raw', |
|
295 | response = self.app.get(url(controller='files', action='raw', | |
296 | repo_name=HG_REPO, |
|
296 | repo_name=HG_REPO, | |
297 | revision=rev, |
|
297 | revision=rev, | |
298 | f_path=f_path)) |
|
298 | f_path=f_path)) | |
299 |
|
299 | |||
300 | assert """Revision %r does not exist for this repository""" % (rev) in response.session['flash'][0][1], 'No flash message' |
|
300 | assert """Revision %r does not exist for this repository""" % (rev) in response.session['flash'][0][1], 'No flash message' | |
301 | assert """%s""" % (HG_REPO) in response.session['flash'][0][1], 'No flash message' |
|
301 | assert """%s""" % (HG_REPO) in response.session['flash'][0][1], 'No flash message' | |
302 |
|
302 | |||
303 |
|
303 | |||
304 | def test_raw_wrong_f_path(self): |
|
304 | def test_raw_wrong_f_path(self): | |
305 | self.log_user() |
|
305 | self.log_user() | |
306 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
306 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
307 | f_path = 'vcs/ERRORnodes.py' |
|
307 | f_path = 'vcs/ERRORnodes.py' | |
308 | response = self.app.get(url(controller='files', action='raw', |
|
308 | response = self.app.get(url(controller='files', action='raw', | |
309 | repo_name=HG_REPO, |
|
309 | repo_name=HG_REPO, | |
310 | revision=rev, |
|
310 | revision=rev, | |
311 | f_path=f_path)) |
|
311 | f_path=f_path)) | |
312 |
|
312 | |||
313 | assert "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12]) in response.session['flash'][0][1], 'No flash message' |
|
313 | assert "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12]) in response.session['flash'][0][1], 'No flash message' |
@@ -1,216 +1,221 b'' | |||||
1 | import os |
|
1 | import os | |
2 | import unittest |
|
2 | import unittest | |
3 | from rhodecode.tests import * |
|
3 | from rhodecode.tests import * | |
4 |
|
4 | |||
5 | from rhodecode.model.repos_group import ReposGroupModel |
|
5 | from rhodecode.model.repos_group import ReposGroupModel | |
6 | from rhodecode.model.repo import RepoModel |
|
6 | from rhodecode.model.repo import RepoModel | |
7 | from rhodecode.model.db import RepoGroup, User, Notification, UserNotification |
|
7 | from rhodecode.model.db import RepoGroup, User, Notification, UserNotification | |
8 | from sqlalchemy.exc import IntegrityError |
|
8 | from sqlalchemy.exc import IntegrityError | |
9 | from rhodecode.model.user import UserModel |
|
9 | from rhodecode.model.user import UserModel | |
10 |
|
10 | |||
11 | from rhodecode.model import meta |
|
11 | from rhodecode.model import meta | |
12 |
|
12 | |||
13 | Session = meta.Session() |
|
13 | Session = meta.Session() | |
14 |
|
14 | |||
15 | class TestReposGroups(unittest.TestCase): |
|
15 | class TestReposGroups(unittest.TestCase): | |
16 |
|
16 | |||
17 | def setUp(self): |
|
17 | def setUp(self): | |
18 | self.g1 = self.__make_group('test1', skip_if_exists=True) |
|
18 | self.g1 = self.__make_group('test1', skip_if_exists=True) | |
19 | self.g2 = self.__make_group('test2', skip_if_exists=True) |
|
19 | self.g2 = self.__make_group('test2', skip_if_exists=True) | |
20 | self.g3 = self.__make_group('test3', skip_if_exists=True) |
|
20 | self.g3 = self.__make_group('test3', skip_if_exists=True) | |
21 |
|
21 | |||
22 | def tearDown(self): |
|
22 | def tearDown(self): | |
23 | print 'out' |
|
23 | print 'out' | |
24 |
|
24 | |||
25 | def __check_path(self, *path): |
|
25 | def __check_path(self, *path): | |
26 | path = [TESTS_TMP_PATH] + list(path) |
|
26 | path = [TESTS_TMP_PATH] + list(path) | |
27 | path = os.path.join(*path) |
|
27 | path = os.path.join(*path) | |
28 | return os.path.isdir(path) |
|
28 | return os.path.isdir(path) | |
29 |
|
29 | |||
30 | def _check_folders(self): |
|
30 | def _check_folders(self): | |
31 | print os.listdir(TESTS_TMP_PATH) |
|
31 | print os.listdir(TESTS_TMP_PATH) | |
32 |
|
32 | |||
33 | def __make_group(self, path, desc='desc', parent_id=None, |
|
33 | def __make_group(self, path, desc='desc', parent_id=None, | |
34 | skip_if_exists=False): |
|
34 | skip_if_exists=False): | |
35 |
|
35 | |||
36 | gr = RepoGroup.get_by_group_name(path) |
|
36 | gr = RepoGroup.get_by_group_name(path) | |
37 | if gr and skip_if_exists: |
|
37 | if gr and skip_if_exists: | |
38 | return gr |
|
38 | return gr | |
39 |
|
39 | |||
40 | form_data = dict(group_name=path, |
|
40 | form_data = dict(group_name=path, | |
41 | group_description=desc, |
|
41 | group_description=desc, | |
42 | group_parent_id=parent_id) |
|
42 | group_parent_id=parent_id) | |
43 | gr = ReposGroupModel().create(form_data) |
|
43 | gr = ReposGroupModel().create(form_data) | |
44 | return gr |
|
44 | return gr | |
45 |
|
45 | |||
46 | def __delete_group(self, id_): |
|
46 | def __delete_group(self, id_): | |
47 | ReposGroupModel().delete(id_) |
|
47 | ReposGroupModel().delete(id_) | |
48 |
|
48 | |||
49 |
|
49 | |||
50 | def __update_group(self, id_, path, desc='desc', parent_id=None): |
|
50 | def __update_group(self, id_, path, desc='desc', parent_id=None): | |
51 | form_data = dict(group_name=path, |
|
51 | form_data = dict(group_name=path, | |
52 | group_description=desc, |
|
52 | group_description=desc, | |
53 | group_parent_id=parent_id) |
|
53 | group_parent_id=parent_id) | |
54 |
|
54 | |||
55 | gr = ReposGroupModel().update(id_, form_data) |
|
55 | gr = ReposGroupModel().update(id_, form_data) | |
56 | return gr |
|
56 | return gr | |
57 |
|
57 | |||
58 | def test_create_group(self): |
|
58 | def test_create_group(self): | |
59 | g = self.__make_group('newGroup') |
|
59 | g = self.__make_group('newGroup') | |
60 | self.assertEqual(g.full_path, 'newGroup') |
|
60 | self.assertEqual(g.full_path, 'newGroup') | |
61 |
|
61 | |||
62 | self.assertTrue(self.__check_path('newGroup')) |
|
62 | self.assertTrue(self.__check_path('newGroup')) | |
63 |
|
63 | |||
64 |
|
64 | |||
65 | def test_create_same_name_group(self): |
|
65 | def test_create_same_name_group(self): | |
66 | self.assertRaises(IntegrityError, lambda:self.__make_group('newGroup')) |
|
66 | self.assertRaises(IntegrityError, lambda:self.__make_group('newGroup')) | |
67 |
|
67 | |||
68 |
|
68 | |||
69 | def test_same_subgroup(self): |
|
69 | def test_same_subgroup(self): | |
70 | sg1 = self.__make_group('sub1', parent_id=self.g1.group_id) |
|
70 | sg1 = self.__make_group('sub1', parent_id=self.g1.group_id) | |
71 | self.assertEqual(sg1.parent_group, self.g1) |
|
71 | self.assertEqual(sg1.parent_group, self.g1) | |
72 | self.assertEqual(sg1.full_path, 'test1/sub1') |
|
72 | self.assertEqual(sg1.full_path, 'test1/sub1') | |
73 | self.assertTrue(self.__check_path('test1', 'sub1')) |
|
73 | self.assertTrue(self.__check_path('test1', 'sub1')) | |
74 |
|
74 | |||
75 | ssg1 = self.__make_group('subsub1', parent_id=sg1.group_id) |
|
75 | ssg1 = self.__make_group('subsub1', parent_id=sg1.group_id) | |
76 | self.assertEqual(ssg1.parent_group, sg1) |
|
76 | self.assertEqual(ssg1.parent_group, sg1) | |
77 | self.assertEqual(ssg1.full_path, 'test1/sub1/subsub1') |
|
77 | self.assertEqual(ssg1.full_path, 'test1/sub1/subsub1') | |
78 | self.assertTrue(self.__check_path('test1', 'sub1', 'subsub1')) |
|
78 | self.assertTrue(self.__check_path('test1', 'sub1', 'subsub1')) | |
79 |
|
79 | |||
80 |
|
80 | |||
81 | def test_remove_group(self): |
|
81 | def test_remove_group(self): | |
82 | sg1 = self.__make_group('deleteme') |
|
82 | sg1 = self.__make_group('deleteme') | |
83 | self.__delete_group(sg1.group_id) |
|
83 | self.__delete_group(sg1.group_id) | |
84 |
|
84 | |||
85 | self.assertEqual(RepoGroup.get(sg1.group_id), None) |
|
85 | self.assertEqual(RepoGroup.get(sg1.group_id), None) | |
86 | self.assertFalse(self.__check_path('deteteme')) |
|
86 | self.assertFalse(self.__check_path('deteteme')) | |
87 |
|
87 | |||
88 | sg1 = self.__make_group('deleteme', parent_id=self.g1.group_id) |
|
88 | sg1 = self.__make_group('deleteme', parent_id=self.g1.group_id) | |
89 | self.__delete_group(sg1.group_id) |
|
89 | self.__delete_group(sg1.group_id) | |
90 |
|
90 | |||
91 | self.assertEqual(RepoGroup.get(sg1.group_id), None) |
|
91 | self.assertEqual(RepoGroup.get(sg1.group_id), None) | |
92 | self.assertFalse(self.__check_path('test1', 'deteteme')) |
|
92 | self.assertFalse(self.__check_path('test1', 'deteteme')) | |
93 |
|
93 | |||
94 |
|
94 | |||
95 | def test_rename_single_group(self): |
|
95 | def test_rename_single_group(self): | |
96 | sg1 = self.__make_group('initial') |
|
96 | sg1 = self.__make_group('initial') | |
97 |
|
97 | |||
98 | new_sg1 = self.__update_group(sg1.group_id, 'after') |
|
98 | new_sg1 = self.__update_group(sg1.group_id, 'after') | |
99 | self.assertTrue(self.__check_path('after')) |
|
99 | self.assertTrue(self.__check_path('after')) | |
100 | self.assertEqual(RepoGroup.get_by_group_name('initial'), None) |
|
100 | self.assertEqual(RepoGroup.get_by_group_name('initial'), None) | |
101 |
|
101 | |||
102 |
|
102 | |||
103 | def test_update_group_parent(self): |
|
103 | def test_update_group_parent(self): | |
104 |
|
104 | |||
105 | sg1 = self.__make_group('initial', parent_id=self.g1.group_id) |
|
105 | sg1 = self.__make_group('initial', parent_id=self.g1.group_id) | |
106 |
|
106 | |||
107 | new_sg1 = self.__update_group(sg1.group_id, 'after', parent_id=self.g1.group_id) |
|
107 | new_sg1 = self.__update_group(sg1.group_id, 'after', parent_id=self.g1.group_id) | |
108 | self.assertTrue(self.__check_path('test1', 'after')) |
|
108 | self.assertTrue(self.__check_path('test1', 'after')) | |
109 | self.assertEqual(RepoGroup.get_by_group_name('test1/initial'), None) |
|
109 | self.assertEqual(RepoGroup.get_by_group_name('test1/initial'), None) | |
110 |
|
110 | |||
111 |
|
111 | |||
112 | new_sg1 = self.__update_group(sg1.group_id, 'after', parent_id=self.g3.group_id) |
|
112 | new_sg1 = self.__update_group(sg1.group_id, 'after', parent_id=self.g3.group_id) | |
113 | self.assertTrue(self.__check_path('test3', 'after')) |
|
113 | self.assertTrue(self.__check_path('test3', 'after')) | |
114 | self.assertEqual(RepoGroup.get_by_group_name('test3/initial'), None) |
|
114 | self.assertEqual(RepoGroup.get_by_group_name('test3/initial'), None) | |
115 |
|
115 | |||
116 |
|
116 | |||
117 | new_sg1 = self.__update_group(sg1.group_id, 'hello') |
|
117 | new_sg1 = self.__update_group(sg1.group_id, 'hello') | |
118 | self.assertTrue(self.__check_path('hello')) |
|
118 | self.assertTrue(self.__check_path('hello')) | |
119 |
|
119 | |||
120 | self.assertEqual(RepoGroup.get_by_group_name('hello'), new_sg1) |
|
120 | self.assertEqual(RepoGroup.get_by_group_name('hello'), new_sg1) | |
121 |
|
121 | |||
122 |
|
122 | |||
123 |
|
123 | |||
124 | def test_subgrouping_with_repo(self): |
|
124 | def test_subgrouping_with_repo(self): | |
125 |
|
125 | |||
126 | g1 = self.__make_group('g1') |
|
126 | g1 = self.__make_group('g1') | |
127 | g2 = self.__make_group('g2') |
|
127 | g2 = self.__make_group('g2') | |
128 |
|
128 | |||
129 | # create new repo |
|
129 | # create new repo | |
130 | form_data = dict(repo_name='john', |
|
130 | form_data = dict(repo_name='john', | |
131 | repo_name_full='john', |
|
131 | repo_name_full='john', | |
132 | fork_name=None, |
|
132 | fork_name=None, | |
133 | description=None, |
|
133 | description=None, | |
134 | repo_group=None, |
|
134 | repo_group=None, | |
135 | private=False, |
|
135 | private=False, | |
136 | repo_type='hg', |
|
136 | repo_type='hg', | |
137 | clone_uri=None) |
|
137 | clone_uri=None) | |
138 | cur_user = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
138 | cur_user = User.get_by_username(TEST_USER_ADMIN_LOGIN) | |
139 | r = RepoModel().create(form_data, cur_user) |
|
139 | r = RepoModel().create(form_data, cur_user) | |
140 |
|
140 | |||
141 | self.assertEqual(r.repo_name, 'john') |
|
141 | self.assertEqual(r.repo_name, 'john') | |
142 |
|
142 | |||
143 | # put repo into group |
|
143 | # put repo into group | |
144 | form_data = form_data |
|
144 | form_data = form_data | |
145 | form_data['repo_group'] = g1.group_id |
|
145 | form_data['repo_group'] = g1.group_id | |
146 | form_data['perms_new'] = [] |
|
146 | form_data['perms_new'] = [] | |
147 | form_data['perms_updates'] = [] |
|
147 | form_data['perms_updates'] = [] | |
148 | RepoModel().update(r.repo_name, form_data) |
|
148 | RepoModel().update(r.repo_name, form_data) | |
149 | self.assertEqual(r.repo_name, 'g1/john') |
|
149 | self.assertEqual(r.repo_name, 'g1/john') | |
150 |
|
150 | |||
151 |
|
151 | |||
152 | self.__update_group(g1.group_id, 'g1', parent_id=g2.group_id) |
|
152 | self.__update_group(g1.group_id, 'g1', parent_id=g2.group_id) | |
153 | self.assertTrue(self.__check_path('g2', 'g1')) |
|
153 | self.assertTrue(self.__check_path('g2', 'g1')) | |
154 |
|
154 | |||
155 | # test repo |
|
155 | # test repo | |
156 | self.assertEqual(r.repo_name, os.path.join('g2', 'g1', r.just_name)) |
|
156 | self.assertEqual(r.repo_name, os.path.join('g2', 'g1', r.just_name)) | |
157 |
|
157 | |||
158 |
|
158 | |||
159 | class TestNotifications(unittest.TestCase): |
|
159 | class TestNotifications(unittest.TestCase): | |
160 |
|
160 | |||
161 |
|
161 | |||
162 |
|
162 | |||
163 | def setUp(self): |
|
163 | def setUp(self): | |
164 | self.u1 = UserModel().create_or_update(username='u1', password='qweqwe', |
|
164 | self.u1 = UserModel().create_or_update(username='u1', password='qweqwe', | |
165 | email='u1@rhodecode.org', |
|
165 | email='u1@rhodecode.org', | |
166 | name='u1', lastname='u1') |
|
166 | name='u1', lastname='u1') | |
167 | self.u2 = UserModel().create_or_update(username='u2', password='qweqwe', |
|
167 | self.u2 = UserModel().create_or_update(username='u2', password='qweqwe', | |
168 | email='u2@rhodecode.org', |
|
168 | email='u2@rhodecode.org', | |
169 | name='u2', lastname='u3') |
|
169 | name='u2', lastname='u3') | |
170 | self.u3 = UserModel().create_or_update(username='u3', password='qweqwe', |
|
170 | self.u3 = UserModel().create_or_update(username='u3', password='qweqwe', | |
171 | email='u3@rhodecode.org', |
|
171 | email='u3@rhodecode.org', | |
172 | name='u3', lastname='u3') |
|
172 | name='u3', lastname='u3') | |
173 |
|
173 | |||
174 |
|
174 | |||
175 |
|
175 | |||
176 | def test_create_notification(self): |
|
176 | def test_create_notification(self): | |
177 | usrs = [self.u1, self.u2] |
|
177 | usrs = [self.u1, self.u2] | |
178 |
notification = Notification.create( |
|
178 | notification = Notification.create(created_by=self.u1, | |
179 | recipients=usrs) |
|
179 | subject='subj', body='hi there', | |
|
180 | recipients=usrs) | |||
180 |
|
181 | |||
181 | notifications = Session.query(Notification).all() |
|
182 | notifications = Session.query(Notification).all() | |
182 | unotification = UserNotification.query()\ |
|
183 | unotification = UserNotification.query()\ | |
183 | .filter(UserNotification.notification == notification).all() |
|
184 | .filter(UserNotification.notification == notification).all() | |
184 | self.assertEqual(len(notifications), 1) |
|
185 | self.assertEqual(len(notifications), 1) | |
185 | self.assertEqual(notifications[0].recipients, [self.u1, self.u2]) |
|
186 | self.assertEqual(notifications[0].recipients, [self.u1, self.u2]) | |
186 |
self.assertEqual(notification, |
|
187 | self.assertEqual(notification.notification_id, | |
|
188 | notifications[0].notification_id) | |||
187 | self.assertEqual(len(unotification), len(usrs)) |
|
189 | self.assertEqual(len(unotification), len(usrs)) | |
188 | self.assertEqual([x.user.user_id for x in unotification], |
|
190 | self.assertEqual([x.user.user_id for x in unotification], | |
189 | [x.user_id for x in usrs]) |
|
191 | [x.user_id for x in usrs]) | |
190 |
|
192 | |||
191 | def test_user_notifications(self): |
|
193 | def test_user_notifications(self): | |
192 |
notification1 = Notification.create( |
|
194 | notification1 = Notification.create(created_by=self.u1, | |
193 | recipients=[self.u3]) |
|
195 | subject='subj', body='hi there', | |
194 | notification2 = Notification.create(subject='subj', body='hi there', |
|
196 | recipients=[self.u3]) | |
195 | recipients=[self.u3]) |
|
197 | notification2 = Notification.create(created_by=self.u1, | |
|
198 | subject='subj', body='hi there', | |||
|
199 | recipients=[self.u3]) | |||
196 | self.assertEqual(self.u3.notifications, [notification1, notification2]) |
|
200 | self.assertEqual(self.u3.notifications, [notification1, notification2]) | |
197 |
|
201 | |||
198 | def test_delete_notifications(self): |
|
202 | def test_delete_notifications(self): | |
199 |
notification = Notification.create( |
|
203 | notification = Notification.create(created_by=self.u1, | |
200 | recipients=[self.u3, self.u1, self.u2]) |
|
204 | subject='title', body='hi there3', | |
|
205 | recipients=[self.u3, self.u1, self.u2]) | |||
201 | notifications = Notification.query().all() |
|
206 | notifications = Notification.query().all() | |
202 | self.assertTrue(notification in notifications) |
|
207 | self.assertTrue(notification in notifications) | |
203 |
|
208 | |||
204 | Notification.delete(notification.notification_id) |
|
209 | Notification.delete(notification.notification_id) | |
205 |
|
210 | |||
206 | notifications = Notification.query().all() |
|
211 | notifications = Notification.query().all() | |
207 | self.assertFalse(notification in notifications) |
|
212 | self.assertFalse(notification in notifications) | |
208 |
|
213 | |||
209 | un = UserNotification.query().filter(UserNotification.notification |
|
214 | un = UserNotification.query().filter(UserNotification.notification | |
210 | == notification).all() |
|
215 | == notification).all() | |
211 | self.assertEqual(un, []) |
|
216 | self.assertEqual(un, []) | |
212 |
|
217 | |||
213 | def tearDown(self): |
|
218 | def tearDown(self): | |
214 | User.delete(self.u1.user_id) |
|
219 | User.delete(self.u1.user_id) | |
215 | User.delete(self.u2.user_id) |
|
220 | User.delete(self.u2.user_id) | |
216 | User.delete(self.u3.user_id) |
|
221 | User.delete(self.u3.user_id) |
General Comments 0
You need to be logged in to leave comments.
Login now