def test_ignore_events_without_dates_on_last_methods(): # With the addition of timeline events, we have a lot # of missing keys that we would normally get from the # events endpoint. This test asserts that the historywrapper # filters those timeline events out when the necessary # keys are missing # iw.history.label_last_applied(u'needs_info') # iw.history.label_last_removed(u'needs_info') # iw.history.last_date_for_boilerplate(u'needs_info_base') # iw.history.last_date_for_boilerplate(u'issue_missing_data') events = [ [u'labeled', True, u'bcoca', u'needs_info'], [u'labeled', None, u'bcoca', u'needs_info'], [ u'comment', True, u'ansibot', u'foobar\n<!--- boilerplate: needs_info --->' ], [ u'comment', None, u'ansibot', u'foobar\n<!--- boilerplate: needs_info --->' ], [u'labeled', True, u'ansibot', u'needs_info'], [u'labeled', None, u'ansibot', u'needs_info'], [u'comment', True, u'jimi-c', u'unicorns are awesome'], [u'comment', None, u'jimi-c', u'unicorns are awesome'], [u'unlabeled', True, u'ansibot', u'needs_info'], [u'unlabeled', None, u'ansibot', u'needs_info'], ] iw = IssueWrapperMock() for event in events: if event[0] in [u'labeled', u'unlabeled']: levent = LabelEventMock(event[0], event[2], label=event[3]) if event[1] is None: levent._created_at = None iw._events.append(levent) if event[0] == u'comment': thiscomment = CommentMock(event[2], event[3]) if event[1] is None: thiscomment.date = None iw._comments.append(thiscomment) cachedir = tempfile.mkdtemp() hw = HistoryWrapper(iw, cachedir=cachedir, usecache=False) res = [] res.append(hw.label_last_applied(u'needs_info')) res.append(hw.label_last_removed(u'needs_info')) res.append(hw.last_date_for_boilerplate(u'needs_info')) res.append(hw.was_labeled(u'needs_info')) res.append(hw.was_unlabeled(u'needs_info')) assert not [x for x in res if x is None]
def test_ignore_events_without_dates_on_last_methods(): """With the addition of timeline events, we have a lot of missing keys that we would normally get from the events endpoint. This test asserts that the historywrapper filters those timeline events out when the necessary keys are missing.""" events = [ {'event': 'labeled', 'created_at': datetime.datetime.utcnow(), 'actor': 'bcoca', 'label': 'needs_info'}, {'event': 'labeled', 'created_at': datetime.datetime.utcnow(), 'actor': 'bcoca', 'label': 'needs_info'}, {'event': 'comment', 'created_at': datetime.datetime.utcnow(), 'actor': 'ansibot', 'body': 'foobar\n<!--- boilerplate: needs_info --->'}, {'event': 'comment', 'actor': 'ansibot', 'body': 'foobar\n<!--- boilerplate: needs_info --->'}, {'event': 'labeled', 'created_at': datetime.datetime.utcnow(), 'actor': 'ansibot', 'label': 'needs_info'}, {'event': 'labeled', 'actor': 'ansibot', 'label': 'needs_info'}, {'event': 'comment', 'created_at': datetime.datetime.utcnow(), 'actor': 'jimi-c', 'body': 'unicorns are awesome'}, {'event': 'comment', 'actor': 'jimi-c', 'body': 'unicorns are awesome'}, {'event': 'unlabeled', 'created_at': datetime.datetime.utcnow(), 'actor': 'ansibot', 'label': 'needs_info'}, {'event': 'unlabeled', 'actor': 'ansibot', 'label': 'needs_info'}, ] iw = IssueWrapperMock() for event in events: if event['event'] == 'comment': iw._comments.append(event) iw._events.append(event) cachedir = tempfile.mkdtemp() hw = HistoryWrapper(iw, cachedir=cachedir, usecache=False) hw.BOTNAMES = ['ansibot'] res = [] res.append(hw.label_last_applied('needs_info')) res.append(hw.label_last_removed('needs_info')) res.append(hw.last_date_for_boilerplate('needs_info')) res.append(hw.was_labeled('needs_info')) res.append(hw.was_unlabeled('needs_info')) assert not [x for x in res if x is None]