Example #1
0
    def test_max_concurrent_modules(self, mock_proc):
        """Test max_concurrent_modules."""
        mock_proc.cpu_count.return_value = 4
        obj = DeployEnvironment(environ={})

        assert obj.max_concurrent_modules == 4

        mock_proc.cpu_count.return_value = 62
        assert obj.max_concurrent_modules == 61

        obj.max_concurrent_modules = 12
        assert obj.max_concurrent_modules == 12
        assert obj.vars["RUNWAY_MAX_CONCURRENT_MODULES"] == 12
    def test_max_concurrent_modules(self, mocker: MockerFixture) -> None:
        """Test max_concurrent_modules."""
        mock_cpu_count = MagicMock(return_value=4)
        mocker.patch(f"{MODULE}.os.cpu_count", mock_cpu_count)
        obj = DeployEnvironment(environ={})

        assert obj.max_concurrent_modules == 4

        mock_cpu_count.return_value = 62
        assert obj.max_concurrent_modules == 61

        obj.max_concurrent_modules = 12
        assert obj.max_concurrent_modules == 12
        assert obj.vars["RUNWAY_MAX_CONCURRENT_MODULES"] == "12"