def test_submit_issues(monkeypatch, github, github_repo, create_github_issue, p): # Given message = p['input'] logline = LogLine.from_line('2016-08-25 20:12:03 ERROR SEARCHQUEUE-MANUAL-290853 :: [ProviderName] :: [d4ea5af] {message}'.format(message=message)) ErrorViewer.add(logline) create_comment = Mock() similar_issues = dict() locked = p.get('locked', False) similar = p.get('similar') if similar: similar_issue = create_github_issue(similar[1], number=similar[0], locked=locked) monkeypatch.setattr(similar_issue, 'create_comment', create_comment) similar_issues[logline.key] = similar_issue monkeypatch.setattr(github_repo, 'create_issue', create_github_issue) expected = p['expected'] # When actual = sut.submit_issues(github, github_repo, [logline], similar_issues) # Then assert [expected] == actual if expected[1] is not None: assert logline not in ErrorViewer.errors if similar: assert create_comment.called assert message in create_comment.call_args[0][0] else: assert not create_comment.called else: assert logline in ErrorViewer.errors assert not create_comment.called
def test_submit_issues(monkeypatch, github, github_repo, create_github_issue, p): # Given message = p['input'] logline = LogLine.from_line('2016-08-25 20:12:03 ERROR SEARCHQUEUE-MANUAL-290853 :: [ProviderName] :: [d4ea5af] {message}'.format(message=message)) ErrorViewer.add(logline) create_comment = Mock() similar_issues = dict() locked = p.get('locked', False) similar = p.get('similar') if similar: similar_issue = create_github_issue(similar[1], number=similar[0], locked=locked) monkeypatch.setattr(similar_issue, 'create_comment', create_comment) similar_issues[logline.key] = similar_issue monkeypatch.setattr(github_repo, 'create_issue', create_github_issue) expected = p['expected'] # When actual = sut.submit_issues(github, github_repo, [logline], similar_issues) # Then assert [expected] == actual if expected[1] is not None: assert logline not in ErrorViewer.errors if similar: assert create_comment.called assert message in create_comment.call_args[0][0] else: assert not create_comment.called else: assert logline in ErrorViewer.errors assert not create_comment.called
def test_filter_logline(p): # Given logline = LogLine.from_line(p['line']) # When actual = sut.filter_logline(logline, min_level=p.get('min_level'), thread_name=p.get('thread_name'), search_query=p.get('search_query')) # Then assert p['expected'] == actual
def test_filter_logline(p): # Given logline = LogLine.from_line(p['line']) # When actual = sut.filter_logline(logline, min_level=p.get('min_level'), thread_name=p.get('thread_name'), search_query=p.get('search_query')) # Then assert p['expected'] == actual
def test_from_line(p): # Given line = p['line'] expected = p['expected'] # When actual = LogLine.from_line(line) # Then assert expected == describe_logline(actual)
def test_from_line(p): # Given line = p['line'] expected = p['expected'] # When actual = LogLine.from_line(line) # Then assert expected == describe_logline(actual)
def test_create_gist__logline_not_found(github): """If the log line is very old and can't be found in the logs, a gist can not be created.""" # Given logline = LogLine.from_line('2016-08-24 07:42:39 ERROR CHECKVERSION :: [7d1534c] Very Old Log Message') assert logline is not None # When actual = sut.create_gist(github, logline) # Then assert actual is None
def test_create_gist__logline_not_found(github): """If the log line is very old and can't be found in the logs, a gist can not be created.""" # Given logline = LogLine.from_line( '2016-08-24 07:42:39 ERROR CHECKVERSION :: [7d1534c] Very Old Log Message' ) assert logline is not None # When actual = sut.create_gist(github, logline) # Then assert actual is None