コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
ファイル: test_logger.py プロジェクト: pymedusa/SickRage
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
コード例 #4
0
ファイル: test_logger.py プロジェクト: 5l1v3r1/Medusa-2
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
コード例 #5
0
ファイル: test_logger.py プロジェクト: DazzFX/SickRage-1
def test_from_line(p):
    # Given
    line = p['line']
    expected = p['expected']

    # When
    actual = LogLine.from_line(line)

    # Then
    assert expected == describe_logline(actual)
コード例 #6
0
ファイル: test_logger.py プロジェクト: pymedusa/SickRage
def test_from_line(p):
    # Given
    line = p['line']
    expected = p['expected']

    # When
    actual = LogLine.from_line(line)

    # Then
    assert expected == describe_logline(actual)
コード例 #7
0
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
コード例 #8
0
ファイル: test_issue_submitter.py プロジェクト: Adz249/Medusa
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