Exemple #1
0
    def test_delete(self):
        p = IssueParticipant.add(1, 'test1')
        p = IssueParticipant.add(2, 'test1')
        p = IssueParticipant.add(3, 'test1')
        p = IssueParticipant.add(1, 'test2')

        p.delete()
        p = IssueParticipant.get_by_issue_id_and_user_id(1, 'test2')
        assert p is None
Exemple #2
0
 def gets_by_participated_user(cls, user_id, state='open'):
     ps = IssueParticipant.gets_by_user_id(user_id)
     issue_ids = [p.issue_id for p in ps]
     issues = Issue.get_cached_issues(issue_ids)
     issues_with_state = [issue for issue in issues
                          if (state == 'open') is (not issue.closer_id)]
     return issues_with_state
Exemple #3
0
 def gets_by_participated_user(cls, user_id, state='open'):
     ps = IssueParticipant.gets_by_user_id(user_id)
     issue_ids = [p.issue_id for p in ps]
     issues = Issue.get_cached_issues(issue_ids)
     issues_with_state = [
         issue for issue in issues
         if (state == 'open') is (not issue.closer_id)
     ]
     return issues_with_state
Exemple #4
0
    def test_get(self):
        p = IssueParticipant.add(1, 'test1')
        p = IssueParticipant.add(2, 'test1')
        p = IssueParticipant.add(3, 'test1')
        p = IssueParticipant.add(1, 'test2')

        ps = IssueParticipant.gets_by_issue_id(1)
        assert all([isinstance(_p, IssueParticipant) for _p in ps])
        assert len(ps) == 2

        ps = IssueParticipant.gets_by_user_id('test1')
        assert all([isinstance(_p, IssueParticipant) for _p in ps])
        assert len(ps) == 3

        p = IssueParticipant.get_by_issue_id_and_user_id(1, 'test1')
        assert isinstance(p, IssueParticipant)
        assert p.issue_id == 1
        assert p.user_id == 'test1'
Exemple #5
0
    def ttest_get(self):  # FIXME
        p1 = IssueParticipant.add(1, 'test1')
        p2 = IssueParticipant.add(2, 'test1')
        p3 = IssueParticipant.add(3, 'test1')
        p4 = IssueParticipant.add(1, 'test2')

        ps = IssueParticipant.gets_by_issue_id(1)
        assert all([isinstance(_p, IssueParticipant) for _p in ps])
        assert len(ps) == 2

        ps = IssueParticipant.gets_by_user_id('test1')
        assert all([isinstance(_p, IssueParticipant) for _p in ps])
        assert len(ps) == 3

        p = IssueParticipant.get_by_issue_id_and_user_id(1, 'test1')
        assert isinstance(p, IssueParticipant)
        assert p.issue_id == 1
        assert p.user_id == 'test1'
        for p in [p1, p2, p3, p4]:
            p.delete()
Exemple #6
0
 def test_add(self):
     p = IssueParticipant.add(1, 'test1')
     assert isinstance(p, IssueParticipant)
     assert p.issue_id == 1
     assert p.user_id == 'test1'
     p.delete()
Exemple #7
0
    def test_delete(self):
        p = IssueParticipant.add(1, 'test2')

        p.delete()
        p = IssueParticipant.get_by_issue_id_and_user_id(1, 'test2')
        assert p is None
Exemple #8
0
 def participants(self):
     return IssueParticipant.gets_by_issue_id(self.issue_id)
Exemple #9
0
 def has_participated(self, user_id):
     return bool(IssueParticipant.get_by_issue_id_and_user_id(
         self.issue_id, user_id))
Exemple #10
0
 def delete_participant(self, user_id):
     p = IssueParticipant.get_by_issue_id_and_user_id(self.issue_id,
                                                      user_id)
     if p:
         p.delete()
Exemple #11
0
 def add_participant(self, user_id):
     p = IssueParticipant.get_by_issue_id_and_user_id(self.issue_id,
                                                      user_id)
     if not p:
         IssueParticipant.add(self.issue_id, user_id)
Exemple #12
0
 def participants(self):
     return IssueParticipant.gets_by_issue_id(self.issue_id)
Exemple #13
0
 def has_participated(self, user_id):
     return bool(
         IssueParticipant.get_by_issue_id_and_user_id(
             self.issue_id, user_id))
Exemple #14
0
 def delete_participant(self, user_id):
     p = IssueParticipant.get_by_issue_id_and_user_id(
         self.issue_id, user_id)
     if p:
         p.delete()
Exemple #15
0
 def add_participant(self, user_id):
     p = IssueParticipant.get_by_issue_id_and_user_id(
         self.issue_id, user_id)
     if not p:
         IssueParticipant.add(self.issue_id, user_id)