Changeset - 8171dfafb5db
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2013-02-18 22:56:54
marcin@python-works.com
some tests fixes for compare view
1 file changed with 42 insertions and 56 deletions:
0 comments (0 inline, 0 general)
rhodecode/tests/functional/test_compare.py
Show inline comments
 
@@ -62,14 +62,25 @@ def _commit_change(repo, filename, conte
 

	
 
class TestCompareController(TestController):
 

	
 
    def setUp(self):
 
        self.r1_id = None
 
        self.r2_id = None
 

	
 
    def tearDown(self):
 
        if self.r2_id:
 
            RepoModel().delete(self.r2_id)
 
        if self.r1_id:
 
            RepoModel().delete(self.r1_id)
 
        Session().commit()
 
        Session.remove()
 

	
 
    def test_compare_forks_on_branch_extra_commits_hg(self):
 
        self.log_user()
 

	
 
        repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
 
                                        description='diff-test',
 
                                        owner=TEST_USER_ADMIN_LOGIN)
 
        r1_id = repo1.repo_id
 
        Session().commit()
 
        self.r1_id = repo1.repo_id
 
        #commit something !
 
        cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
 
                             message='commit1', vcs_type='hg', parent=None, newfile=True)
 
@@ -77,7 +88,7 @@ class TestCompareController(TestControll
 
        #fork this repo
 
        repo2 = _fork_repo('one-fork', 'hg', parent='one')
 
        Session().commit()
 
        r2_id = repo2.repo_id
 
        self.r2_id = repo2.repo_id
 

	
 
        #add two extra commit into fork
 
        cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n',
 
@@ -89,8 +100,6 @@ class TestCompareController(TestControll
 
        rev1 = 'default'
 
        rev2 = 'default'
 

	
 

	
 
        try:
 
            response = self.app.get(url(controller='compare', action='index',
 
                                        repo_name=repo1.repo_name,
 
                                        org_ref_type="branch",
 
@@ -113,9 +122,6 @@ class TestCompareController(TestControll
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo1.repo_name, rev2, rev1, repo2.repo_name))
 
            #swap
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
 
        finally:
 
            RepoModel().delete(r2_id)
 
            RepoModel().delete(r1_id)
 

	
 
    def test_compare_forks_on_branch_extra_commits_origin_has_incomming_hg(self):
 
        self.log_user()
 
@@ -123,8 +129,9 @@ class TestCompareController(TestControll
 
        repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
 
                                        description='diff-test',
 
                                        owner=TEST_USER_ADMIN_LOGIN)
 
        r1_id = repo1.repo_id
 
        Session().commit()
 
        self.r1_id = repo1.repo_id
 

	
 
        #commit something !
 
        cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
 
                             message='commit1', vcs_type='hg', parent=None, newfile=True)
 
@@ -132,13 +139,12 @@ class TestCompareController(TestControll
 
        #fork this repo
 
        repo2 = _fork_repo('one-fork', 'hg', parent='one')
 
        Session().commit()
 
        self.r2_id = repo2.repo_id
 

	
 
        #now commit something to origin repo
 
        cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n',
 
                                  message='commit2', vcs_type='hg', parent=cs0, newfile=True)
 

	
 
        r2_id = repo2.repo_id
 

	
 
        #add two extra commit into fork
 
        cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n',
 
                             message='commit2', vcs_type='hg', parent=cs0)
 
@@ -149,7 +155,6 @@ class TestCompareController(TestControll
 
        rev1 = 'default'
 
        rev2 = 'default'
 

	
 
        try:
 
            response = self.app.get(url(controller='compare', action='index',
 
                                        repo_name=repo1.repo_name,
 
                                        org_ref_type="branch",
 
@@ -171,9 +176,6 @@ class TestCompareController(TestControll
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo1.repo_name, rev2, rev1, repo2.repo_name))
 
            #swap
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
 
        finally:
 
            RepoModel().delete(r2_id)
 
            RepoModel().delete(r1_id)
 

	
 
    def test_compare_cherry_pick_changesets_from_bottom(self):
 
        """
 
@@ -194,8 +196,9 @@ class TestCompareController(TestControll
 
        repo1 = RepoModel().create_repo(repo_name='repo1', repo_type='hg',
 
                                        description='diff-test',
 
                                        owner=TEST_USER_ADMIN_LOGIN)
 
        r1_id = repo1.repo_id
 
        Session().commit()
 
        self.r1_id = repo1.repo_id
 

	
 
        #commit something !
 
        cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
 
                             message='commit1', vcs_type='hg', parent=None,
 
@@ -205,7 +208,7 @@ class TestCompareController(TestControll
 
        #fork this repo
 
        repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1')
 
        Session().commit()
 
        r2_id = repo1.repo_id
 
        self.r2_id = repo2.repo_id
 
        #now make cs3-6
 
        cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n',
 
                             message='commit3', vcs_type='hg', parent=cs2)
 
@@ -219,7 +222,6 @@ class TestCompareController(TestControll
 
        rev1 = 'tip'
 
        rev2 = 'tip'
 

	
 
        try:
 
            response = self.app.get(url(controller='compare', action='index',
 
                                        repo_name=repo2.repo_name,
 
                                        org_ref_type="tag",
 
@@ -245,9 +247,6 @@ class TestCompareController(TestControll
 
            response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
 
            #swap
 
            response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo1.repo_name, rev1, rev2, repo2.repo_name))
 
        finally:
 
            RepoModel().delete(r2_id)
 
            RepoModel().delete(r1_id)
 

	
 
    def test_compare_cherry_pick_changesets_from_top(self):
 
        """
 
@@ -264,12 +263,12 @@ class TestCompareController(TestControll
 
        """
 
        #make repo1, and cs1+cs2
 
        self.log_user()
 

	
 
        repo1 = RepoModel().create_repo(repo_name='repo1', repo_type='hg',
 
                                        description='diff-test',
 
                                        owner=TEST_USER_ADMIN_LOGIN)
 
        r1_id = repo1.repo_id
 
        Session().commit()
 
        self.r1_id = repo1.repo_id
 

	
 
        #commit something !
 
        cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
 
                             message='commit1', vcs_type='hg', parent=None,
 
@@ -279,7 +278,7 @@ class TestCompareController(TestControll
 
        #fork this repo
 
        repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1')
 
        Session().commit()
 
        r2_id = repo1.repo_id
 
        self.r2_id = repo1.repo_id
 
        #now make cs3-6
 
        cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n',
 
                             message='commit3', vcs_type='hg', parent=cs2)
 
@@ -289,11 +288,9 @@ class TestCompareController(TestControll
 
                             message='commit5', vcs_type='hg', parent=cs4)
 
        cs6 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\nline6\n',
 
                             message='commit6', vcs_type='hg', parent=cs5)
 

	
 
        rev1 = 'tip'
 
        rev2 = 'tip'
 

	
 
        try:
 
            response = self.app.get(url(controller='compare', action='index',
 
                                        repo_name=repo2.repo_name,
 
                                        org_ref_type="tag",
 
@@ -320,9 +317,6 @@ class TestCompareController(TestControll
 
            response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
 
            #swap
 
            response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo1.repo_name, rev1, rev2, repo2.repo_name))
 
        finally:
 
            RepoModel().delete(r2_id)
 
            RepoModel().delete(r1_id)
 

	
 
    def test_compare_cherry_pick_changeset_mixed_branches(self):
 
        """
 
@@ -339,7 +333,6 @@ class TestCompareController(TestControll
 
        rev1 = '56349e29c2af'
 
        rev2 = '7d4bc8ec6be5'
 

	
 
        try:
 
            response = self.app.get(url(controller='compare', action='index',
 
                                        repo_name=HG_REPO,
 
                                        org_ref_type="rev",
 
@@ -351,16 +344,14 @@ class TestCompareController(TestControll
 
            response.mustcontain('%s@%s -&gt; %s@%s' % (HG_REPO, rev1, HG_FORK, rev2))
 
            ## outgoing changesets between those revisions
 

	
 
            response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO))
 
            response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO))
 
            response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2))
 
        response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_FORK))
 
        response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_FORK))
 
        response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_FORK, rev2))
 

	
 
            ## files
 
            response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2))
 
            response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2))
 
            response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2))
 
        finally:
 
            RepoModel().delete(HG_FORK)
 
        response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK))
 
        response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK))
 
        response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK))
 

	
 
    def test_org_repo_new_commits_after_forking_simple_diff(self):
 
        self.log_user()
 
@@ -370,7 +361,7 @@ class TestCompareController(TestControll
 
                                        owner=TEST_USER_ADMIN_LOGIN)
 

	
 
        Session().commit()
 
        r1_id = repo1.repo_id
 
        self.r1_id = repo1.repo_id
 
        r1_name = repo1.repo_name
 

	
 
        #commit something initially !
 
@@ -391,7 +382,7 @@ class TestCompareController(TestControll
 
                                owner=TEST_USER_ADMIN_LOGIN, fork_of='one')
 
        Session().commit()
 
        self.assertEqual(repo2.scm_instance.revisions, [cs0.raw_id])
 
        r2_id = repo2.repo_id
 
        self.r2_id = repo2.repo_id
 
        r2_name = repo2.repo_name
 

	
 
        #make 3 new commits in fork
 
@@ -424,24 +415,25 @@ class TestCompareController(TestControll
 
        rev1 = 'default'
 
        rev2 = 'default'
 

	
 
        try:
 
            response = self.app.get(url(controller='compare', action='index',
 
                                        repo_name=r2_name,
 
                                        org_ref_type="branch",
 
                                        org_ref=rev1,
 
                                        other_ref_type="branch",
 
                                        other_ref=rev2,
 
                                        repo=r1_name,
 
                                    other_repo=r1_name,
 
                                        ))
 
            #response.mustcontain('%s@%s -&gt; %s@%s' % (r2_name, rev1, r1_name, rev2))
 
        response.mustcontain('%s@%s -&gt; %s@%s' % (r2_name, rev1, r1_name, rev2))
 
        response.mustcontain('No files')
 
        response.mustcontain('No changesets')
 

	
 
            #add new commit into parent !
 
            cs0 = ScmModel().create_node(
 
                repo=repo1.scm_instance, repo_name=r1_name,
 
                cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN,
 
                author=TEST_USER_ADMIN_LOGIN,
 
                message='commit2',
 
                content='line1',
 
            message='commit2-parent',
 
            content='line1-added-after-fork',
 
                f_path='file2'
 
            )
 
            #compare !
 
@@ -453,17 +445,11 @@ class TestCompareController(TestControll
 
                                        org_ref=rev1,
 
                                        other_ref_type="branch",
 
                                        other_ref=rev2,
 
                                        repo=r1_name,
 
                                        bundle=False
 
                                    other_repo=r1_name,
 
                                        ))
 

	
 
            response.mustcontain('%s@%s -&gt; %s@%s' % (r2_name, rev1, r1_name, rev2))
 
            response.mustcontain("""file1-line1-from-fork""")
 
            response.mustcontain("""file2-line1-from-fork""")
 
            response.mustcontain("""file3-line1-from-fork""")
 
            self.assertFalse("""<a href="#">file2</a>""" in response.body)  # new commit from parent
 
            self.assertFalse("""line1-from-new-parent"""  in response.body)
 
        finally:
 
            RepoModel().delete(r2_id)
 
            RepoModel().delete(r1_id)
 
            Session()
 

	
 
        response.mustcontain("""commit2-parent""")
 
        response.mustcontain("""1 file changed with 1 insertions and 0 deletions""")
 
        response.mustcontain("""line1-added-after-fork""")
0 comments (0 inline, 0 general)