From 6130479c386406b610024b390b2ac4a062305db9 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 20 Sep 2024 18:35:00 +0000 Subject: [PATCH] Updating Testing --- brewtils/config.py | 2 +- test/config_test.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/brewtils/config.py b/brewtils/config.py index bf89f187..f5a65726 100644 --- a/brewtils/config.py +++ b/brewtils/config.py @@ -156,7 +156,7 @@ def load_config( if "bg_url_prefix" in config: config.bg_url_prefix = normalize_url_prefix(config.bg_url_prefix) - if "max_concurrent" in config and config.max_concurrent < 0: + if "max_concurrent" not in config or config.max_concurrent < 0: config.max_concurrent = min(32, os.cpu_count() + 4) return config diff --git a/test/config_test.py b/test/config_test.py index 8e5051b8..a1bc1e57 100644 --- a/test/config_test.py +++ b/test/config_test.py @@ -38,6 +38,25 @@ def params(): } +class TestMaxConcurrent(object): + + def test_negative_max_concurrent(self, monkeypatch, params): + monkeypatch.setattr(os, "cpu_count", Mock(return_value=2)) + + cli_args = ["-max_concurrent", "-1"] + config = load_config(cli_args=cli_args) + + assert config["max_concurrent"] == 8 + + def test_positive_max_concurrent(self, monkeypatch, params): + monkeypatch.setattr(os, "cpu_count", Mock(return_value=2)) + + cli_args = ["-max_concurrent", "3"] + config = load_config(cli_args=cli_args) + + assert config["max_concurrent"] == 3 + + class TestGetConnectionInfo(object): def test_kwargs(self, params): assert params == get_connection_info(**params)