annotate kallithea/tests/functional/test_admin_gists.py @ 6864:7691290837d2

codingstyle: trivial whitespace fixes Reported by flake8.
author Lars Kruse <devel@sumpfralle.de>
date Fri, 25 Aug 2017 14:32:50 +0200
parents 7bbe7dfaa48b
children 16df4993b442
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6217
8d98924c58b1 tests: add as little code as possible in __init__.py
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 6084
diff changeset
1 from kallithea.tests.base import *
4186
7e5f8c12a3fc First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents: 4116
diff changeset
2 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
3 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
4 from kallithea.model.db import User, Gist
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 def _create_gist(f_name, content='some gist', lifetime=-1,
4731
c154dc461bd5 tests: fix some test sqlalchemy unicode warnings
Mads Kiilerich <madski@unity3d.com>
parents: 4422
diff changeset
8 description=u'gist-desc', gist_type='public',
3843
ad4a680113b7 Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents: 3842
diff changeset
9 owner=TEST_USER_ADMIN_LOGIN):
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 gist_mapping = {
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 f_name: {'content': content}
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 }
6230
cd6176c0634a db: PullRequest/Repository/RepoGroup/UserGroup: change 'user' to 'owner'
Søren Løvborg <sorenl@unity3d.com>
parents: 6229
diff changeset
13 owner = User.get_by_username(owner)
cd6176c0634a db: PullRequest/Repository/RepoGroup/UserGroup: change 'user' to 'owner'
Søren Løvborg <sorenl@unity3d.com>
parents: 6229
diff changeset
14 gist = GistModel().create(description, owner=owner,
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 gist_mapping=gist_mapping, gist_type=gist_type,
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 lifetime=lifetime)
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 Session().commit()
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 return gist
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20
5922
7f2aa3ec2931 pytest migration: rename TestControllerPytest back to TestController
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5914
diff changeset
21 class TestGistsController(TestController):
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22
5801
15c40f8a3510 pytest migration: convert functional tests with setup/teardown methods
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5698
diff changeset
23 def teardown_method(self, method):
6220
7bffccee3a49 db: inline calls to get_all
Søren Løvborg <sorenl@unity3d.com>
parents: 6217
diff changeset
24 for g in Gist.query():
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 GistModel().delete(g)
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 Session().commit()
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 def test_index(self):
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 self.log_user()
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 response = self.app.get(url('gists'))
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 # Test response...
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 response.mustcontain('There are no gists yet')
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33
3849
b4fc29a051ae small tests improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 3846
diff changeset
34 g1 = _create_gist('gist1').gist_access_id
b4fc29a051ae small tests improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 3846
diff changeset
35 g2 = _create_gist('gist2', lifetime=1400).gist_access_id
4731
c154dc461bd5 tests: fix some test sqlalchemy unicode warnings
Mads Kiilerich <madski@unity3d.com>
parents: 4422
diff changeset
36 g3 = _create_gist('gist3', description=u'gist3-desc').gist_access_id
3849
b4fc29a051ae small tests improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 3846
diff changeset
37 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
38 response = self.app.get(url('gists'))
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 # 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
40 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
41 response.mustcontain('gist: %s' % g2)
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 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
43 response.mustcontain('gist: %s' % g3)
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 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
45 response.mustcontain(no=['gist: %s' % g4])
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 def test_index_private_gists(self):
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 self.log_user()
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 gist = _create_gist('gist5', gist_type='private')
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 response = self.app.get(url('gists', private=1))
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 # Test response...
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52
6864
7691290837d2 codingstyle: trivial whitespace fixes
Lars Kruse <devel@sumpfralle.de>
parents: 6285
diff changeset
53 # 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
54 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
55
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 def test_create_missing_description(self):
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 self.log_user()
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 response = self.app.post(url('gists'),
4993
0efca3ad8467 tests: provide _authentication_token when POSTing
Mads Kiilerich <madski@unity3d.com>
parents: 4731
diff changeset
59 params={'lifetime': -1, '_authentication_token': self.authentication_token()},
0efca3ad8467 tests: provide _authentication_token when POSTing
Mads Kiilerich <madski@unity3d.com>
parents: 4731
diff changeset
60 status=200)
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 response.mustcontain('Missing value')
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 def test_create(self):
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 self.log_user()
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 response = self.app.post(url('gists'),
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 params={'lifetime': -1,
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 'content': 'gist test',
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 'filename': 'foo',
4993
0efca3ad8467 tests: provide _authentication_token when POSTing
Mads Kiilerich <madski@unity3d.com>
parents: 4731
diff changeset
70 'public': 'public',
0efca3ad8467 tests: provide _authentication_token when POSTing
Mads Kiilerich <madski@unity3d.com>
parents: 4731
diff changeset
71 '_authentication_token': self.authentication_token()},
3840
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')
6285
7bbe7dfaa48b style: replace some disabled btn with Bootstrap compatible label markup
Mads Kiilerich <madski@unity3d.com>
parents: 6258
diff changeset
76 response.mustcontain('<div class="label label-success">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',
4993
0efca3ad8467 tests: provide _authentication_token when POSTing
Mads Kiilerich <madski@unity3d.com>
parents: 4731
diff changeset
84 'public': 'public',
0efca3ad8467 tests: provide _authentication_token when POSTing
Mads Kiilerich <madski@unity3d.com>
parents: 4731
diff changeset
85 '_authentication_token': self.authentication_token()},
3846
2576a20d94ca Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3844
diff changeset
86 status=200)
2576a20d94ca Gist: don't allow files inside directories when creating gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3844
diff changeset
87 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
88
3844
ec64c396da8c added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents: 3843
diff changeset
89 def test_access_expired_gist(self):
ec64c396da8c added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents: 3843
diff changeset
90 self.log_user()
ec64c396da8c added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents: 3843
diff changeset
91 gist = _create_gist('never-see-me')
ec64c396da8c added tests for gist expiration
Marcin Kuzminski <marcin@python-works.com>
parents: 3843
diff changeset
92 gist.gist_expires = 0 # 1970
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',
4993
0efca3ad8467 tests: provide _authentication_token when POSTing
Mads Kiilerich <madski@unity3d.com>
parents: 4731
diff changeset
103 'private': 'private',
0efca3ad8467 tests: provide _authentication_token when POSTing
Mads Kiilerich <madski@unity3d.com>
parents: 4731
diff changeset
104 '_authentication_token': self.authentication_token()},
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
105 status=302)
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
106 response = response.follow()
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
107 response.mustcontain('added file: private-foo<')
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
108 response.mustcontain('private gist test')
6285
7bbe7dfaa48b style: replace some disabled btn with Bootstrap compatible label markup
Mads Kiilerich <madski@unity3d.com>
parents: 6258
diff changeset
109 response.mustcontain('<div class="label label-warning">Private Gist</div>')
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
110
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
111 def test_create_with_description(self):
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
112 self.log_user()
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113 response = self.app.post(url('gists'),
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
114 params={'lifetime': -1,
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
115 'content': 'gist test',
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
116 'filename': 'foo-desc',
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117 'description': 'gist-desc',
4993
0efca3ad8467 tests: provide _authentication_token when POSTing
Mads Kiilerich <madski@unity3d.com>
parents: 4731
diff changeset
118 'public': 'public',
0efca3ad8467 tests: provide _authentication_token when POSTing
Mads Kiilerich <madski@unity3d.com>
parents: 4731
diff changeset
119 '_authentication_token': self.authentication_token()},
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
120 status=302)
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
121 response = response.follow()
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
122 response.mustcontain('added file: foo-desc')
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
123 response.mustcontain('gist test')
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
124 response.mustcontain('gist-desc')
6285
7bbe7dfaa48b style: replace some disabled btn with Bootstrap compatible label markup
Mads Kiilerich <madski@unity3d.com>
parents: 6258
diff changeset
125 response.mustcontain('<div class="label label-success">Public Gist</div>')
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
126
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
127 def test_new(self):
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
128 self.log_user()
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
129 response = self.app.get(url('new_gist'))
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
130
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131 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
132 self.log_user()
ad4a680113b7 Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents: 3842
diff changeset
133 gist = _create_gist('delete-me')
6084
74f880bfcb7b routing: introduce 'gist_delete' url and use POST instead of DELETE
Mads Kiilerich <madski@unity3d.com>
parents: 6071
diff changeset
134 response = self.app.post(url('gist_delete', gist_id=gist.gist_id),
74f880bfcb7b routing: introduce 'gist_delete' url and use POST instead of DELETE
Mads Kiilerich <madski@unity3d.com>
parents: 6071
diff changeset
135 params={'_authentication_token': self.authentication_token()})
3843
ad4a680113b7 Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents: 3842
diff changeset
136
ad4a680113b7 Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents: 3842
diff changeset
137 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
138 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
139 gist = _create_gist('delete-me', owner=TEST_USER_REGULAR_LOGIN)
6084
74f880bfcb7b routing: introduce 'gist_delete' url and use POST instead of DELETE
Mads Kiilerich <madski@unity3d.com>
parents: 6071
diff changeset
140 response = self.app.post(url('gist_delete', gist_id=gist.gist_id),
74f880bfcb7b routing: introduce 'gist_delete' url and use POST instead of DELETE
Mads Kiilerich <madski@unity3d.com>
parents: 6071
diff changeset
141 params={'_authentication_token': self.authentication_token()})
3843
ad4a680113b7 Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents: 3842
diff changeset
142
ad4a680113b7 Gist: implemented delete of gists by owner, or super admin
Marcin Kuzminski <marcin@python-works.com>
parents: 3842
diff changeset
143 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
144 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
145 gist = _create_gist('delete-me')
6084
74f880bfcb7b routing: introduce 'gist_delete' url and use POST instead of DELETE
Mads Kiilerich <madski@unity3d.com>
parents: 6071
diff changeset
146 response = self.app.post(url('gist_delete', gist_id=gist.gist_id), status=403,
74f880bfcb7b routing: introduce 'gist_delete' url and use POST instead of DELETE
Mads Kiilerich <madski@unity3d.com>
parents: 6071
diff changeset
147 params={'_authentication_token': self.authentication_token()})
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
148
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
149 def test_show(self):
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
150 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
151 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
152 response.mustcontain('added file: gist-show-me<')
5203
29d0ed59e674 tests: remove hardcoded test_admin username
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 4993
diff changeset
153 response.mustcontain('%s - created' % TEST_USER_ADMIN_LOGIN)
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
154 response.mustcontain('gist-desc')
6285
7bbe7dfaa48b style: replace some disabled btn with Bootstrap compatible label markup
Mads Kiilerich <madski@unity3d.com>
parents: 6258
diff changeset
155 response.mustcontain('<div class="label label-success">Public Gist</div>')
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
156
3873
4b0d283ecede added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3866
diff changeset
157 def test_show_as_raw(self):
4b0d283ecede added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3866
diff changeset
158 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
159 response = self.app.get(url('formatted_gist',
4b0d283ecede added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3866
diff changeset
160 gist_id=gist.gist_access_id, format='raw'))
5914
be1d366f461c pytest migration: functional: switch to standard assert statements
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5801
diff changeset
161 assert response.body == 'GIST CONTENT'
3873
4b0d283ecede added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3866
diff changeset
162
4b0d283ecede added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3866
diff changeset
163 def test_show_as_raw_individual_file(self):
4b0d283ecede added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3866
diff changeset
164 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
165 response = self.app.get(url('formatted_gist_file',
4b0d283ecede added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3866
diff changeset
166 gist_id=gist.gist_access_id, format='raw',
4b0d283ecede added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3866
diff changeset
167 revision='tip', f_path='gist-show-me-raw'))
5914
be1d366f461c pytest migration: functional: switch to standard assert statements
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents: 5801
diff changeset
168 assert response.body == 'GIST BODY'
3873
4b0d283ecede added tests for raw gists
Marcin Kuzminski <marcin@python-works.com>
parents: 3866
diff changeset
169
3840
dc4644865e8b Implemented simple gist functionality ref #530.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
170 def test_edit(self):
3866
1fdec7e3aeb2 refactored url.resource to full definition of routes
Marcin Kuzminski <marcin@python-works.com>
parents: 3849
diff changeset
171 response = self.app.get(url('edit_gist', gist_id=1))