Tests: Set autouse=False for patch_report_service fixture

This commit is contained in:
Mike Salvatore 2021-07-12 12:08:31 -04:00
parent e4cd06d8c3
commit c7d655ac7d
1 changed files with 11 additions and 11 deletions

View File

@ -3,6 +3,9 @@ import pytest
from monkey_island.cc.services.ransomware import ransomware_report
from monkey_island.cc.services.reporting.report import ReportService
@pytest.fixture
def patch_report_service_for_stats(monkeypatch):
TEST_SCANNED_RESULTS = [{}, {}, {}, {}]
TEST_EXPLOITED_RESULTS = [
{"exploits": ["SSH Exploiter"]},
@ -10,26 +13,23 @@ TEST_EXPLOITED_RESULTS = [
{"exploits": ["WMI Exploiter"]},
]
@pytest.fixture(scope="function", autouse=True)
def patch_report_service(monkeypatch):
monkeypatch.setattr(ReportService, "get_scanned", lambda: TEST_SCANNED_RESULTS)
monkeypatch.setattr(ReportService, "get_exploited", lambda: TEST_EXPLOITED_RESULTS)
def test_get_propagation_stats__num_scanned():
def test_get_propagation_stats__num_scanned(patch_report_service_for_stats):
stats = ransomware_report.get_propagation_stats()
assert stats["num_scanned_nodes"] == 4
def test_get_propagation_stats__num_exploited():
def test_get_propagation_stats__num_exploited(patch_report_service_for_stats):
stats = ransomware_report.get_propagation_stats()
assert stats["num_exploited_nodes"] == 3
def test_get_propagation_stats__num_exploited_per_exploit():
def test_get_propagation_stats__num_exploited_per_exploit(patch_report_service_for_stats):
stats = ransomware_report.get_propagation_stats()
assert stats["num_exploited_per_exploit"]["SSH Exploiter"] == 2