Beispiel #1
0
 def setUp(self):
     TestCase.setUp(self)
     for name in ('testproject1', 'testproject2', 'testproject1_fork',
                  'testproject2_fork'):
         delete_project(name)
     _, self.proj1, _, self.proj1_fork = setup_repos(mkdtemp(),
                                                     'testproject1')
     _, self.proj2, _, self.proj2_fork = setup_repos(mkdtemp(),
                                                     'testproject2')
Beispiel #2
0
    def test_pr_stat(self):
        TestCase.setUp(self)
        _, self.proj1, _, self.proj1_fork = setup_repos(
            mkdtemp(), 'testproject1')
        _, self.proj2, _, self.proj2_fork = setup_repos(
            mkdtemp(), 'testproject2')
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 0
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 0
        assert len(pr_rs) - pr_open_count == 0

        pullreq1 = PullRequest.open(self.proj1_fork, 'master', self.proj1,
                                    'master')
        ticket1 = Ticket.add(self.proj1.id, 'title', 'content', 'testuser')
        pullreq1 = pullreq1.insert(ticket1.ticket_number)
        pullreq2 = PullRequest.open(self.proj2_fork, 'master', self.proj2,
                                    'master')
        ticket2 = Ticket.add(self.proj2.id, 'title', 'content', 'testuser')
        pullreq2 = pullreq2.insert(ticket2.ticket_number)
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 2
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 2
        assert len(pr_rs) - pr_open_count == 0

        ticket1.close("testuser")
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 2
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 1
        assert len(pr_rs) - pr_open_count == 1

        pr_comment_count = get_ticket_comment_count()
        assert (pr_comment_count) == 0
        ticket2.add_comment("comment1", "testuse1")
        ticket2.add_comment("comment2", "testuse2")
        pr_comment_count = get_ticket_comment_count()
        assert (pr_comment_count) == 2
Beispiel #3
0
    def test_pr_stat(self):
        TestCase.setUp(self)
        _, self.proj1, _, self.proj1_fork = setup_repos(
            mkdtemp(), 'testproject1')
        _, self.proj2, _, self.proj2_fork = setup_repos(
            mkdtemp(), 'testproject2')
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 0
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 0
        assert len(pr_rs) - pr_open_count == 0

        pullreq1 = PullRequest.open(
            self.proj1_fork, 'master', self.proj1, 'master')
        ticket1 = Ticket.add(self.proj1.id, 'title', 'content', 'testuser')
        pullreq1 = pullreq1.insert(ticket1.ticket_number)
        pullreq2 = PullRequest.open(
            self.proj2_fork, 'master', self.proj2, 'master')
        ticket2 = Ticket.add(self.proj2.id, 'title', 'content', 'testuser')
        pullreq2 = pullreq2.insert(ticket2.ticket_number)
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 2
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 2
        assert len(pr_rs) - pr_open_count == 0

        ticket1.close("testuser")
        pr_rs = get_all_ticket()
        assert len(pr_rs) == 2
        pr_open_count = len(filter(lambda x: x[1] is None, pr_rs))
        assert pr_open_count == 1
        assert len(pr_rs) - pr_open_count == 1

        pr_comment_count = get_ticket_comment_count()
        assert(pr_comment_count) == 0
        ticket2.add_comment("comment1", "testuse1")
        ticket2.add_comment("comment2", "testuse2")
        pr_comment_count = get_ticket_comment_count()
        assert(pr_comment_count) == 2
Beispiel #4
0
    def test_conflict_detection(self):
        """有冲突存在时,is_auto_mergable()应返回False"""
        with mkdtemp() as tmpdir:
            path, repo, fork_path, fork_repo = setup_repos(
                tmpdir, 'test_conflict_detection')

            # make conflict changes

            with clone(path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("asdf")

            with clone(fork_path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("fdsa")

            # submit a pull request

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            assert not pullreq.is_auto_mergable()
            # assure merge --abort
            assert not os.path.exists(os.path.join(path, 'MERGE_MODE'))
Beispiel #5
0
    def test_conflict_detection(self):
        """有冲突存在时,is_auto_mergable()应返回False"""
        with mkdtemp() as tmpdir:
            path, repo, fork_path, fork_repo = setup_repos(
                tmpdir, 'test_conflict_detection')

            # make conflict changes

            with clone(path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("asdf")

            with clone(fork_path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("fdsa")

            # submit a pull request

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            assert not pullreq.is_auto_mergable()
            # assure merge --abort
            assert not os.path.exists(os.path.join(path, 'MERGE_MODE'))
Beispiel #6
0
 def setUp(self):
     TestCase.setUp(self)
     _, self.proj1, _, self.proj1_fork = setup_repos(
         mkdtemp(), 'testproject1')
     _, self.proj2, _, self.proj2_fork = setup_repos(
         mkdtemp(), 'testproject2')
Beispiel #7
0
 def setUp(self):
     TestCase.setUp(self)
     _, self.proj1, _, self.proj1_fork = setup_repos(
         mkdtemp(), 'testproject1')
     _, self.proj2, _, self.proj2_fork = setup_repos(
         mkdtemp(), 'testproject2')