From 691e01e9c147010b907caf05ede94463110a2666 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Sun, 27 Jun 2021 19:35:27 -0400 Subject: [PATCH] tests: Move telemetry_messenger_spy to infection_monkey/conftest.py --- .../unit_tests/infection_monkey/conftest.py | 17 +++++++++++++++++ .../ransomware/test_ransomware_payload.py | 15 --------------- 2 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 monkey/tests/unit_tests/infection_monkey/conftest.py diff --git a/monkey/tests/unit_tests/infection_monkey/conftest.py b/monkey/tests/unit_tests/infection_monkey/conftest.py new file mode 100644 index 000000000..533572f98 --- /dev/null +++ b/monkey/tests/unit_tests/infection_monkey/conftest.py @@ -0,0 +1,17 @@ +import pytest + +from infection_monkey.telemetry.i_telem import ITelem +from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger + + +class TelemetryMessengerSpy(ITelemetryMessenger): + def __init__(self): + self.telemetries = [] + + def send_telemetry(self, telemetry: ITelem): + self.telemetries.append(telemetry) + + +@pytest.fixture +def telemetry_messenger_spy(): + return TelemetryMessengerSpy() diff --git a/monkey/tests/unit_tests/infection_monkey/ransomware/test_ransomware_payload.py b/monkey/tests/unit_tests/infection_monkey/ransomware/test_ransomware_payload.py index 86fb5c336..f26463ed1 100644 --- a/monkey/tests/unit_tests/infection_monkey/ransomware/test_ransomware_payload.py +++ b/monkey/tests/unit_tests/infection_monkey/ransomware/test_ransomware_payload.py @@ -23,16 +23,6 @@ from tests.utils import hash_file, is_user_admin from infection_monkey.ransomware import ransomware_payload as ransomware_payload_module from infection_monkey.ransomware.ransomware_payload import EXTENSION, RansomewarePayload -from infection_monkey.telemetry.i_telem import ITelem -from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger - - -class TelemetryMessengerSpy(ITelemetryMessenger): - def __init__(self): - self.telemetries = [] - - def send_telemetry(self, telemetry: ITelem): - self.telemetries.append(telemetry) def with_extension(filename): @@ -46,11 +36,6 @@ def ransomware_payload_config(ransomware_target): } -@pytest.fixture -def telemetry_messenger_spy(): - return TelemetryMessengerSpy() - - @pytest.fixture def ransomware_payload(ransomware_payload_config, telemetry_messenger_spy): return RansomewarePayload(ransomware_payload_config, telemetry_messenger_spy)