コード例 #1
0
ファイル: test_search.py プロジェクト: leeccong/code
    def test_single_project(self):
        skip_test()
        u_to = User("admin")
        u_from = User("testuser")
        to_proj = self._prj("test", "admin")
        self._add(to_proj, u_to, "README.md", "hi")
        from_proj = self._prj("testuser/test", "testuser", to_proj.id)
        self._add(from_proj, u_from, "README.md", "hello")
        pullreq = PullRequest.open(from_proj, "master", to_proj, "master")
        ticket = Ticket(None, None, to_proj.id, "title", "desc", "testuser",
                        None, None)
        pullreq = add_pull(ticket, pullreq, u_from)

        iss = ProjectIssue.add(title='title1', description='desc1',
                               creator='owner', project=to_proj.id)
        IssuePRSearch.index_a_project(to_proj)
        res = IssueSearch.search_a_phrase('title1', to_proj.id)
        res = SearchEngine.decode(res, ('issue_id',))
        res = [id for id, in res]
        assert len(res) == 1
        assert res[0] == iss.id
        res = PullRequestSearch.search_a_phrase('title', to_proj.id)
        res = SearchEngine.decode(res, ('issue_id',))
        res = [id for id, in res]
        assert len(res) == 1
コード例 #2
0
ファイル: pull.py プロジェクト: 000fan000/code
 def search(self, request):
     key_word = request.get_form_var('q')
     if not key_word:
         return self._index(request)
     status = request.get_form_var('status')
     user = request.user
     page = request.get_form_var('page', 1)
     project = self.project
     tickets = []
     ticket_len = Ticket.get_count_by_proj_id(project.id)
     search_result = PullRequestSearch.search_a_phrase(
         key_word, project.id, size=ticket_len)
     if search_result and not search_result.get('error'):
         ticket_ids = [id for id, in SearchEngine.decode(
             search_result, ['ticket_id'])]
         tickets = Ticket.gets_by_projectid_and_ticketnumbers(
             project.id, ticket_ids)
         if status == "closed":
             tickets = [t for t in tickets if t.closed]
         else:
             tickets = [t for t in tickets if not t.closed]
     ticket_total_len = len(tickets)
     limit = TICKETS_COUNT_PER_PAGE
     start = TICKETS_COUNT_PER_PAGE * (int(page) - 1)
     tickets = tickets[start:start + limit]
     n_pages = (ticket_total_len - 1) / TICKETS_COUNT_PER_PAGE + 1
     if status == "closed":
         is_closed_tab = True
     else:
         is_closed_tab = False
     open_tab_link = self.open_tab_link
     close_tab_link = self.close_tab_link
     return st('/pull/pulls.html', **locals())
コード例 #3
0
ファイル: pull.py プロジェクト: jackfrued/code-1
 def search(self, request):
     key_word = request.get_form_var('q')
     if not key_word:
         return self._index(request)
     status = request.get_form_var('status')
     user = request.user
     page = request.get_form_var('page', 1)
     project = self.project
     tickets = []
     ticket_len = Ticket.get_count_by_proj_id(project.id)
     search_result = PullRequestSearch.search_a_phrase(key_word,
                                                       project.id,
                                                       size=ticket_len)
     if search_result and not search_result.get('error'):
         ticket_ids = [
             id for id, in SearchEngine.decode(search_result, ['ticket_id'])
         ]
         tickets = Ticket.gets_by_projectid_and_ticketnumbers(
             project.id, ticket_ids)
         if status == "closed":
             tickets = [t for t in tickets if t.closed]
         else:
             tickets = [t for t in tickets if not t.closed]
     ticket_total_len = len(tickets)
     limit = TICKETS_COUNT_PER_PAGE
     start = TICKETS_COUNT_PER_PAGE * (int(page) - 1)
     tickets = tickets[start:start + limit]
     n_pages = (ticket_total_len - 1) / TICKETS_COUNT_PER_PAGE + 1
     if status == "closed":
         is_closed_tab = True
     else:
         is_closed_tab = False
     open_tab_link = self.open_tab_link
     close_tab_link = self.close_tab_link
     return st('/pull/pulls.html', **locals())
コード例 #4
0
    def test_single_project(self):
        skip_test()
        u_to = User("admin")
        u_from = User("testuser")
        to_proj = self._prj("test", "admin")
        self._add(to_proj, u_to, "README.md", "hi")
        from_proj = self._prj("testuser/test", "testuser", to_proj.id)
        self._add(from_proj, u_from, "README.md", "hello")
        pullreq = PullRequest.open(from_proj, "master", to_proj, "master")
        ticket = Ticket(None, None, to_proj.id, "title", "desc", "testuser",
                        None, None)
        pullreq = add_pull(ticket, pullreq, u_from)

        iss = ProjectIssue.add(title='title1',
                               description='desc1',
                               creator='owner',
                               project=to_proj.id)
        IssuePRSearch.index_a_project(to_proj)
        res = IssueSearch.search_a_phrase('title1', to_proj.id)
        res = SearchEngine.decode(res, ('issue_id', ))
        res = [id for id, in res]
        assert len(res) == 1
        assert res[0] == iss.id
        res = PullRequestSearch.search_a_phrase('title', to_proj.id)
        res = SearchEngine.decode(res, ('issue_id', ))
        res = [id for id, in res]
        assert len(res) == 1
コード例 #5
0
ファイル: test_search.py プロジェクト: leeccong/code
 def test_single_project(self):
     skip_test()
     u_to = User("admin")
     u_from = User("testuser")
     to_proj = self._prj("test", "admin")
     self._add(to_proj, u_to, "README.md", "hi")
     from_proj = self._prj("testuser/test", "testuser", to_proj.id)
     self._add(from_proj, u_from, "README.md", "hello")
     pullreq = PullRequest.open(from_proj, "master", to_proj, "master")
     ticket = Ticket(None, None, to_proj.id, "title", "desc", "testuser",
                     None, None)
     pullreq = add_pull(ticket, pullreq, u_from)
     ticket = pullreq.ticket
     PullRequestSearch.index_a_project_pr(to_proj)
     res = PullRequestSearch.search_a_phrase('title', to_proj.id)
     res = SearchEngine.decode(res, ('to_proj_id',))
     res = [id for id, in res]
     assert len(res) == 1
コード例 #6
0
 def test_single_project(self):
     skip_test()
     u_to = User("admin")
     u_from = User("testuser")
     to_proj = self._prj("test", "admin")
     self._add(to_proj, u_to, "README.md", "hi")
     from_proj = self._prj("testuser/test", "testuser", to_proj.id)
     self._add(from_proj, u_from, "README.md", "hello")
     pullreq = PullRequest.open(from_proj, "master", to_proj, "master")
     ticket = Ticket(None, None, to_proj.id, "title", "desc", "testuser",
                     None, None)
     pullreq = add_pull(ticket, pullreq, u_from)
     ticket = pullreq.ticket
     PullRequestSearch.index_a_project_pr(to_proj)
     res = PullRequestSearch.search_a_phrase('title', to_proj.id)
     res = SearchEngine.decode(res, ('to_proj_id', ))
     res = [id for id, in res]
     assert len(res) == 1