|
1 | 1 | # SPDX-License-Identifier: GPL-3.0-or-later |
2 | 2 | from unittest.mock import patch |
| 3 | +from unittest import mock |
3 | 4 | from io import BytesIO |
4 | 5 | import os |
5 | 6 | import re |
@@ -37,6 +38,7 @@ def test_configure_celery_with_classes_and_files(mock_open, mock_isfile, mock_ge |
37 | 38 | assert celery_app.conf.broker_connection_max_retries == 10 |
38 | 39 |
|
39 | 40 |
|
| 41 | +@mock.patch.dict(os.environ, {'IIB_OTEL_TRACING': 'some-str'}) |
40 | 42 | @patch('os.path.isdir', return_value=True) |
41 | 43 | @patch('os.access', return_value=True) |
42 | 44 | def test_validate_celery_config(mock_isdir, mock_isaccess): |
@@ -291,35 +293,23 @@ def test_validate_celery_config_invalid_s3_env_vars(): |
291 | 293 | validate_celery_config(conf) |
292 | 294 |
|
293 | 295 |
|
294 | | -@pytest.mark.parametrize( |
295 | | - 'config, error', |
296 | | - ( |
297 | | - ( |
298 | | - {'iib_otel_tracing': True}, |
299 | | - ( |
300 | | - '"OTEL_EXPORTER_OTLP_ENDPOINT" and "OTEL_SERVICE_NAME" environment ' |
301 | | - 'variables must be set to valid strings when iib_otel_tracing is set to True.' |
302 | | - ), |
303 | | - ), |
304 | | - ( |
305 | | - {'iib_otel_tracing': 'random-str'}, |
306 | | - '"iib_otel_tracing" must be a valid boolean value', |
307 | | - ), |
308 | | - ), |
309 | | -) |
310 | | -def test_validate_celery_config_invalid_otel_config(tmpdir, config, error): |
| 296 | +@mock.patch.dict(os.environ, {'IIB_OTEL_TRACING': 'True'}) |
| 297 | +def test_validate_celery_config_invalid_otel_config(tmpdir): |
311 | 298 | conf = { |
312 | 299 | 'iib_api_url': 'http://localhost:8080/api/v1/', |
313 | 300 | 'iib_registry': 'registry', |
314 | 301 | 'iib_required_labels': {}, |
315 | 302 | 'iib_organization_customizations': {}, |
316 | 303 | 'iib_request_recursive_related_bundles_dir': tmpdir.join('some-dir'), |
317 | 304 | } |
| 305 | + error = ( |
| 306 | + '"OTEL_EXPORTER_OTLP_ENDPOINT" and "OTEL_SERVICE_NAME" environment ' |
| 307 | + 'variables must be set to valid strings when "IIB_OTEL_TRACING" is set to True.' |
| 308 | + ) |
318 | 309 | iib_request_recursive_related_bundles_dir = conf['iib_request_recursive_related_bundles_dir'] |
319 | 310 | iib_request_recursive_related_bundles_dir.mkdir() |
320 | | - worker_config = {**conf, **config} |
321 | 311 | with pytest.raises(ConfigError, match=error): |
322 | | - validate_celery_config(worker_config) |
| 312 | + validate_celery_config(conf) |
323 | 313 |
|
324 | 314 |
|
325 | 315 | def test_validate_celery_config_invalid_recursive_related_bundles_config(): |
|
0 commit comments