aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/tests/api
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2012-08-25 19:00:59 +0200
committerMarcin Kuzminski <marcin@python-works.com>2012-08-25 19:00:59 +0200
commit1890086eb6c2e06fc2a440d4b25a0ff9d1561104 (patch)
treebe6942bcce2fc02c88102ddc9eb8f41ec88bc4ee /rhodecode/tests/api
parent43e77e50754c4981097d4fcced2a295b0eb5180f (diff)
added API call for locking/unlocking repositories
--HG-- branch : beta
Diffstat (limited to 'rhodecode/tests/api')
-rw-r--r--rhodecode/tests/api/api_base.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/rhodecode/tests/api/api_base.py b/rhodecode/tests/api/api_base.py
index 4888019d..d8ab9a4d 100644
--- a/rhodecode/tests/api/api_base.py
+++ b/rhodecode/tests/api/api_base.py
@@ -10,6 +10,7 @@ from rhodecode.model.users_group import UsersGroupModel
from rhodecode.model.repo import RepoModel
from rhodecode.model.meta import Session
from rhodecode.model.scm import ScmModel
+from rhodecode.model.db import Repository
API_URL = '/_admin/api'
@@ -230,7 +231,41 @@ class BaseTestApi(object):
response = self.app.post(API_URL, content_type='application/json',
params=params)
- expected = 'Unable to rescan repositories'
+ expected = 'Error occurred during rescan repositories action'
+ self._compare_error(id_, expected, given=response.body)
+
+ def test_api_lock_repo_lock_aquire(self):
+ id_, params = _build_data(self.apikey, 'lock',
+ userid=TEST_USER_ADMIN_LOGIN,
+ repoid=self.REPO,
+ locked=True)
+ response = self.app.post(API_URL, content_type='application/json',
+ params=params)
+ expected = ('User `%s` set lock state for repo `%s` to `%s`'
+ % (TEST_USER_ADMIN_LOGIN, self.REPO, True))
+ self._compare_ok(id_, expected, given=response.body)
+
+ def test_api_lock_repo_lock_release(self):
+ id_, params = _build_data(self.apikey, 'lock',
+ userid=TEST_USER_ADMIN_LOGIN,
+ repoid=self.REPO,
+ locked=False)
+ response = self.app.post(API_URL, content_type='application/json',
+ params=params)
+ expected = ('User `%s` set lock state for repo `%s` to `%s`'
+ % (TEST_USER_ADMIN_LOGIN, self.REPO, False))
+ self._compare_ok(id_, expected, given=response.body)
+
+ @mock.patch.object(Repository, 'lock', crash)
+ def test_api_lock_error(self):
+ id_, params = _build_data(self.apikey, 'lock',
+ userid=TEST_USER_ADMIN_LOGIN,
+ repoid=self.REPO,
+ locked=True)
+ response = self.app.post(API_URL, content_type='application/json',
+ params=params)
+
+ expected = 'Error occurred locking repository `%s`' % self.REPO
self._compare_error(id_, expected, given=response.body)
def test_api_create_existing_user(self):