|
1 | 1 | import re
|
2 | 2 | from pathlib import Path
|
3 |
| -from typing import Any, Dict, List, Optional, Set |
| 3 | +from typing import Any, Dict, Optional, Set |
4 | 4 | from unittest.mock import MagicMock, patch, PropertyMock
|
5 | 5 |
|
6 | 6 | import pytest
|
|
14 | 14 | run_operator_sdk_bundle_validate,
|
15 | 15 | check_api_version_constraints,
|
16 | 16 | check_replaces_availability,
|
17 |
| - check_upgrade_graph_loop, |
18 | 17 | check_using_fbc,
|
19 | 18 | ocp_to_k8s_ver,
|
20 | 19 | )
|
@@ -512,75 +511,6 @@ def test_check_api_version_constraints(
|
512 | 511 | assert set(check_api_version_constraints(bundle)) == expected
|
513 | 512 |
|
514 | 513 |
|
515 |
| -def test_check_upgrade_graph_loop(tmp_path: Path) -> None: |
516 |
| - create_files( |
517 |
| - tmp_path, |
518 |
| - bundle_files("hello", "0.0.1"), |
519 |
| - bundle_files("hello", "0.0.2", csv={"spec": {"replaces": "hello.v0.0.1"}}), |
520 |
| - ) |
521 |
| - |
522 |
| - repo = Repo(tmp_path) |
523 |
| - operator = repo.operator("hello") |
524 |
| - bundle = operator.bundle("0.0.1") |
525 |
| - with patch.object( |
526 |
| - type(operator), "config", new_callable=PropertyMock |
527 |
| - ) as mock_config: |
528 |
| - mock_config.return_value = {"updateGraph": "replaces-mode"} |
529 |
| - is_loop = list(check_upgrade_graph_loop(bundle)) |
530 |
| - assert is_loop == [] |
531 |
| - |
532 |
| - with patch.object( |
533 |
| - type(operator), "config", new_callable=PropertyMock |
534 |
| - ) as mock_config: |
535 |
| - mock_config.return_value = {"updateGraph": "unknown-mode"} |
536 |
| - is_loop = list(check_upgrade_graph_loop(bundle)) |
537 |
| - assert is_loop == [ |
538 |
| - Fail("Operator(hello): unsupported updateGraph value: unknown-mode") |
539 |
| - ] |
540 |
| - |
541 |
| - # Both bundles replace each other |
542 |
| - create_files( |
543 |
| - tmp_path, |
544 |
| - bundle_files("hello", "0.0.1", csv={"spec": {"replaces": "hello.v0.0.2"}}), |
545 |
| - bundle_files("hello", "0.0.2", csv={"spec": {"replaces": "hello.v0.0.1"}}), |
546 |
| - ) |
547 |
| - |
548 |
| - repo = Repo(tmp_path) |
549 |
| - operator = repo.operator("hello") |
550 |
| - bundle = operator.bundle("0.0.1") |
551 |
| - with patch.object( |
552 |
| - type(operator), "config", new_callable=PropertyMock |
553 |
| - ) as mock_config: |
554 |
| - mock_config.return_value = {"updateGraph": "replaces-mode"} |
555 |
| - is_loop = list(check_upgrade_graph_loop(bundle)) |
556 |
| - assert len(is_loop) == 1 and isinstance(is_loop[0], Fail) |
557 |
| - assert ( |
558 |
| - is_loop[0].reason |
559 |
| - == "Upgrade graph loop detected for bundle: [Bundle(hello/0.0.1), " |
560 |
| - "Bundle(hello/0.0.2), Bundle(hello/0.0.1)]" |
561 |
| - ) |
562 |
| - |
563 |
| - # Malformed .spec.replaces |
564 |
| - create_files( |
565 |
| - tmp_path, |
566 |
| - bundle_files("malformed", "0.0.1", csv={"spec": {"replaces": ""}}), |
567 |
| - ) |
568 |
| - |
569 |
| - repo = Repo(tmp_path) |
570 |
| - operator = repo.operator("malformed") |
571 |
| - bundle = operator.bundle("0.0.1") |
572 |
| - with patch.object( |
573 |
| - type(operator), "config", new_callable=PropertyMock |
574 |
| - ) as mock_config: |
575 |
| - mock_config.return_value = {"updateGraph": "replaces-mode"} |
576 |
| - failures = list(check_upgrade_graph_loop(bundle)) |
577 |
| - assert len(failures) == 1 and isinstance(failures[0], Fail) |
578 |
| - assert ( |
579 |
| - "Bundle(malformed/0.0.1) has invalid 'replaces' field:" |
580 |
| - in failures[0].reason |
581 |
| - ) |
582 |
| - |
583 |
| - |
584 | 514 | def test_check_replaces_availability_no_replaces(
|
585 | 515 | tmp_path: Path,
|
586 | 516 | ) -> None:
|
|
0 commit comments