Beispiel #1
0
 def index_a_project_issue(cls, project):
     issues = ProjectIssue._get_issues_by_project_id(project.id)
     for issue in issues:
         data = issue.as_dict()
         if data:
             serial = "%s_%s" % (project.index_name, issue.number)
             cls.index_an_object(serial, data)
Beispiel #2
0
    def test_get_issue(self):
        p = ProjectIssue.add('test', 'test description', 'test', project=1)
        r = ProjectIssue.get(p.project_id, issue_id=p.issue_id)
        assert isinstance(r, ProjectIssue)
        assert r.project_id == 1

        r = ProjectIssue.get(p.project_id, number=p.number)
        assert isinstance(r, ProjectIssue)
        assert r.project_id == 1

        r = Issue.get_cached_issue(p.issue_id)
        assert isinstance(r, ProjectIssue)
        assert r.title == 'test'
        assert r.description == 'test description'
        assert r.project_id == 1

        p2 = ProjectIssue.add(
            'test2', 'test2 description', 'test', project=1,
            assignee='assignee')
        p3 = ProjectIssue.add(
            'test3', 'test3 description', 'test', project=1,
            assignee='assignee')
        p4 = ProjectIssue.add(
            'test4', 'test4 description', 'test', project=1, assignee='test')
        p5 = ProjectIssue.add(
            'test5', 'test5 description', 'test1', project=2, assignee='test')

        rs = ProjectIssue._gets_by_project_id(1)
        assert len(rs) == 4

        rs = ProjectIssue._get_issues_by_project_id(1)
        assert all([isinstance(i, ProjectIssue) for i in rs])
        assert len(rs) == 4

        rs = ProjectIssue.gets_by_assignee_id(1, 'assignee')
        assert all([isinstance(i, ProjectIssue) for i in rs])
        assert len(rs) == 2

        rs = ProjectIssue.gets_by_creator_id(1, 'test')
        assert all([isinstance(i, ProjectIssue) for i in rs])
        assert len(rs) == 4

        for p in [p, p2, p3, p4, p5]:
            p.delete()