Mercurial > kallithea
annotate rhodecode/tests/functional/test_settings.py @ 3565:a8f2d78d14ea beta
consistently capitalize initial letter in flash messages
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 20 Mar 2013 12:16:58 +0100 |
parents | 8b8edfc25856 |
children |
rev | line source |
---|---|
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
535
diff
changeset
|
1 from rhodecode.tests import * |
3219
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
2 from rhodecode.model.db import UserRepoToPerm, Repository, User, Permission |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
3 from rhodecode.model.meta import Session |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
4 |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
5 |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
6 def _get_permission_for_user(user, repo): |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
7 perm = UserRepoToPerm.query()\ |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
8 .filter(UserRepoToPerm.repository == |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
9 Repository.get_by_repo_name(repo))\ |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
10 .filter(UserRepoToPerm.user == User.get_by_username(user))\ |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
11 .all() |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
12 return perm |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
13 |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 class TestSettingsController(TestController): |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 def test_index(self): |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
18 self.log_user() |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
19 response = self.app.get(url(controller='settings', action='index', |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
20 repo_name=HG_REPO)) |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # Test response... |
3219
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
22 |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
23 def test_set_private_flag_sets_default_to_none(self): |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
24 self.log_user() |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
25 #initially repository perm should be read |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
26 perm = _get_permission_for_user(user='default', repo=HG_REPO) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
27 self.assertTrue(len(perm), 1) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
28 self.assertEqual(perm[0].permission.permission_name, 'repository.read') |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
29 self.assertEqual(Repository.get_by_repo_name(HG_REPO).private, False) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
30 |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
31 response = self.app.put(url('repo', repo_name=HG_REPO), |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
32 _get_repo_create_params(repo_private=1, |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
33 repo_name=HG_REPO, |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
34 user=TEST_USER_ADMIN_LOGIN)) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
35 self.checkSessionFlash(response, |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
36 msg='Repository %s updated successfully' % (HG_REPO)) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
37 self.assertEqual(Repository.get_by_repo_name(HG_REPO).private, True) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
38 |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
39 #now the repo default permission should be None |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
40 perm = _get_permission_for_user(user='default', repo=HG_REPO) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
41 self.assertTrue(len(perm), 1) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
42 self.assertEqual(perm[0].permission.permission_name, 'repository.none') |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
43 |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
44 response = self.app.put(url('repo', repo_name=HG_REPO), |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
45 _get_repo_create_params(repo_private=False, |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
46 repo_name=HG_REPO, |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
47 user=TEST_USER_ADMIN_LOGIN)) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
48 self.checkSessionFlash(response, |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
49 msg='Repository %s updated successfully' % (HG_REPO)) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
50 self.assertEqual(Repository.get_by_repo_name(HG_REPO).private, False) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
51 |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
52 #we turn off private now the repo default permission should stay None |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
53 perm = _get_permission_for_user(user='default', repo=HG_REPO) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
54 self.assertTrue(len(perm), 1) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
55 self.assertEqual(perm[0].permission.permission_name, 'repository.none') |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
56 |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
57 #update this permission back |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
58 perm[0].permission = Permission.get_by_key('repository.read') |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
59 Session().add(perm[0]) |
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
60 Session().commit() |