Exemplo n.º 1
0
 def test_raises_error_when_bookmark_is_specified_for_git(self):
     with patch('rhodecode.model.db.Repository') as repo:
         repo.scm_instance().alias = 'git'
         repo.scm_instance().bookmarks = {
             self.bookmark_name: self.commit_hash
         }
         with pytest.raises(ValueError):
             utils._get_ref_hash(repo, 'bookmark', self.bookmark_name)
Exemplo n.º 2
0
 def test_returns_hash_when_bookmark_is_specified_for_hg(self):
     with patch('rhodecode.model.db.Repository') as repo:
         repo.scm_instance().alias = 'hg'
         repo.scm_instance().bookmarks = {
             self.bookmark_name: self.commit_hash
         }
         result_hash = utils._get_ref_hash(repo, 'bookmark',
                                           self.bookmark_name)
         assert result_hash == self.commit_hash
Exemplo n.º 3
0
 def test_raises_error_when_bookmark_is_not_found_in_hg_repo(self):
     with patch('rhodecode.model.db.Repository') as repo:
         repo.scm_instance().alias = 'hg'
         repo.scm_instance().bookmarks = {}
         with pytest.raises(KeyError):
             utils._get_ref_hash(repo, 'bookmark', self.bookmark_name)
Exemplo n.º 4
0
 def test_raises_error_when_branch_is_not_found(self, alias, branch_name):
     with patch('rhodecode.model.db.Repository') as repo:
         repo.scm_instance().alias = alias
         repo.scm_instance().branches = {}
         with pytest.raises(KeyError):
             utils._get_ref_hash(repo, 'branch', branch_name)
Exemplo n.º 5
0
 def test_returns_hash_by_branch_name(self, alias, branch_name):
     with patch('rhodecode.model.db.Repository') as repo:
         repo.scm_instance().alias = alias
         repo.scm_instance().branches = {branch_name: self.commit_hash}
         result_hash = utils._get_ref_hash(repo, 'branch', branch_name)
         assert result_hash == self.commit_hash