comparison rhodecode/tests/api/api_base.py @ 3502:7cde75eac0fe beta

get_locks API function draft
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 07 Mar 2013 20:06:45 +0100
parents 08e8115585bd
children 8a86836fad64
comparison
equal deleted inserted replaced
3501:3d5f4d2f0826 3502:7cde75eac0fe
369 expected = ('User `%s` set lock state for repo `%s` to `%s`' 369 expected = ('User `%s` set lock state for repo `%s` to `%s`'
370 % (TEST_USER_ADMIN_LOGIN, self.REPO, True)) 370 % (TEST_USER_ADMIN_LOGIN, self.REPO, True))
371 self._compare_ok(id_, expected, given=response.body) 371 self._compare_ok(id_, expected, given=response.body)
372 372
373 def test_api_lock_repo_lock_optional_locked(self): 373 def test_api_lock_repo_lock_optional_locked(self):
374 from rhodecode.lib import helpers
375 from rhodecode.lib.utils2 import time_to_datetime 374 from rhodecode.lib.utils2 import time_to_datetime
376 _locked_since = helpers.fmt_date(time_to_datetime(Repository\ 375 _locked_since = json.dumps(time_to_datetime(Repository\
377 .get_by_repo_name(self.REPO).locked[1])) 376 .get_by_repo_name(self.REPO).locked[1]))
378 id_, params = _build_data(self.apikey, 'lock', 377 id_, params = _build_data(self.apikey, 'lock',
379 repoid=self.REPO) 378 repoid=self.REPO)
380 response = api_call(self, params) 379 response = api_call(self, params)
381 expected = ('Repo `%s` locked by `%s`. Locked=`True`. Locked since: `%s`' 380 expected = ('Repo `%s` locked by `%s`. Locked=`True`. Locked since: `%s`'
390 locked=True) 389 locked=True)
391 response = api_call(self, params) 390 response = api_call(self, params)
392 391
393 expected = 'Error occurred locking repository `%s`' % self.REPO 392 expected = 'Error occurred locking repository `%s`' % self.REPO
394 self._compare_error(id_, expected, given=response.body) 393 self._compare_error(id_, expected, given=response.body)
394
395 def test_api_get_locks_regular_user(self):
396 id_, params = _build_data(self.apikey_regular, 'get_locks')
397 response = api_call(self, params)
398 expected = []
399 self._compare_ok(id_, expected, given=response.body)
400
401 def test_api_get_locks_with_userid_regular_user(self):
402 id_, params = _build_data(self.apikey_regular, 'get_locks',
403 userid=TEST_USER_ADMIN_LOGIN)
404 response = api_call(self, params)
405 expected = 'userid is not the same as your user'
406 self._compare_error(id_, expected, given=response.body)
407
408 def test_api_get_locks(self):
409 id_, params = _build_data(self.apikey, 'get_locks')
410 response = api_call(self, params)
411 expected = []
412 self._compare_ok(id_, expected, given=response.body)
413
414 def test_api_get_locks_with_userid(self):
415 id_, params = _build_data(self.apikey, 'get_locks',
416 userid=TEST_USER_REGULAR_LOGIN)
417 response = api_call(self, params)
418 expected = []
419 self._compare_ok(id_, expected, given=response.body)
395 420
396 def test_api_create_existing_user(self): 421 def test_api_create_existing_user(self):
397 id_, params = _build_data(self.apikey, 'create_user', 422 id_, params = _build_data(self.apikey, 'create_user',
398 username=TEST_USER_ADMIN_LOGIN, 423 username=TEST_USER_ADMIN_LOGIN,
399 email='test@foo.com', 424 email='test@foo.com',