##// END OF EJS Templates
fixes problem with basic auth and pushes
fixes problem with basic auth and pushes

File last commit:

r1398:6dee4345 beta
r1534:72c3cea0 beta
Show More
test_admin_repos.py
213 lines | 7.7 KiB | text/x-python | PythonLexer
added test for non ascii repositories and fixed users_groups test
r1398 # -*- coding: utf-8 -*-
added repo creation filesystem test
r1037 import os
import vcs
Refactor codes for scm model...
r691 from rhodecode.model.db import Repository
from rhodecode.tests import *
class TestAdminReposController(TestController):
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366
def __make_repo(self):
pass
Refactor codes for scm model...
r691 def test_index(self):
self.log_user()
response = self.app.get(url('repos'))
# Test response...
def test_index_as_xml(self):
response = self.app.get(url('formatted_repos', format='xml'))
def test_create_hg(self):
self.log_user()
repo_name = NEW_HG_REPO
description = 'description for newly created repo'
private = False
response = self.app.post(url('repos'), {'repo_name':repo_name,
'repo_type':'hg',
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 'clone_uri':'',
'repo_group':'',
Refactor codes for scm model...
r691 'description':description,
'private':private})
added test for non ascii repositories and fixed users_groups test
r1398 self.checkSessionFlash(response, 'created repository %s' % (repo_name))
Refactor codes for scm model...
r691
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 #test if the repo was created in the database
new_repo = self.sa.query(Repository).filter(Repository.repo_name ==
repo_name).one()
Refactor codes for scm model...
r691
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 self.assertEqual(new_repo.repo_name, repo_name)
self.assertEqual(new_repo.description, description)
Refactor codes for scm model...
r691
#test if repository is visible in the list ?
response = response.follow()
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 self.assertTrue(repo_name in response.body)
Refactor codes for scm model...
r691
added repo creation filesystem test
r1037
#test if repository was created on filesystem
try:
vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
except:
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 self.fail('no repo in filesystem')
added repo creation filesystem test
r1037
added test for non ascii repositories and fixed users_groups test
r1398 def test_create_hg_non_ascii(self):
self.log_user()
non_ascii = "ąęł"
repo_name = "%s%s" % (NEW_HG_REPO, non_ascii)
repo_name_unicode = repo_name.decode('utf8')
description = 'description for newly created repo' + non_ascii
description_unicode = description.decode('utf8')
private = False
response = self.app.post(url('repos'), {'repo_name':repo_name,
'repo_type':'hg',
'clone_uri':'',
'repo_group':'',
'description':description,
'private':private})
self.checkSessionFlash(response,
'created repository %s' % (repo_name_unicode))
#test if the repo was created in the database
new_repo = self.sa.query(Repository).filter(Repository.repo_name ==
repo_name_unicode).one()
self.assertEqual(new_repo.repo_name, repo_name_unicode)
self.assertEqual(new_repo.description, description_unicode)
#test if repository is visible in the list ?
response = response.follow()
self.assertTrue(repo_name in response.body)
#test if repository was created on filesystem
try:
vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
except:
self.fail('no repo in filesystem')
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 def test_create_hg_in_group(self):
#TODO: write test !
pass
added repo creation filesystem test
r1037
Refactor codes for scm model...
r691 def test_create_git(self):
fixed bug in forms found due to testing,...
r728 return
Refactor codes for scm model...
r691 self.log_user()
repo_name = NEW_GIT_REPO
description = 'description for newly created repo'
private = False
response = self.app.post(url('repos'), {'repo_name':repo_name,
'repo_type':'git',
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 'clone_uri':'',
'repo_group':'',
Refactor codes for scm model...
r691 'description':description,
'private':private})
#test if we have a message for that repository
assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
#test if the fork was created in the database
new_repo = self.sa.query(Repository).filter(Repository.repo_name == repo_name).one()
assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
assert new_repo.description == description, 'wrong description'
#test if repository is visible in the list ?
response = response.follow()
assert repo_name in response.body, 'missing new repo from the main repos list'
added repo creation filesystem test
r1037 #test if repository was created on filesystem
try:
vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
except:
assert False , 'no repo in filesystem'
Refactor codes for scm model...
r691
def test_new(self):
self.log_user()
response = self.app.get(url('new_repo'))
def test_new_as_xml(self):
response = self.app.get(url('formatted_new_repo', format='xml'))
def test_update(self):
response = self.app.put(url('repo', repo_name=HG_REPO))
def test_update_browser_fakeout(self):
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 response = self.app.post(url('repo', repo_name=HG_REPO),
params=dict(_method='put'))
Refactor codes for scm model...
r691
def test_delete(self):
self.log_user()
repo_name = 'vcs_test_new_to_delete'
description = 'description for newly created repo'
private = False
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366
Refactor codes for scm model...
r691 response = self.app.post(url('repos'), {'repo_name':repo_name,
'repo_type':'hg',
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 'clone_uri':'',
'repo_group':'',
'description':description,
'private':private})
self.assertTrue('flash' in response.session)
Refactor codes for scm model...
r691
#test if we have a message for that repository
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 self.assertTrue('''created repository %s''' % (repo_name) in
response.session['flash'][0])
Refactor codes for scm model...
r691
#test if the repo was created in the database
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 new_repo = self.sa.query(Repository).filter(Repository.repo_name ==
repo_name).one()
Refactor codes for scm model...
r691
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 self.assertEqual(new_repo.repo_name, repo_name)
self.assertEqual(new_repo.description, description)
Refactor codes for scm model...
r691
#test if repository is visible in the list ?
response = response.follow()
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 self.assertTrue(repo_name in response.body)
Refactor codes for scm model...
r691
response = self.app.delete(url('repo', repo_name=repo_name))
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 self.assertTrue('''deleted repository %s''' % (repo_name) in
response.session['flash'][0])
Refactor codes for scm model...
r691
response.follow()
#check if repo was deleted from db
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 deleted_repo = self.sa.query(Repository).filter(Repository.repo_name
== repo_name).scalar()
self.assertEqual(deleted_repo, None)
Refactor codes for scm model...
r691
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366
def test_delete_repo_with_group(self):
#TODO:
pass
Refactor codes for scm model...
r691
def test_delete_browser_fakeout(self):
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 response = self.app.post(url('repo', repo_name=HG_REPO),
params=dict(_method='delete'))
Refactor codes for scm model...
r691
def test_show(self):
self.log_user()
response = self.app.get(url('repo', repo_name=HG_REPO))
def test_show_as_xml(self):
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 response = self.app.get(url('formatted_repo', repo_name=HG_REPO,
format='xml'))
Refactor codes for scm model...
r691
def test_edit(self):
response = self.app.get(url('edit_repo', repo_name=HG_REPO))
def test_edit_as_xml(self):
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 response = self.app.get(url('formatted_edit_repo', repo_name=HG_REPO,
format='xml'))