@pytest.mark.parametrize('benign', ['', 'from os import path'])
def test_scan_benign_contents(db_session, monkeypatch, benign):
    monkeypatch.setattr(c, 'fetch_url_content', pretend.call_recorder((lambda *a: pretend.stub())))
    monkeypatch.setattr(c, 'extract_file_content', pretend.call_recorder((lambda *a: (b'this is a benign string\n' + benign.encode('utf-8')))))
    MalwareCheckFactory.create(name='SetupPatternCheck', state=MalwareCheckState.Enabled)
    check = c.SetupPatternCheck(db_session)
    file = FileFactory.create(packagetype='sdist')
    check.scan(obj=file, file_url=pretend.stub())
    assert (len(check._verdicts) == 1)
    assert (check._verdicts[0].check_id == check.id)
    assert (check._verdicts[0].file_id == file.id)
    assert (check._verdicts[0].classification == VerdictClassification.Benign)
    assert (check._verdicts[0].confidence == VerdictConfidence.Low)
    assert (check._verdicts[0].message == 'No malicious patterns found in setup.py')
@pytest.mark.parametrize('benign', [, 'from os import path'])
def test_scan_benign_contents(db_session, monkeypatch, benign):
    monkeypatch.setattr(c, 'fetch_url_content', pretend.call_recorder((lambda *a: pretend.stub())))
    monkeypatch.setattr(c, 'extract_file_content', pretend.call_recorder((lambda *a: (b'this is a benign string\n' + benign.encode('utf-8')))))
    MalwareCheckFactory.create(name='SetupPatternCheck', state=MalwareCheckState.Enabled)
    check = c.SetupPatternCheck(db_session)
    file = FileFactory.create(packagetype='sdist')
    check.scan(obj=file, file_url=pretend.stub())
    assert (len(check._verdicts) == 1)
    assert (check._verdicts[0].check_id == check.id)
    assert (check._verdicts[0].file_id == file.id)
    assert (check._verdicts[0].classification == VerdictClassification.Benign)
    assert (check._verdicts[0].confidence == VerdictConfidence.Low)
    assert (check._verdicts[0].message == 'No malicious patterns found in setup.py')