From bc7ef40044f1bba9ed277f23e3a8cf38f5fa8182 Mon Sep 17 00:00:00 2001 From: Mikhail Shchatko Date: Tue, 2 Nov 2021 20:54:59 +0300 Subject: SERVER-61169 Fix unittests --- .../task_generation/task_types/test_fuzzer_tasks.py | 21 +++++++++++++++++++++ .../task_types/test_multiversion_decorator.py | 12 ++++++++++++ .../tests/task_generation/test_gen_task_service.py | 20 ++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/buildscripts/tests/task_generation/task_types/test_fuzzer_tasks.py b/buildscripts/tests/task_generation/task_types/test_fuzzer_tasks.py index 89f5a8a3330..34c1d1eb3e5 100644 --- a/buildscripts/tests/task_generation/task_types/test_fuzzer_tasks.py +++ b/buildscripts/tests/task_generation/task_types/test_fuzzer_tasks.py @@ -2,9 +2,12 @@ import unittest +import inject + import buildscripts.task_generation.task_types.fuzzer_tasks as under_test # pylint: disable=missing-docstring,invalid-name,unused-argument,no-self-use,protected-access +from buildscripts.task_generation.resmoke_proxy import ResmokeProxyService def build_mock_fuzzer_params(jstestfuzz_vars="vars for jstestfuzz", npm_command="jstestfuzz"): @@ -55,6 +58,15 @@ class TestFuzzerGenTaskParams(unittest.TestCase): class TestGenerateTasks(unittest.TestCase): + def setUp(self) -> None: + def dependencies(binder: inject.Binder) -> None: + binder.bind(ResmokeProxyService, ResmokeProxyService()) + + inject.clear_and_configure(dependencies) + + def tearDown(self) -> None: + inject.clear() + def test_fuzzer_tasks_are_generated(self): mock_params = build_mock_fuzzer_params() fuzzer_service = under_test.FuzzerGenTaskService() @@ -66,6 +78,15 @@ class TestGenerateTasks(unittest.TestCase): class TestBuildFuzzerSubTask(unittest.TestCase): + def setUp(self) -> None: + def dependencies(binder: inject.Binder) -> None: + binder.bind(ResmokeProxyService, ResmokeProxyService()) + + inject.clear_and_configure(dependencies) + + def tearDown(self) -> None: + inject.clear() + def test_sub_task_should_be_built_correct_no_minimize_command(self): mock_params = build_mock_fuzzer_params(npm_command="jstestfuzz") fuzzer_service = under_test.FuzzerGenTaskService() diff --git a/buildscripts/tests/task_generation/task_types/test_multiversion_decorator.py b/buildscripts/tests/task_generation/task_types/test_multiversion_decorator.py index 6ada07a195b..6d4951e1b23 100644 --- a/buildscripts/tests/task_generation/task_types/test_multiversion_decorator.py +++ b/buildscripts/tests/task_generation/task_types/test_multiversion_decorator.py @@ -3,6 +3,9 @@ import unittest from unittest.mock import patch +import inject + +from buildscripts.task_generation.resmoke_proxy import ResmokeProxyService from buildscripts.task_generation.task_types import multiversion_decorator as under_test from buildscripts.task_generation.task_types.fuzzer_tasks import FuzzerGenTaskParams @@ -41,6 +44,15 @@ def build_mock_sub_tasks(): class TestDecorateFuzzerGenTask(unittest.TestCase): + def setUp(self) -> None: + def dependencies(binder: inject.Binder) -> None: + binder.bind(ResmokeProxyService, ResmokeProxyService()) + + inject.clear_and_configure(dependencies) + + def tearDown(self) -> None: + inject.clear() + def run_test(self, fixture_type): mock_params = build_mock_fuzzer_params() mock_sub_tasks = build_mock_sub_tasks() diff --git a/buildscripts/tests/task_generation/test_gen_task_service.py b/buildscripts/tests/task_generation/test_gen_task_service.py index dbbb62bf8c9..caf6027736e 100644 --- a/buildscripts/tests/task_generation/test_gen_task_service.py +++ b/buildscripts/tests/task_generation/test_gen_task_service.py @@ -3,9 +3,11 @@ import unittest from unittest.mock import MagicMock +import inject from shrub.v2 import BuildVariant import buildscripts.task_generation.gen_task_service as under_test +from buildscripts.task_generation.resmoke_proxy import ResmokeProxyService from buildscripts.task_generation.task_types.fuzzer_tasks import FuzzerGenTaskService # pylint: disable=missing-docstring,invalid-name,unused-argument,no-self-use,protected-access @@ -43,6 +45,15 @@ def build_mocked_service(): class TestGenerateFuzzerTask(unittest.TestCase): + def setUp(self) -> None: + def dependencies(binder: inject.Binder) -> None: + binder.bind(ResmokeProxyService, ResmokeProxyService()) + + inject.clear_and_configure(dependencies) + + def tearDown(self) -> None: + inject.clear() + def test_fuzzer_tasks_should_be_generated(self): mock_params = build_mock_fuzzer_params() build_variant = BuildVariant("mock build variant") @@ -74,6 +85,15 @@ class TestGenerateFuzzerTask(unittest.TestCase): class TestGetDistro(unittest.TestCase): + def setUp(self) -> None: + def dependencies(binder: inject.Binder) -> None: + binder.bind(ResmokeProxyService, ResmokeProxyService()) + + inject.clear_and_configure(dependencies) + + def tearDown(self) -> None: + inject.clear() + def test_default_distro_should_be_used_if_use_large_distro_not_set(self): service = build_mocked_service() -- cgit v1.2.1