From eeba0e0616a77e6a47c59c0282344effdf37511e Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 22 Jun 2022 10:59:46 -0400 Subject: [PATCH] UT: Add tests for should_propagate --- .../utils/test_propagation.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 monkey/tests/unit_tests/infection_monkey/utils/test_propagation.py diff --git a/monkey/tests/unit_tests/infection_monkey/utils/test_propagation.py b/monkey/tests/unit_tests/infection_monkey/utils/test_propagation.py new file mode 100644 index 000000000..37f7194a6 --- /dev/null +++ b/monkey/tests/unit_tests/infection_monkey/utils/test_propagation.py @@ -0,0 +1,32 @@ +from infection_monkey.utils.propagation import should_propagate + + +def get_config(max_depth): + return {"config": {"depth": max_depth}} + + +def test_should_propagate_current_less_than_max(): + max_depth = 2 + current_depth = 1 + + config = get_config(max_depth) + + assert should_propagate(config, current_depth) is True + + +def test_should_propagate_current_greater_than_max(): + max_depth = 2 + current_depth = 3 + + config = get_config(max_depth) + + assert should_propagate(config, current_depth) is False + + +def test_should_propagate_current_equal_to_max(): + max_depth = 2 + current_depth = max_depth + + config = get_config(max_depth) + + assert should_propagate(config, current_depth) is False