Mercurial > kallithea
annotate rhodecode/tests/functional/test_admin_gists.py @ 4186:7e5f8c12a3fc kallithea-2.2.5-rebrand
First step in two-part process to rename directories to kallithea.
This first step is to change all references in the files where they refer
to the old directory name.
author | Bradley M. Kuhn <bkuhn@sfconservancy.org> |
---|---|
date | Wed, 02 Jul 2014 19:04:28 -0400 |
parents | ffd45b185016 |
children |
rev | line source |
---|---|
3844
ec64c396da8c
added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents:
3843
diff
changeset
|
1 import datetime |
ec64c396da8c
added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents:
3843
diff
changeset
|
2 |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
3 from kallithea.tests import * |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
4 from kallithea.model.gist import GistModel |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
5 from kallithea.model.meta import Session |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
6 from kallithea.model.db import User, Gist |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 def _create_gist(f_name, content='some gist', lifetime=-1, |
3843
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
10 description='gist-desc', gist_type='public', |
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
11 owner=TEST_USER_ADMIN_LOGIN): |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 gist_mapping = { |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 f_name: {'content': content} |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 } |
3843
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
15 user = User.get_by_username(owner) |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 gist = GistModel().create(description, owner=user, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 gist_mapping=gist_mapping, gist_type=gist_type, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 lifetime=lifetime) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 Session().commit() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 return gist |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 class TestGistsController(TestController): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 def tearDown(self): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 for g in Gist.get_all(): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 GistModel().delete(g) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 Session().commit() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 def test_index(self): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 self.log_user() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 response = self.app.get(url('gists')) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 # Test response... |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 response.mustcontain('There are no gists yet') |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 |
3849
b4fc29a051ae
small tests improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
3846
diff
changeset
|
36 g1 = _create_gist('gist1').gist_access_id |
b4fc29a051ae
small tests improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
3846
diff
changeset
|
37 g2 = _create_gist('gist2', lifetime=1400).gist_access_id |
b4fc29a051ae
small tests improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
3846
diff
changeset
|
38 g3 = _create_gist('gist3', description='gist3-desc').gist_access_id |
b4fc29a051ae
small tests improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
3846
diff
changeset
|
39 g4 = _create_gist('gist4', gist_type='private').gist_access_id |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 response = self.app.get(url('gists')) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 # Test response... |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3873
diff
changeset
|
42 response.mustcontain('gist: %s' % g1) |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3873
diff
changeset
|
43 response.mustcontain('gist: %s' % g2) |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 response.mustcontain('Expires: in 23 hours') # we don't care about the end |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3873
diff
changeset
|
45 response.mustcontain('gist: %s' % g3) |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 response.mustcontain('gist3-desc') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3873
diff
changeset
|
47 response.mustcontain(no=['gist: %s' % g4]) |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 def test_index_private_gists(self): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 self.log_user() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 gist = _create_gist('gist5', gist_type='private') |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 response = self.app.get(url('gists', private=1)) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 # Test response... |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 #and privates |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3873
diff
changeset
|
56 response.mustcontain('gist: %s' % gist.gist_access_id) |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 def test_create_missing_description(self): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 self.log_user() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 response = self.app.post(url('gists'), |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 params={'lifetime': -1}, status=200) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 response.mustcontain('Missing value') |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 def test_create(self): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 self.log_user() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 response = self.app.post(url('gists'), |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 params={'lifetime': -1, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 'content': 'gist test', |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
70 'filename': 'foo', |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 'public': 'public'}, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 status=302) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 response = response.follow() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 response.mustcontain('added file: foo') |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 response.mustcontain('gist test') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3873
diff
changeset
|
76 response.mustcontain('<div class="btn btn-mini btn-success disabled">Public Gist</div>') |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
77 |
3846
2576a20d94ca
Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3844
diff
changeset
|
78 def test_create_with_path_with_dirs(self): |
2576a20d94ca
Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3844
diff
changeset
|
79 self.log_user() |
2576a20d94ca
Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3844
diff
changeset
|
80 response = self.app.post(url('gists'), |
2576a20d94ca
Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3844
diff
changeset
|
81 params={'lifetime': -1, |
2576a20d94ca
Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3844
diff
changeset
|
82 'content': 'gist test', |
2576a20d94ca
Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3844
diff
changeset
|
83 'filename': '/home/foo', |
2576a20d94ca
Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3844
diff
changeset
|
84 'public': 'public'}, |
2576a20d94ca
Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3844
diff
changeset
|
85 status=200) |
2576a20d94ca
Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3844
diff
changeset
|
86 response.mustcontain('Filename cannot be inside a directory') |
2576a20d94ca
Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3844
diff
changeset
|
87 |
3844
ec64c396da8c
added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents:
3843
diff
changeset
|
88 def test_access_expired_gist(self): |
ec64c396da8c
added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents:
3843
diff
changeset
|
89 self.log_user() |
ec64c396da8c
added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents:
3843
diff
changeset
|
90 gist = _create_gist('never-see-me') |
ec64c396da8c
added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents:
3843
diff
changeset
|
91 gist.gist_expires = 0 # 1970 |
ec64c396da8c
added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents:
3843
diff
changeset
|
92 Session().add(gist) |
ec64c396da8c
added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents:
3843
diff
changeset
|
93 Session().commit() |
ec64c396da8c
added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents:
3843
diff
changeset
|
94 |
3866
1fdec7e3aeb2
refactored url.resource to full definition of routes
Marcin Kuzminski <marcin@python-works.com>
parents:
3849
diff
changeset
|
95 response = self.app.get(url('gist', gist_id=gist.gist_access_id), status=404) |
3844
ec64c396da8c
added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents:
3843
diff
changeset
|
96 |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 def test_create_private(self): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
98 self.log_user() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 response = self.app.post(url('gists'), |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 params={'lifetime': -1, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 'content': 'private gist test', |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 'filename': 'private-foo', |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
103 'private': 'private'}, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
104 status=302) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
105 response = response.follow() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
106 response.mustcontain('added file: private-foo<') |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
107 response.mustcontain('private gist test') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3873
diff
changeset
|
108 response.mustcontain('<div class="btn btn-mini btn-warning disabled">Private Gist</div>') |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
109 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
110 def test_create_with_description(self): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
111 self.log_user() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
112 response = self.app.post(url('gists'), |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
113 params={'lifetime': -1, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
114 'content': 'gist test', |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
115 'filename': 'foo-desc', |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
116 'description': 'gist-desc', |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
117 'public': 'public'}, |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
118 status=302) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
119 response = response.follow() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
120 response.mustcontain('added file: foo-desc') |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
121 response.mustcontain('gist test') |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
122 response.mustcontain('gist-desc') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3873
diff
changeset
|
123 response.mustcontain('<div class="btn btn-mini btn-success disabled">Public Gist</div>') |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
124 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
125 def test_new(self): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
126 self.log_user() |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
127 response = self.app.get(url('new_gist')) |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
128 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
129 def test_update(self): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
130 self.skipTest('not implemented') |
3866
1fdec7e3aeb2
refactored url.resource to full definition of routes
Marcin Kuzminski <marcin@python-works.com>
parents:
3849
diff
changeset
|
131 response = self.app.put(url('gist', gist_id=1)) |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
132 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
133 def test_delete(self): |
3843
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
134 self.log_user() |
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
135 gist = _create_gist('delete-me') |
3866
1fdec7e3aeb2
refactored url.resource to full definition of routes
Marcin Kuzminski <marcin@python-works.com>
parents:
3849
diff
changeset
|
136 response = self.app.delete(url('gist', gist_id=gist.gist_id)) |
3843
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
137 self.checkSessionFlash(response, 'Deleted gist %s' % gist.gist_id) |
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
138 |
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
139 def test_delete_normal_user_his_gist(self): |
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
140 self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
141 gist = _create_gist('delete-me', owner=TEST_USER_REGULAR_LOGIN) |
3866
1fdec7e3aeb2
refactored url.resource to full definition of routes
Marcin Kuzminski <marcin@python-works.com>
parents:
3849
diff
changeset
|
142 response = self.app.delete(url('gist', gist_id=gist.gist_id)) |
3843
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
143 self.checkSessionFlash(response, 'Deleted gist %s' % gist.gist_id) |
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
144 |
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
145 def test_delete_normal_user_not_his_own_gist(self): |
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
146 self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
ad4a680113b7
Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents:
3842
diff
changeset
|
147 gist = _create_gist('delete-me') |
3866
1fdec7e3aeb2
refactored url.resource to full definition of routes
Marcin Kuzminski <marcin@python-works.com>
parents:
3849
diff
changeset
|
148 response = self.app.delete(url('gist', gist_id=gist.gist_id), status=403) |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
149 |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
150 def test_show(self): |
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
151 gist = _create_gist('gist-show-me') |
3866
1fdec7e3aeb2
refactored url.resource to full definition of routes
Marcin Kuzminski <marcin@python-works.com>
parents:
3849
diff
changeset
|
152 response = self.app.get(url('gist', gist_id=gist.gist_access_id)) |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
153 response.mustcontain('added file: gist-show-me<') |
3842
54bc7a89f090
gists: add some API related code improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
154 response.mustcontain('test_admin (RhodeCode Admin) - created') |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
155 response.mustcontain('gist-desc') |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3873
diff
changeset
|
156 response.mustcontain('<div class="btn btn-mini btn-success disabled">Public Gist</div>') |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
157 |
3873
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
158 def test_show_as_raw(self): |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
159 gist = _create_gist('gist-show-me', content='GIST CONTENT') |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
160 response = self.app.get(url('formatted_gist', |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
161 gist_id=gist.gist_access_id, format='raw')) |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
162 self.assertEqual(response.body, 'GIST CONTENT') |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
163 |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
164 def test_show_as_raw_individual_file(self): |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
165 gist = _create_gist('gist-show-me-raw', content='GIST BODY') |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
166 response = self.app.get(url('formatted_gist_file', |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
167 gist_id=gist.gist_access_id, format='raw', |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
168 revision='tip', f_path='gist-show-me-raw')) |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
169 self.assertEqual(response.body, 'GIST BODY') |
4b0d283ecede
added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents:
3866
diff
changeset
|
170 |
3840
dc4644865e8b
Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
171 def test_edit(self): |
3866
1fdec7e3aeb2
refactored url.resource to full definition of routes
Marcin Kuzminski <marcin@python-works.com>
parents:
3849
diff
changeset
|
172 response = self.app.get(url('edit_gist', gist_id=1)) |