|
| 1 | +from collections import defaultdict |
1 | 2 | import os |
2 | 3 | from pathlib import Path |
3 | 4 | from typing import Annotated, Type |
4 | 5 |
|
5 | 6 | import pytest |
6 | 7 |
|
7 | | -from omnipy.api.enums import (ConfigOutputStorageProtocolOptions, |
| 8 | +from omnipy.api.enums import (BackoffStrategy, |
| 9 | + ConfigOutputStorageProtocolOptions, |
8 | 10 | ConfigPersistOutputsOptions, |
9 | 11 | ConfigRestoreOutputsOptions, |
10 | 12 | EngineChoice) |
@@ -59,6 +61,12 @@ def _assert_runtime_config_default(config: IsRuntimeConfig, dir_path: Path): |
59 | 61 | assert config.data.dynamically_convert_elements_to_models is False |
60 | 62 | assert config.data.terminal_size_columns == 80 |
61 | 63 | assert config.data.terminal_size_lines == 24 |
| 64 | + assert config.data.http_defaults.requests_per_time_period == 60 |
| 65 | + assert config.data.http_defaults.time_period_in_secs == 60 |
| 66 | + assert config.data.http_defaults.retry_http_statuses == (408, 425, 429, 500, 502, 503, 504) |
| 67 | + assert config.data.http_defaults.retry_attempts == 5 |
| 68 | + assert config.data.http_defaults.retry_backoff_strategy == BackoffStrategy.EXPONENTIAL |
| 69 | + assert isinstance(config.data.http_config_for_url_prefix, defaultdict) |
62 | 70 | assert config.engine == EngineChoice.LOCAL |
63 | 71 | assert config.prefect.use_cached_results is False |
64 | 72 |
|
@@ -104,6 +112,15 @@ def test_default_runtime(runtime: Annotated[IsRuntime, pytest.fixture], |
104 | 112 | _assert_runtime_objects_default(runtime.objects) |
105 | 113 |
|
106 | 114 |
|
| 115 | +def test_data_config_http_config_for_url_prefix_default( |
| 116 | + runtime: Annotated[IsRuntime, pytest.fixture]) -> None: |
| 117 | + assert runtime.config.data.http_config_for_url_prefix['http://myserver.com']\ |
| 118 | + .requests_per_time_period == 60 |
| 119 | + runtime.config.data.http_defaults.requests_per_time_period = 30 |
| 120 | + assert runtime.config.data.http_config_for_url_prefix['http://myserver.com']\ |
| 121 | + .requests_per_time_period == 60 |
| 122 | + |
| 123 | + |
107 | 124 | def test_runtime_config_after_data_class_creator( |
108 | 125 | runtime_cls: Annotated[Type[IsRuntime], pytest.fixture]) -> None: |
109 | 126 | DataClassBase.data_class_creator.config.dynamically_convert_elements_to_models = True |
|
0 commit comments