##// END OF EJS Templates
Initial version of landing revisions ref #483...
marcink -
r2471:60bda63b beta
parent child Browse files
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -70,6 +70,7 b' class ReposController(BaseController):'
70 repo_model = RepoModel()
70 repo_model = RepoModel()
71 c.users_array = repo_model.get_users_js()
71 c.users_array = repo_model.get_users_js()
72 c.users_groups_array = repo_model.get_users_groups_js()
72 c.users_groups_array = repo_model.get_users_groups_js()
73 c.landing_revs = ScmModel().get_repo_landing_revs()
73
74
74 def __load_data(self, repo_name=None):
75 def __load_data(self, repo_name=None):
75 """
76 """
@@ -91,6 +92,7 b' class ReposController(BaseController):'
91
92
92 return redirect(url('repos'))
93 return redirect(url('repos'))
93
94
95 c.landing_revs = ScmModel().get_repo_landing_revs(c.repo_info)
94 c.default_user_id = User.get_by_username('default').user_id
96 c.default_user_id = User.get_by_username('default').user_id
95 c.in_public_journal = UserFollowing.query()\
97 c.in_public_journal = UserFollowing.query()\
96 .filter(UserFollowing.user_id == c.default_user_id)\
98 .filter(UserFollowing.user_id == c.default_user_id)\
@@ -116,6 +118,7 b' class ReposController(BaseController):'
116 c.repos_list = [('', _('--REMOVE FORK--'))]
118 c.repos_list = [('', _('--REMOVE FORK--'))]
117 c.repos_list += [(x.repo_id, x.repo_name) for x in
119 c.repos_list += [(x.repo_id, x.repo_name) for x in
118 Repository.query().order_by(Repository.repo_name).all()]
120 Repository.query().order_by(Repository.repo_name).all()]
121
119 return defaults
122 return defaults
120
123
121 @HasPermissionAllDecorator('hg.admin')
124 @HasPermissionAllDecorator('hg.admin')
@@ -397,6 +397,7 b' class SettingsController(BaseController)'
397
397
398 c.repo_groups = RepoGroup.groups_choices()
398 c.repo_groups = RepoGroup.groups_choices()
399 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
399 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
400 c.landing_revs = ScmModel().get_repo_landing_revs()
400
401
401 new_repo = request.GET.get('repo', '')
402 new_repo = request.GET.get('repo', '')
402 c.new_repo = repo_name_slug(new_repo)
403 c.new_repo = repo_name_slug(new_repo)
@@ -448,7 +448,8 b' def repo2db_mapper(initial_repo_list, re'
448 'description': repo.description \
448 'description': repo.description \
449 if repo.description != 'unknown' else '%s repository' % name,
449 if repo.description != 'unknown' else '%s repository' % name,
450 'private': False,
450 'private': False,
451 'group_id': getattr(group, 'group_id', None)
451 'group_id': getattr(group, 'group_id', None),
452 'landing_rev': repo.DEFAULT_BRANCH_NAME
452 }
453 }
453 rm.create(form_data, user, just_db=True)
454 rm.create(form_data, user, just_db=True)
454 sa.commit()
455 sa.commit()
@@ -558,7 +559,7 b' def create_test_env(repos_test_path, con'
558 install test repository into tmp dir
559 install test repository into tmp dir
559 """
560 """
560 from rhodecode.lib.db_manage import DbManage
561 from rhodecode.lib.db_manage import DbManage
561 from rhodecode.tests import HG_REPO, TESTS_TMP_PATH
562 from rhodecode.tests import HG_REPO, GIT_REPO, TESTS_TMP_PATH
562
563
563 # PART ONE create db
564 # PART ONE create db
564 dbconf = config['sqlalchemy.db1.url']
565 dbconf = config['sqlalchemy.db1.url']
@@ -593,12 +594,17 b' def create_test_env(repos_test_path, con'
593 log.debug('remove %s' % data_path)
594 log.debug('remove %s' % data_path)
594 shutil.rmtree(data_path)
595 shutil.rmtree(data_path)
595
596
596 #CREATE DEFAULT HG REPOSITORY
597 #CREATE DEFAULT TEST REPOS
597 cur_dir = dn(dn(abspath(__file__)))
598 cur_dir = dn(dn(abspath(__file__)))
598 tar = tarfile.open(jn(cur_dir, 'tests', "vcs_test_hg.tar.gz"))
599 tar = tarfile.open(jn(cur_dir, 'tests', "vcs_test_hg.tar.gz"))
599 tar.extractall(jn(TESTS_TMP_PATH, HG_REPO))
600 tar.extractall(jn(TESTS_TMP_PATH, HG_REPO))
600 tar.close()
601 tar.close()
601
602
603 cur_dir = dn(dn(abspath(__file__)))
604 tar = tarfile.open(jn(cur_dir, 'tests', "vcs_test_git.tar.gz"))
605 tar.extractall(jn(TESTS_TMP_PATH, GIT_REPO))
606 tar.close()
607
602 #LOAD VCS test stuff
608 #LOAD VCS test stuff
603 from rhodecode.tests.vcs import setup_package
609 from rhodecode.tests.vcs import setup_package
604 setup_package()
610 setup_package()
@@ -295,7 +295,7 b' class User(Base, BaseModel):'
295 password = Column("password", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
295 password = Column("password", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
296 active = Column("active", Boolean(), nullable=True, unique=None, default=None)
296 active = Column("active", Boolean(), nullable=True, unique=None, default=None)
297 admin = Column("admin", Boolean(), nullable=True, unique=None, default=False)
297 admin = Column("admin", Boolean(), nullable=True, unique=None, default=False)
298 name = Column("name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
298 name = Column("firstname", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
299 lastname = Column("lastname", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
299 lastname = Column("lastname", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
300 _email = Column("email", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
300 _email = Column("email", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
301 last_login = Column("last_login", DateTime(timezone=False), nullable=True, unique=None, default=None)
301 last_login = Column("last_login", DateTime(timezone=False), nullable=True, unique=None, default=None)
@@ -500,13 +500,14 b' class Repository(Base, BaseModel):'
500 repo_id = Column("repo_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
500 repo_id = Column("repo_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
501 repo_name = Column("repo_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None)
501 repo_name = Column("repo_name", String(length=255, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None)
502 clone_uri = Column("clone_uri", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=False, default=None)
502 clone_uri = Column("clone_uri", String(length=255, convert_unicode=False, assert_unicode=None), nullable=True, unique=False, default=None)
503 repo_type = Column("repo_type", String(length=255, convert_unicode=False, assert_unicode=None), nullable=False, unique=False, default='hg')
503 repo_type = Column("repo_type", String(length=255, convert_unicode=False, assert_unicode=None), nullable=False, unique=False, default=None)
504 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
504 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=False, default=None)
505 private = Column("private", Boolean(), nullable=True, unique=None, default=None)
505 private = Column("private", Boolean(), nullable=True, unique=None, default=None)
506 enable_statistics = Column("statistics", Boolean(), nullable=True, unique=None, default=True)
506 enable_statistics = Column("statistics", Boolean(), nullable=True, unique=None, default=True)
507 enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True)
507 enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True)
508 description = Column("description", String(length=10000, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
508 description = Column("description", String(length=10000, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
509 created_on = Column('created_on', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now)
509 created_on = Column('created_on', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now)
510 landing_rev = Column("landing_revision", String(length=255, convert_unicode=False, assert_unicode=None), nullable=False, unique=False, default=None)
510
511
511 fork_id = Column("fork_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True, unique=False, default=None)
512 fork_id = Column("fork_id", Integer(), ForeignKey('repositories.repo_id'), nullable=True, unique=False, default=None)
512 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=False, default=None)
513 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=False, default=None)
@@ -523,7 +524,7 b' class Repository(Base, BaseModel):'
523 logs = relationship('UserLog')
524 logs = relationship('UserLog')
524
525
525 def __unicode__(self):
526 def __unicode__(self):
526 return u"<%s('%s:%s')>" % (self.__class__.__name__,self.repo_id,
527 return u"<%s('%s:%s')>" % (self.__class__.__name__, self.repo_id,
527 self.repo_name)
528 self.repo_name)
528
529
529 @classmethod
530 @classmethod
@@ -662,10 +662,11 b' def RepoForm(edit=False, old_data={}, su'
662 clone_uri = All(UnicodeString(strip=True, min=1, not_empty=False))
662 clone_uri = All(UnicodeString(strip=True, min=1, not_empty=False))
663 repo_group = OneOf(repo_groups, hideList=True)
663 repo_group = OneOf(repo_groups, hideList=True)
664 repo_type = OneOf(supported_backends)
664 repo_type = OneOf(supported_backends)
665 description = UnicodeString(strip=True, min=1, not_empty=True)
665 description = UnicodeString(strip=True, min=1, not_empty=False)
666 private = StringBoolean(if_missing=False)
666 private = StringBoolean(if_missing=False)
667 enable_statistics = StringBoolean(if_missing=False)
667 enable_statistics = StringBoolean(if_missing=False)
668 enable_downloads = StringBoolean(if_missing=False)
668 enable_downloads = StringBoolean(if_missing=False)
669 landing_rev = UnicodeString(strip=True, min=1, not_empty=True)
669
670
670 if edit:
671 if edit:
671 #this is repo owner
672 #this is repo owner
@@ -677,8 +678,8 b' def RepoForm(edit=False, old_data={}, su'
677 return _RepoForm
678 return _RepoForm
678
679
679
680
680 def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
681 def RepoForkForm(edit=False, old_data={},
681 repo_groups=[]):
682 supported_backends=BACKENDS.keys(), repo_groups=[]):
682 class _RepoForkForm(formencode.Schema):
683 class _RepoForkForm(formencode.Schema):
683 allow_extra_fields = True
684 allow_extra_fields = True
684 filter_extra_fields = False
685 filter_extra_fields = False
@@ -696,8 +697,8 b' def RepoForkForm(edit=False, old_data={}'
696 return _RepoForkForm
697 return _RepoForkForm
697
698
698
699
699 def RepoSettingsForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
700 def RepoSettingsForm(edit=False, old_data={},
700 repo_groups=[]):
701 supported_backends=BACKENDS.keys(), repo_groups=[]):
701 class _RepoForm(formencode.Schema):
702 class _RepoForm(formencode.Schema):
702 allow_extra_fields = True
703 allow_extra_fields = True
703 filter_extra_fields = False
704 filter_extra_fields = False
@@ -706,7 +707,7 b' def RepoSettingsForm(edit=False, old_dat'
706 description = UnicodeString(strip=True, min=1, not_empty=True)
707 description = UnicodeString(strip=True, min=1, not_empty=True)
707 repo_group = OneOf(repo_groups, hideList=True)
708 repo_group = OneOf(repo_groups, hideList=True)
708 private = StringBoolean(if_missing=False)
709 private = StringBoolean(if_missing=False)
709
710 landing_rev = UnicodeString(strip=True, min=1, not_empty=True)
710 chained_validators = [ValidRepoName(edit, old_data), ValidPerms(),
711 chained_validators = [ValidRepoName(edit, old_data), ValidPerms(),
711 ValidSettings]
712 ValidSettings]
712 return _RepoForm
713 return _RepoForm
@@ -29,6 +29,7 b' import logging'
29 import cStringIO
29 import cStringIO
30
30
31 from sqlalchemy import func
31 from sqlalchemy import func
32 from pylons.i18n.translation import _
32
33
33 from rhodecode.lib.vcs import get_backend
34 from rhodecode.lib.vcs import get_backend
34 from rhodecode.lib.vcs.exceptions import RepositoryError
35 from rhodecode.lib.vcs.exceptions import RepositoryError
@@ -472,3 +473,33 b' class ScmModel(BaseModel):'
472
473
473 def get_unread_journal(self):
474 def get_unread_journal(self):
474 return self.sa.query(UserLog).count()
475 return self.sa.query(UserLog).count()
476
477 def get_repo_landing_revs(self, repo=None):
478 """
479 Generates select option with tags branches and bookmarks (for hg only)
480 grouped by type
481
482 :param repo:
483 :type repo:
484 """
485 hist_l = []
486 repo = self.__get_repo(repo)
487 hist_l.append(['tip', _('latest tip')])
488 if not repo:
489 return hist_l
490
491 repo = repo.scm_instance
492 branches_group = ([(k, k) for k, v in
493 repo.branches.iteritems()], _("Branches"))
494 hist_l.append(branches_group)
495
496 if repo.alias == 'hg':
497 bookmarks_group = ([(k, k) for k, v in
498 repo.bookmarks.iteritems()], _("Bookmarks"))
499 hist_l.append(bookmarks_group)
500
501 tags_group = ([(k, k) for k, v in
502 repo.tags.iteritems()], _("Tags"))
503 hist_l.append(tags_group)
504
505 return hist_l
@@ -42,6 +42,15 b''
42 <span class="help-block">${_('Type of repository to create.')}</span>
42 <span class="help-block">${_('Type of repository to create.')}</span>
43 </div>
43 </div>
44 </div>
44 </div>
45 <div class="field">
46 <div class="label">
47 <label for="landing_rev">${_('Landing revision')}:</label>
48 </div>
49 <div class="input">
50 ${h.select('landing_rev','',c.landing_revs,class_="medium")}
51 <span class="help-block">${_('Default revision for files page, downloads, whoosh and readme')}</span>
52 </div>
53 </div>
45 <div class="field">
54 <div class="field">
46 <div class="label label-textarea">
55 <div class="label label-textarea">
47 <label for="description">${_('Description')}:</label>
56 <label for="description">${_('Description')}:</label>
@@ -62,6 +62,15 b''
62 </div>
62 </div>
63 </div>
63 </div>
64 <div class="field">
64 <div class="field">
65 <div class="label">
66 <label for="landing_rev">${_('Landing revision')}:</label>
67 </div>
68 <div class="input">
69 ${h.select('landing_rev','',c.landing_revs,class_="medium")}
70 <span class="help-block">${_('Default revision for files page, downloads, whoosh and readme')}</span>
71 </div>
72 </div>
73 <div class="field">
65 <div class="label label-textarea">
74 <div class="label label-textarea">
66 <label for="description">${_('Description')}:</label>
75 <label for="description">${_('Description')}:</label>
67 </div>
76 </div>
@@ -210,7 +219,7 b''
210 </div>
219 </div>
211 ${h.end_form()}
220 ${h.end_form()}
212
221
213 <h3>${_('Set as fork')}</h3>
222 <h3>${_('Set as fork of')}</h3>
214 ${h.form(url('repo_as_fork', repo_name=c.repo_info.repo_name),method='put')}
223 ${h.form(url('repo_as_fork', repo_name=c.repo_info.repo_name),method='put')}
215 <div class="form">
224 <div class="form">
216 <div class="fields">
225 <div class="fields">
@@ -219,7 +228,7 b''
219 </div>
228 </div>
220 <div class="field" style="border:none;color:#888">
229 <div class="field" style="border:none;color:#888">
221 <ul>
230 <ul>
222 <li>${_('''Manually set this repository as a fork of another''')}</li>
231 <li>${_('''Manually set this repository as a fork of another from the list''')}</li>
223 </ul>
232 </ul>
224 </div>
233 </div>
225 </div>
234 </div>
@@ -38,13 +38,14 b' if not is_windows:'
38 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
39
39
40 __all__ = [
40 __all__ = [
41 'environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO',
41 'environ', 'url', 'get_new_dir', 'TestController', 'TESTS_TMP_PATH',
42 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK',
42 'HG_REPO', 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK',
43 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_REGULAR_LOGIN',
43 'GIT_FORK', 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_REGULAR_LOGIN',
44 'TEST_USER_REGULAR_PASS', 'TEST_USER_REGULAR_EMAIL',
44 'TEST_USER_REGULAR_PASS', 'TEST_USER_REGULAR_EMAIL',
45 'TEST_USER_REGULAR2_LOGIN', 'TEST_USER_REGULAR2_PASS',
45 'TEST_USER_REGULAR2_LOGIN', 'TEST_USER_REGULAR2_PASS',
46 'TEST_USER_REGULAR2_EMAIL', 'TEST_HG_REPO', 'TEST_GIT_REPO',
46 'TEST_USER_REGULAR2_EMAIL', 'TEST_HG_REPO', 'TEST_HG_REPO_CLONE',
47 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO', 'SCM_TESTS',
47 'TEST_HG_REPO_PULL', 'TEST_GIT_REPO', 'TEST_GIT_REPO_CLONE',
48 'TEST_GIT_REPO_PULL', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO', 'SCM_TESTS',
48 ]
49 ]
49
50
50 # Invoke websetup with the current config file
51 # Invoke websetup with the current config file
@@ -83,22 +84,27 b" GIT_FORK = 'vcs_test_git_fork'"
83 SCM_TESTS = ['hg', 'git']
84 SCM_TESTS = ['hg', 'git']
84 uniq_suffix = str(int(time.mktime(datetime.datetime.now().timetuple())))
85 uniq_suffix = str(int(time.mktime(datetime.datetime.now().timetuple())))
85
86
86 THIS = os.path.abspath(os.path.dirname(__file__))
87 GIT_REMOTE_REPO = 'git://github.com/codeinn/vcs.git'
87
88
88 GIT_REMOTE_REPO = 'git://github.com/codeinn/vcs.git'
89 TEST_GIT_REPO = jn(TESTS_TMP_PATH, GIT_REPO)
89 TEST_GIT_REPO = jn(TESTS_TMP_PATH, GIT_REPO)
90 TEST_GIT_REPO_CLONE = jn(TESTS_TMP_PATH, 'vcsgitclone%s' % uniq_suffix)
90 TEST_GIT_REPO_CLONE = jn(TESTS_TMP_PATH, 'vcsgitclone%s' % uniq_suffix)
91 TEST_GIT_REPO_PULL = jn(TESTS_TMP_PATH, 'vcsgitpull%s' % uniq_suffix)
91 TEST_GIT_REPO_PULL = jn(TESTS_TMP_PATH, 'vcsgitpull%s' % uniq_suffix)
92
92
93
93
94 HG_REMOTE_REPO = 'http://bitbucket.org/marcinkuzminski/vcs'
94 HG_REMOTE_REPO = 'http://bitbucket.org/marcinkuzminski/vcs'
95 TEST_HG_REPO = jn(TESTS_TMP_PATH, 'vcs-hg')
95
96 TEST_HG_REPO = jn(TESTS_TMP_PATH, HG_REPO)
96 TEST_HG_REPO_CLONE = jn(TESTS_TMP_PATH, 'vcshgclone%s' % uniq_suffix)
97 TEST_HG_REPO_CLONE = jn(TESTS_TMP_PATH, 'vcshgclone%s' % uniq_suffix)
97 TEST_HG_REPO_PULL = jn(TESTS_TMP_PATH, 'vcshgpull%s' % uniq_suffix)
98 TEST_HG_REPO_PULL = jn(TESTS_TMP_PATH, 'vcshgpull%s' % uniq_suffix)
98
99
99 TEST_DIR = tempfile.gettempdir()
100 TEST_DIR = tempfile.gettempdir()
100 TEST_REPO_PREFIX = 'vcs-test'
101 TEST_REPO_PREFIX = 'vcs-test'
101
102
103 # cached repos if any !
104 # comment out to get some other repos from bb or github
105 GIT_REMOTE_REPO = jn(TESTS_TMP_PATH, GIT_REPO)
106 HG_REMOTE_REPO = jn(TESTS_TMP_PATH, HG_REPO)
107
102
108
103 def get_new_dir(title):
109 def get_new_dir(title):
104 """
110 """
@@ -114,12 +120,6 b' def get_new_dir(title):'
114 return get_normalized_path(path)
120 return get_normalized_path(path)
115
121
116
122
117 PACKAGE_DIR = os.path.abspath(os.path.join(
118 os.path.dirname(__file__), '..'))
119
120 TEST_USER_CONFIG_FILE = jn(THIS, 'aconfig')
121
122
123 class TestController(TestCase):
123 class TestController(TestCase):
124
124
125 def __init__(self, *args, **kwargs):
125 def __init__(self, *args, **kwargs):
@@ -6,6 +6,7 b' from rhodecode.lib import vcs'
6 from rhodecode.model.db import Repository
6 from rhodecode.model.db import Repository
7 from rhodecode.tests import *
7 from rhodecode.tests import *
8
8
9
9 class TestAdminReposController(TestController):
10 class TestAdminReposController(TestController):
10
11
11 def __make_repo(self):
12 def __make_repo(self):
@@ -24,17 +25,19 b' class TestAdminReposController(TestContr'
24 repo_name = NEW_HG_REPO
25 repo_name = NEW_HG_REPO
25 description = 'description for newly created repo'
26 description = 'description for newly created repo'
26 private = False
27 private = False
27 response = self.app.post(url('repos'), {'repo_name':repo_name,
28 response = self.app.post(url('repos'), {'repo_name': repo_name,
28 'repo_type':'hg',
29 'repo_type': 'hg',
29 'clone_uri':'',
30 'clone_uri': '',
30 'repo_group':'',
31 'repo_group': '',
31 'description':description,
32 'description': description,
32 'private':private})
33 'private': private,
33 self.checkSessionFlash(response, 'created repository %s' % (repo_name))
34 'landing_rev': 'tip'})
35 self.checkSessionFlash(response,
36 'created repository %s' % (repo_name))
34
37
35 #test if the repo was created in the database
38 #test if the repo was created in the database
36 new_repo = self.Session.query(Repository).filter(Repository.repo_name ==
39 new_repo = self.Session.query(Repository)\
37 repo_name).one()
40 .filter(Repository.repo_name == repo_name).one()
38
41
39 self.assertEqual(new_repo.repo_name, repo_name)
42 self.assertEqual(new_repo.repo_name, repo_name)
40 self.assertEqual(new_repo.description, description)
43 self.assertEqual(new_repo.description, description)
@@ -42,15 +45,13 b' class TestAdminReposController(TestContr'
42 #test if repository is visible in the list ?
45 #test if repository is visible in the list ?
43 response = response.follow()
46 response = response.follow()
44
47
45 self.assertTrue(repo_name in response.body)
48 response.mustcontain(repo_name)
46
47
49
48 #test if repository was created on filesystem
50 #test if repository was created on filesystem
49 try:
51 try:
50 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
52 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
51 except:
53 except:
52 self.fail('no repo in filesystem')
54 self.fail('no repo %s in filesystem' % repo_name)
53
54
55
55 def test_create_hg_non_ascii(self):
56 def test_create_hg_non_ascii(self):
56 self.log_user()
57 self.log_user()
@@ -60,18 +61,19 b' class TestAdminReposController(TestContr'
60 description = 'description for newly created repo' + non_ascii
61 description = 'description for newly created repo' + non_ascii
61 description_unicode = description.decode('utf8')
62 description_unicode = description.decode('utf8')
62 private = False
63 private = False
63 response = self.app.post(url('repos'), {'repo_name':repo_name,
64 response = self.app.post(url('repos'), {'repo_name': repo_name,
64 'repo_type':'hg',
65 'repo_type': 'hg',
65 'clone_uri':'',
66 'clone_uri': '',
66 'repo_group':'',
67 'repo_group': '',
67 'description':description,
68 'description': description,
68 'private':private})
69 'private': private,
70 'landing_rev': 'tip'})
69 self.checkSessionFlash(response,
71 self.checkSessionFlash(response,
70 'created repository %s' % (repo_name_unicode))
72 'created repository %s' % (repo_name_unicode))
71
73
72 #test if the repo was created in the database
74 #test if the repo was created in the database
73 new_repo = self.Session.query(Repository).filter(Repository.repo_name ==
75 new_repo = self.Session.query(Repository)\
74 repo_name_unicode).one()
76 .filter(Repository.repo_name == repo_name_unicode).one()
75
77
76 self.assertEqual(new_repo.repo_name, repo_name_unicode)
78 self.assertEqual(new_repo.repo_name, repo_name_unicode)
77 self.assertEqual(new_repo.description, description_unicode)
79 self.assertEqual(new_repo.description, description_unicode)
@@ -79,52 +81,86 b' class TestAdminReposController(TestContr'
79 #test if repository is visible in the list ?
81 #test if repository is visible in the list ?
80 response = response.follow()
82 response = response.follow()
81
83
82 self.assertTrue(repo_name in response.body)
84 response.mustcontain(repo_name)
83
85
84 #test if repository was created on filesystem
86 #test if repository was created on filesystem
85 try:
87 try:
86 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
88 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
87 except:
89 except:
88 self.fail('no repo in filesystem')
90 self.fail('no repo %s in filesystem' % repo_name)
89
90
91
91 def test_create_hg_in_group(self):
92 def test_create_hg_in_group(self):
92 #TODO: write test !
93 #TODO: write test !
93 pass
94 pass
94
95
95 def test_create_git(self):
96 def test_create_git(self):
96 return
97 self.log_user()
97 self.log_user()
98 repo_name = NEW_GIT_REPO
98 repo_name = NEW_GIT_REPO
99 description = 'description for newly created repo'
99 description = 'description for newly created repo'
100 private = False
100 private = False
101 response = self.app.post(url('repos'), {'repo_name':repo_name,
101 response = self.app.post(url('repos'), {'repo_name': repo_name,
102 'repo_type':'git',
102 'repo_type': 'git',
103 'clone_uri':'',
103 'clone_uri': '',
104 'repo_group':'',
104 'repo_group': '',
105 'description':description,
105 'description': description,
106 'private':private})
106 'private': private,
107
107 'landing_rev': 'tip'})
108 self.checkSessionFlash(response,
109 'created repository %s' % (repo_name))
108
110
109 #test if we have a message for that repository
111 #test if the repo was created in the database
110 assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'
112 new_repo = self.Session.query(Repository)\
113 .filter(Repository.repo_name == repo_name).one()
111
114
112 #test if the fork was created in the database
115 self.assertEqual(new_repo.repo_name, repo_name)
113 new_repo = self.Session.query(Repository).filter(Repository.repo_name == repo_name).one()
116 self.assertEqual(new_repo.description, description)
114
115 assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
116 assert new_repo.description == description, 'wrong description'
117
117
118 #test if repository is visible in the list ?
118 #test if repository is visible in the list ?
119 response = response.follow()
119 response = response.follow()
120
120
121 assert repo_name in response.body, 'missing new repo from the main repos list'
121 response.mustcontain(repo_name)
122
122
123 #test if repository was created on filesystem
123 #test if repository was created on filesystem
124 try:
124 try:
125 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
125 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
126 except:
126 except:
127 assert False , 'no repo in filesystem'
127 self.fail('no repo %s in filesystem' % repo_name)
128
129 def test_create_git_non_ascii(self):
130 self.log_user()
131 non_ascii = "ąęł"
132 repo_name = "%s%s" % (NEW_GIT_REPO, non_ascii)
133 repo_name_unicode = repo_name.decode('utf8')
134 description = 'description for newly created repo' + non_ascii
135 description_unicode = description.decode('utf8')
136 private = False
137 response = self.app.post(url('repos'), {'repo_name': repo_name,
138 'repo_type': 'git',
139 'clone_uri': '',
140 'repo_group': '',
141 'description': description,
142 'private': private,
143 'landing_rev': 'tip'})
144 self.checkSessionFlash(response,
145 'created repository %s' % (repo_name_unicode))
146
147 #test if the repo was created in the database
148 new_repo = self.Session.query(Repository)\
149 .filter(Repository.repo_name == repo_name_unicode).one()
150
151 self.assertEqual(new_repo.repo_name, repo_name_unicode)
152 self.assertEqual(new_repo.description, description_unicode)
153
154 #test if repository is visible in the list ?
155 response = response.follow()
156
157 response.mustcontain(repo_name)
158
159 #test if repository was created on filesystem
160 try:
161 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
162 except:
163 self.fail('no repo %s in filesystem' % repo_name)
128
164
129 def test_new(self):
165 def test_new(self):
130 self.log_user()
166 self.log_user()
@@ -140,27 +176,24 b' class TestAdminReposController(TestContr'
140 response = self.app.post(url('repo', repo_name=HG_REPO),
176 response = self.app.post(url('repo', repo_name=HG_REPO),
141 params=dict(_method='put'))
177 params=dict(_method='put'))
142
178
143 def test_delete(self):
179 def test_delete_hg(self):
144 self.log_user()
180 self.log_user()
145 repo_name = 'vcs_test_new_to_delete'
181 repo_name = 'vcs_test_new_to_delete'
146 description = 'description for newly created repo'
182 description = 'description for newly created repo'
147 private = False
183 private = False
148
184 response = self.app.post(url('repos'), {'repo_name': repo_name,
149 response = self.app.post(url('repos'), {'repo_name':repo_name,
185 'repo_type': 'hg',
150 'repo_type':'hg',
186 'clone_uri': '',
151 'clone_uri':'',
187 'repo_group': '',
152 'repo_group':'',
188 'description': description,
153 'description':description,
189 'private': private,
154 'private':private})
190 'landing_rev': 'tip'})
155 self.assertTrue('flash' in response.session)
191 self.checkSessionFlash(response,
156
192 'created repository %s' % (repo_name))
157 #test if we have a message for that repository
158 self.assertTrue('''created repository %s''' % (repo_name) in
159 response.session['flash'][0])
160
193
161 #test if the repo was created in the database
194 #test if the repo was created in the database
162 new_repo = self.Session.query(Repository).filter(Repository.repo_name ==
195 new_repo = self.Session.query(Repository)\
163 repo_name).one()
196 .filter(Repository.repo_name == repo_name).one()
164
197
165 self.assertEqual(new_repo.repo_name, repo_name)
198 self.assertEqual(new_repo.repo_name, repo_name)
166 self.assertEqual(new_repo.description, description)
199 self.assertEqual(new_repo.description, description)
@@ -168,8 +201,13 b' class TestAdminReposController(TestContr'
168 #test if repository is visible in the list ?
201 #test if repository is visible in the list ?
169 response = response.follow()
202 response = response.follow()
170
203
171 self.assertTrue(repo_name in response.body)
204 response.mustcontain(repo_name)
172
205
206 #test if repository was created on filesystem
207 try:
208 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
209 except:
210 self.fail('no repo %s in filesystem' % repo_name)
173
211
174 response = self.app.delete(url('repo', repo_name=repo_name))
212 response = self.app.delete(url('repo', repo_name=repo_name))
175
213
@@ -179,32 +217,79 b' class TestAdminReposController(TestContr'
179 response.follow()
217 response.follow()
180
218
181 #check if repo was deleted from db
219 #check if repo was deleted from db
182 deleted_repo = self.Session.query(Repository).filter(Repository.repo_name
220 deleted_repo = self.Session.query(Repository)\
183 == repo_name).scalar()
221 .filter(Repository.repo_name == repo_name).scalar()
184
222
185 self.assertEqual(deleted_repo, None)
223 self.assertEqual(deleted_repo, None)
186
224
225 self.assertEqual(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)),
226 False)
227
228 def test_delete_git(self):
229 self.log_user()
230 repo_name = 'vcs_test_new_to_delete'
231 description = 'description for newly created repo'
232 private = False
233 response = self.app.post(url('repos'), {'repo_name': repo_name,
234 'repo_type': 'git',
235 'clone_uri': '',
236 'repo_group': '',
237 'description': description,
238 'private': private,
239 'landing_rev': 'tip'})
240 self.checkSessionFlash(response,
241 'created repository %s' % (repo_name))
242
243 #test if the repo was created in the database
244 new_repo = self.Session.query(Repository)\
245 .filter(Repository.repo_name == repo_name).one()
246
247 self.assertEqual(new_repo.repo_name, repo_name)
248 self.assertEqual(new_repo.description, description)
249
250 #test if repository is visible in the list ?
251 response = response.follow()
252
253 response.mustcontain(repo_name)
254
255 #test if repository was created on filesystem
256 try:
257 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
258 except:
259 self.fail('no repo %s in filesystem' % repo_name)
260
261 response = self.app.delete(url('repo', repo_name=repo_name))
262
263 self.assertTrue('''deleted repository %s''' % (repo_name) in
264 response.session['flash'][0])
265
266 response.follow()
267
268 #check if repo was deleted from db
269 deleted_repo = self.Session.query(Repository)\
270 .filter(Repository.repo_name == repo_name).scalar()
271
272 self.assertEqual(deleted_repo, None)
273
274 self.assertEqual(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)),
275 False)
187
276
188 def test_delete_repo_with_group(self):
277 def test_delete_repo_with_group(self):
189 #TODO:
278 #TODO:
190 pass
279 pass
191
280
192
193 def test_delete_browser_fakeout(self):
281 def test_delete_browser_fakeout(self):
194 response = self.app.post(url('repo', repo_name=HG_REPO),
282 response = self.app.post(url('repo', repo_name=HG_REPO),
195 params=dict(_method='delete'))
283 params=dict(_method='delete'))
196
284
197 def test_show(self):
285 def test_show_hg(self):
198 self.log_user()
286 self.log_user()
199 response = self.app.get(url('repo', repo_name=HG_REPO))
287 response = self.app.get(url('repo', repo_name=HG_REPO))
200
288
201 def test_show_as_xml(self):
289 def test_show_git(self):
202 response = self.app.get(url('formatted_repo', repo_name=HG_REPO,
290 self.log_user()
203 format='xml'))
291 response = self.app.get(url('repo', repo_name=GIT_REPO))
292
204
293
205 def test_edit(self):
294 def test_edit(self):
206 response = self.app.get(url('edit_repo', repo_name=HG_REPO))
295 response = self.app.get(url('edit_repo', repo_name=HG_REPO))
207
208 def test_edit_as_xml(self):
209 response = self.app.get(url('formatted_edit_repo', repo_name=HG_REPO,
210 format='xml'))
@@ -28,7 +28,7 b' class TestForksController(TestController'
28
28
29 self.assertTrue("""There are no forks yet""" in response.body)
29 self.assertTrue("""There are no forks yet""" in response.body)
30
30
31 def test_index_with_fork(self):
31 def test_index_with_fork_hg(self):
32 self.log_user()
32 self.log_user()
33
33
34 # create a fork
34 # create a fork
@@ -39,19 +39,49 b' class TestForksController(TestController'
39 response = self.app.post(url(controller='forks',
39 response = self.app.post(url(controller='forks',
40 action='fork_create',
40 action='fork_create',
41 repo_name=repo_name),
41 repo_name=repo_name),
42 {'repo_name':fork_name,
42 {'repo_name': fork_name,
43 'repo_group':'',
43 'repo_group': '',
44 'fork_parent_id':org_repo.repo_id,
44 'fork_parent_id': org_repo.repo_id,
45 'repo_type':'hg',
45 'repo_type': 'hg',
46 'description':description,
46 'description': description,
47 'private':'False'})
47 'private': 'False',
48 'landing_rev': 'tip'})
48
49
49 response = self.app.get(url(controller='forks', action='forks',
50 response = self.app.get(url(controller='forks', action='forks',
50 repo_name=repo_name))
51 repo_name=repo_name))
51
52
52 self.assertTrue("""<a href="/%s/summary">"""
53 response.mustcontain(
53 """vcs_test_hg_fork</a>""" % fork_name
54 """<a href="/%s/summary">%s</a>""" % (fork_name, fork_name)
54 in response.body)
55 )
56
57 #remove this fork
58 response = self.app.delete(url('repo', repo_name=fork_name))
59
60 def test_index_with_fork_git(self):
61 self.log_user()
62
63 # create a fork
64 fork_name = GIT_FORK
65 description = 'fork of vcs test'
66 repo_name = GIT_REPO
67 org_repo = Repository.get_by_repo_name(repo_name)
68 response = self.app.post(url(controller='forks',
69 action='fork_create',
70 repo_name=repo_name),
71 {'repo_name': fork_name,
72 'repo_group': '',
73 'fork_parent_id': org_repo.repo_id,
74 'repo_type': 'git',
75 'description': description,
76 'private': 'False',
77 'landing_rev': 'tip'})
78
79 response = self.app.get(url(controller='forks', action='forks',
80 repo_name=repo_name))
81
82 response.mustcontain(
83 """<a href="/%s/summary">%s</a>""" % (fork_name, fork_name)
84 )
55
85
56 #remove this fork
86 #remove this fork
57 response = self.app.delete(url('repo', repo_name=fork_name))
87 response = self.app.delete(url('repo', repo_name=fork_name))
@@ -69,11 +99,12 b' class TestForksController(TestController'
69 'fork_parent_id':org_repo.repo_id,
99 'fork_parent_id':org_repo.repo_id,
70 'repo_type':'hg',
100 'repo_type':'hg',
71 'description':description,
101 'description':description,
72 'private':'False'})
102 'private':'False',
103 'landing_rev': 'tip'})
73
104
74 #test if we have a message that fork is ok
105 #test if we have a message that fork is ok
75 self.assertTrue('forked %s repository as %s' \
106 self.checkSessionFlash(response,
76 % (repo_name, fork_name) in response.session['flash'][0])
107 'forked %s repository as %s' % (repo_name, fork_name))
77
108
78 #test if the fork was created in the database
109 #test if the fork was created in the database
79 fork_repo = self.Session.query(Repository)\
110 fork_repo = self.Session.query(Repository)\
@@ -85,10 +116,6 b' class TestForksController(TestController'
85 #test if fork is visible in the list ?
116 #test if fork is visible in the list ?
86 response = response.follow()
117 response = response.follow()
87
118
88 # check if fork is marked as fork
89 # wait for cache to expire
90 import time
91 time.sleep(10)
92 response = self.app.get(url(controller='summary', action='index',
119 response = self.app.get(url(controller='summary', action='index',
93 repo_name=fork_name))
120 repo_name=fork_name))
94
121
@@ -1,5 +1,5 b''
1 import os
1 from rhodecode.tests import *
2 from rhodecode.tests import *
2 import os
3 from nose.plugins.skip import SkipTest
3 from nose.plugins.skip import SkipTest
4
4
5
5
@@ -27,8 +27,7 b' class TestSearchController(TestControlle'
27 self.log_user()
27 self.log_user()
28 response = self.app.get(url(controller='search', action='index'),
28 response = self.app.get(url(controller='search', action='index'),
29 {'q': 'def repo'})
29 {'q': 'def repo'})
30 response.mustcontain('10 results')
30 response.mustcontain('39 results')
31 response.mustcontain('Permission denied')
32
31
33 def test_repo_search(self):
32 def test_repo_search(self):
34 self.log_user()
33 self.log_user()
@@ -36,4 +35,3 b' class TestSearchController(TestControlle'
36 {'q': 'repository:%s def test' % HG_REPO})
35 {'q': 'repository:%s def test' % HG_REPO})
37
36
38 response.mustcontain('4 results')
37 response.mustcontain('4 results')
39 response.mustcontain('Permission denied')
@@ -92,7 +92,7 b' class TestSummaryController(TestControll'
92 #repo type
92 #repo type
93 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
93 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
94 """title="Git repository" alt="Git """
94 """title="Git repository" alt="Git """
95 """repository" src="/images/icons/hgicon.png"/>""")
95 """repository" src="/images/icons/giticon.png"/>""")
96 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
96 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
97 """title="public repository" alt="public """
97 """title="public repository" alt="public """
98 """repository" src="/images/icons/lock_open.png"/>""")
98 """repository" src="/images/icons/lock_open.png"/>""")
@@ -136,7 +136,8 b' class TestReposGroups(unittest.TestCase)'
136 repo_group=None,
136 repo_group=None,
137 private=False,
137 private=False,
138 repo_type='hg',
138 repo_type='hg',
139 clone_uri=None)
139 clone_uri=None,
140 landing_rev='tip')
140 cur_user = User.get_by_username(TEST_USER_ADMIN_LOGIN)
141 cur_user = User.get_by_username(TEST_USER_ADMIN_LOGIN)
141 r = RepoModel().create(form_data, cur_user)
142 r = RepoModel().create(form_data, cur_user)
142
143
@@ -608,7 +609,6 b' class TestPermissions(unittest.TestCase)'
608 user=self.anon,
609 user=self.anon,
609 perm='group.none')
610 perm='group.none')
610
611
611
612 u1_auth = AuthUser(user_id=self.u1.user_id)
612 u1_auth = AuthUser(user_id=self.u1.user_id)
613 self.assertEqual(u1_auth.permissions['repositories_groups'],
613 self.assertEqual(u1_auth.permissions['repositories_groups'],
614 {u'group1': u'group.none', u'group2': u'group.none'})
614 {u'group1': u'group.none', u'group2': u'group.none'})
@@ -619,13 +619,14 b' class TestPermissions(unittest.TestCase)'
619
619
620 # add repo to group
620 # add repo to group
621 form_data = {
621 form_data = {
622 'repo_name':HG_REPO,
622 'repo_name': HG_REPO,
623 'repo_name_full':RepoGroup.url_sep().join([self.g1.group_name,HG_REPO]),
623 'repo_name_full': RepoGroup.url_sep().join([self.g1.group_name,HG_REPO]),
624 'repo_type':'hg',
624 'repo_type': 'hg',
625 'clone_uri':'',
625 'clone_uri': '',
626 'repo_group':self.g1.group_id,
626 'repo_group': self.g1.group_id,
627 'description':'desc',
627 'description': 'desc',
628 'private':False
628 'private': False,
629 'landing_rev': 'tip'
629 }
630 }
630 self.test_repo = RepoModel().create(form_data, cur_user=self.u1)
631 self.test_repo = RepoModel().create(form_data, cur_user=self.u1)
631 Session.commit()
632 Session.commit()
@@ -52,5 +52,5 b' def setup_package():'
52 except VCSTestError, err:
52 except VCSTestError, err:
53 raise RuntimeError(str(err))
53 raise RuntimeError(str(err))
54
54
55 start_dir = os.path.abspath(os.path.dirname(__file__))
55 #start_dir = os.path.abspath(os.path.dirname(__file__))
56 unittest.defaultTestLoader.discover(start_dir)
56 #unittest.defaultTestLoader.discover(start_dir)
@@ -1,59 +1,60 b''
1 """
1 """
2 Unit tests configuration module for vcs.
2 Unit tests configuration module for vcs.
3 """
3 """
4
4 import os
5 import os
5 import time
6 import time
6 import hashlib
7 import hashlib
7 import tempfile
8 import tempfile
8 import datetime
9 import datetime
9
10 from rhodecode.tests import *
10 from utils import get_normalized_path
11 from utils import get_normalized_path
11 from os.path import join as jn
12 from os.path import join as jn
12
13
13 __all__ = (
14 TEST_TMP_PATH = TESTS_TMP_PATH
14 'TEST_HG_REPO', 'TEST_GIT_REPO', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO',
15 #__all__ = (
15 'SCM_TESTS',
16 # 'TEST_HG_REPO', 'TEST_GIT_REPO', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO',
16 )
17 # 'SCM_TESTS',
17
18 #)
18 SCM_TESTS = ['hg', 'git']
19 #
19 uniq_suffix = str(int(time.mktime(datetime.datetime.now().timetuple())))
20 #SCM_TESTS = ['hg', 'git']
20
21 #uniq_suffix = str(int(time.mktime(datetime.datetime.now().timetuple())))
22 #
21 THIS = os.path.abspath(os.path.dirname(__file__))
23 THIS = os.path.abspath(os.path.dirname(__file__))
22
24 #
23 GIT_REMOTE_REPO = 'git://github.com/codeinn/vcs.git'
25 #GIT_REMOTE_REPO = 'git://github.com/codeinn/vcs.git'
24
26 #
25 TEST_TMP_PATH = os.environ.get('VCS_TEST_ROOT', '/tmp')
27 #TEST_TMP_PATH = os.environ.get('VCS_TEST_ROOT', '/tmp')
26 TEST_GIT_REPO = os.environ.get('VCS_TEST_GIT_REPO',
28 #TEST_GIT_REPO = os.environ.get('VCS_TEST_GIT_REPO',
27 jn(TEST_TMP_PATH, 'vcs-git'))
29 # jn(TEST_TMP_PATH, 'vcs-git'))
28 TEST_GIT_REPO_CLONE = os.environ.get('VCS_TEST_GIT_REPO_CLONE',
30 #TEST_GIT_REPO_CLONE = os.environ.get('VCS_TEST_GIT_REPO_CLONE',
29 jn(TEST_TMP_PATH, 'vcsgitclone%s' % uniq_suffix))
31 # jn(TEST_TMP_PATH, 'vcsgitclone%s' % uniq_suffix))
30 TEST_GIT_REPO_PULL = os.environ.get('VCS_TEST_GIT_REPO_PULL',
32 #TEST_GIT_REPO_PULL = os.environ.get('VCS_TEST_GIT_REPO_PULL',
31 jn(TEST_TMP_PATH, 'vcsgitpull%s' % uniq_suffix))
33 # jn(TEST_TMP_PATH, 'vcsgitpull%s' % uniq_suffix))
32
34 #
33 HG_REMOTE_REPO = 'http://bitbucket.org/marcinkuzminski/vcs'
35 #HG_REMOTE_REPO = 'http://bitbucket.org/marcinkuzminski/vcs'
34 TEST_HG_REPO = os.environ.get('VCS_TEST_HG_REPO',
36 #TEST_HG_REPO = os.environ.get('VCS_TEST_HG_REPO',
35 jn(TEST_TMP_PATH, 'vcs-hg'))
37 # jn(TEST_TMP_PATH, 'vcs-hg'))
36 TEST_HG_REPO_CLONE = os.environ.get('VCS_TEST_HG_REPO_CLONE',
38 #TEST_HG_REPO_CLONE = os.environ.get('VCS_TEST_HG_REPO_CLONE',
37 jn(TEST_TMP_PATH, 'vcshgclone%s' % uniq_suffix))
39 # jn(TEST_TMP_PATH, 'vcshgclone%s' % uniq_suffix))
38 TEST_HG_REPO_PULL = os.environ.get('VCS_TEST_HG_REPO_PULL',
40 #TEST_HG_REPO_PULL = os.environ.get('VCS_TEST_HG_REPO_PULL',
39 jn(TEST_TMP_PATH, 'vcshgpull%s' % uniq_suffix))
41 # jn(TEST_TMP_PATH, 'vcshgpull%s' % uniq_suffix))
40
42 #
41 TEST_DIR = os.environ.get('VCS_TEST_ROOT', tempfile.gettempdir())
43 #TEST_DIR = os.environ.get('VCS_TEST_ROOT', tempfile.gettempdir())
42 TEST_REPO_PREFIX = 'vcs-test'
44 #TEST_REPO_PREFIX = 'vcs-test'
43
45 #
44
46 #
45 def get_new_dir(title):
47 #def get_new_dir(title):
46 """
48 # """
47 Returns always new directory path.
49 # Returns always new directory path.
48 """
50 # """
49 name = TEST_REPO_PREFIX
51 # name = TEST_REPO_PREFIX
50 if title:
52 # if title:
51 name = '-'.join((name, title))
53 # name = '-'.join((name, title))
52 hex = hashlib.sha1(str(time.time())).hexdigest()
54 # hex = hashlib.sha1(str(time.time())).hexdigest()
53 name = '-'.join((name, hex))
55 # name = '-'.join((name, hex))
54 path = os.path.join(TEST_DIR, name)
56 # path = os.path.join(TEST_DIR, name)
55 return get_normalized_path(path)
57 # return get_normalized_path(path)
56
57
58
58 PACKAGE_DIR = os.path.abspath(os.path.join(
59 PACKAGE_DIR = os.path.abspath(os.path.join(
59 os.path.dirname(__file__), '..'))
60 os.path.dirname(__file__), '..'))
@@ -156,14 +156,10 b' class MercurialRepositoryTest(unittest.T'
156
156
157 #active branches
157 #active branches
158 self.assertTrue('default' in self.repo.branches)
158 self.assertTrue('default' in self.repo.branches)
159
159 self.assertTrue('git' in self.repo.branches)
160 #closed branches
161 self.assertFalse('web' in self.repo.branches)
162 self.assertFalse('git' in self.repo.branches)
163
160
164 # closed
161 # closed
165 self.assertTrue('workdir' in self.repo._get_branches(closed=True))
162 self.assertTrue('web' in self.repo._get_branches(closed=True))
166 self.assertTrue('webvcs' in self.repo._get_branches(closed=True))
167
163
168 for name, id in self.repo.branches.items():
164 for name, id in self.repo.branches.items():
169 self.assertTrue(isinstance(
165 self.assertTrue(isinstance(
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now