From cec8341b172baddc3e075f17bd62ff006870896a Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 23 Jun 2021 15:38:27 +0530 Subject: [PATCH] tests: Add unit tests for ransomware telem --- .../telemetry/test_ransomware_telem.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 monkey/tests/unit_tests/infection_monkey/telemetry/test_ransomware_telem.py diff --git a/monkey/tests/unit_tests/infection_monkey/telemetry/test_ransomware_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/test_ransomware_telem.py new file mode 100644 index 000000000..4994c9287 --- /dev/null +++ b/monkey/tests/unit_tests/infection_monkey/telemetry/test_ransomware_telem.py @@ -0,0 +1,20 @@ +import json + +import pytest + +from infection_monkey.telemetry.ransomware_telem import RansomwareTelem + +ATTEMPTS = [("", "")] + + +@pytest.fixture +def ransomware_telem_test_instance(): + return RansomwareTelem(ATTEMPTS) + + +def test_ransomware_telem_send(ransomware_telem_test_instance, spy_send_telemetry): + ransomware_telem_test_instance.send() + expected_data = {"ransomware_attempts": ATTEMPTS} + expected_data = json.dumps(expected_data, cls=ransomware_telem_test_instance.json_encoder) + assert spy_send_telemetry.data == expected_data + assert spy_send_telemetry.telem_category == "ransomware"