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
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
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
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'
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()
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()
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
def participants(self): return IssueParticipant.gets_by_issue_id(self.issue_id)
def has_participated(self, user_id): return bool(IssueParticipant.get_by_issue_id_and_user_id( self.issue_id, user_id))
def delete_participant(self, user_id): p = IssueParticipant.get_by_issue_id_and_user_id(self.issue_id, user_id) if p: p.delete()
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)
def has_participated(self, user_id): return bool( IssueParticipant.get_by_issue_id_and_user_id( self.issue_id, user_id))
def delete_participant(self, user_id): p = IssueParticipant.get_by_issue_id_and_user_id( self.issue_id, user_id) if p: p.delete()
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)