|
31 | 31 | import time |
32 | 32 | from datetime import timedelta |
33 | 33 | from pathlib import Path |
34 | | -from typing import TYPE_CHECKING, Any, Callable, Optional, Union |
| 34 | +from typing import Any, Callable, Optional, TYPE_CHECKING, Union |
35 | 35 | from urllib.error import HTTPError, URLError |
36 | 36 | from urllib.request import Request, urlopen |
37 | 37 |
|
| 38 | +from testcontainers.compose import DockerCompose |
38 | 39 | from testcontainers.core.utils import setup_logger |
39 | | -from . import testcontainers_config |
40 | 40 | # Import base classes from waiting_utils to make them available for tests |
41 | 41 | from testcontainers.core.waiting_utils import WaitStrategy, WaitStrategyTarget |
42 | | -from testcontainers.compose import DockerCompose |
43 | 42 |
|
44 | 43 | if TYPE_CHECKING: |
45 | 44 | from testcontainers.core.container import DockerContainer |
@@ -81,22 +80,6 @@ def __init__( |
81 | 80 | self._times = times |
82 | 81 | self._predicate_streams_and = predicate_streams_and |
83 | 82 |
|
84 | | - def with_startup_timeout(self, timeout: Union[int, timedelta]) -> "LogMessageWaitStrategy": |
85 | | - """Set the maximum time to wait for the container to be ready.""" |
86 | | - if isinstance(timeout, timedelta): |
87 | | - self._startup_timeout = int(timeout.total_seconds()) |
88 | | - else: |
89 | | - self._startup_timeout = timeout |
90 | | - return self |
91 | | - |
92 | | - def with_poll_interval(self, interval: Union[float, timedelta]) -> "LogMessageWaitStrategy": |
93 | | - """Set how frequently to check if the container is ready.""" |
94 | | - if isinstance(interval, timedelta): |
95 | | - self._poll_interval = interval.total_seconds() |
96 | | - else: |
97 | | - self._poll_interval = interval |
98 | | - return self |
99 | | - |
100 | 83 | def wait_until_ready(self, container: "WaitStrategyTarget") -> None: |
101 | 84 | """ |
102 | 85 | Wait until the specified message appears in the container logs. |
@@ -202,22 +185,6 @@ def __init__(self, port: int, path: Optional[str] = "/") -> None: |
202 | 185 | self._body: Optional[str] = None |
203 | 186 | self._insecure_tls = False |
204 | 187 |
|
205 | | - def with_startup_timeout(self, timeout: Union[int, timedelta]) -> "HttpWaitStrategy": |
206 | | - """Set the maximum time to wait for the container to be ready.""" |
207 | | - if isinstance(timeout, timedelta): |
208 | | - self._startup_timeout = int(timeout.total_seconds()) |
209 | | - else: |
210 | | - self._startup_timeout = timeout |
211 | | - return self |
212 | | - |
213 | | - def with_poll_interval(self, interval: Union[float, timedelta]) -> "HttpWaitStrategy": |
214 | | - """Set how frequently to check if the container is ready.""" |
215 | | - if isinstance(interval, timedelta): |
216 | | - self._poll_interval = interval.total_seconds() |
217 | | - else: |
218 | | - self._poll_interval = interval |
219 | | - return self |
220 | | - |
221 | 188 | @classmethod |
222 | 189 | def from_url(cls, url: str) -> "HttpWaitStrategy": |
223 | 190 | """ |
@@ -487,22 +454,6 @@ class HealthcheckWaitStrategy(WaitStrategy): |
487 | 454 | def __init__(self) -> None: |
488 | 455 | super().__init__() |
489 | 456 |
|
490 | | - def with_startup_timeout(self, timeout: Union[int, timedelta]) -> "HealthcheckWaitStrategy": |
491 | | - """Set the maximum time to wait for the container to be ready.""" |
492 | | - if isinstance(timeout, timedelta): |
493 | | - self._startup_timeout = int(timeout.total_seconds()) |
494 | | - else: |
495 | | - self._startup_timeout = timeout |
496 | | - return self |
497 | | - |
498 | | - def with_poll_interval(self, interval: Union[float, timedelta]) -> "HealthcheckWaitStrategy": |
499 | | - """Set how frequently to check if the container is ready.""" |
500 | | - if isinstance(interval, timedelta): |
501 | | - self._poll_interval = interval.total_seconds() |
502 | | - else: |
503 | | - self._poll_interval = interval |
504 | | - return self |
505 | | - |
506 | 457 | def wait_until_ready(self, container: WaitStrategyTarget) -> None: |
507 | 458 | """ |
508 | 459 | Wait until the container's health check reports as healthy. |
@@ -585,22 +536,6 @@ def __init__(self, port: int) -> None: |
585 | 536 | super().__init__() |
586 | 537 | self._port = port |
587 | 538 |
|
588 | | - def with_startup_timeout(self, timeout: Union[int, timedelta]) -> "PortWaitStrategy": |
589 | | - """Set the maximum time to wait for the container to be ready.""" |
590 | | - if isinstance(timeout, timedelta): |
591 | | - self._startup_timeout = int(timeout.total_seconds()) |
592 | | - else: |
593 | | - self._startup_timeout = timeout |
594 | | - return self |
595 | | - |
596 | | - def with_poll_interval(self, interval: Union[float, timedelta]) -> "PortWaitStrategy": |
597 | | - """Set how frequently to check if the container is ready.""" |
598 | | - if isinstance(interval, timedelta): |
599 | | - self._poll_interval = interval.total_seconds() |
600 | | - else: |
601 | | - self._poll_interval = interval |
602 | | - return self |
603 | | - |
604 | 539 | def wait_until_ready(self, container: WaitStrategyTarget) -> None: |
605 | 540 | """ |
606 | 541 | Wait until the specified port is available for connection. |
@@ -658,22 +593,6 @@ def __init__(self, file_path: Union[str, Path]) -> None: |
658 | 593 | super().__init__() |
659 | 594 | self._file_path = Path(file_path) |
660 | 595 |
|
661 | | - def with_startup_timeout(self, timeout: Union[int, timedelta]) -> "FileExistsWaitStrategy": |
662 | | - """Set the maximum time to wait for the container to be ready.""" |
663 | | - if isinstance(timeout, timedelta): |
664 | | - self._startup_timeout = int(timeout.total_seconds()) |
665 | | - else: |
666 | | - self._startup_timeout = timeout |
667 | | - return self |
668 | | - |
669 | | - def with_poll_interval(self, interval: Union[float, timedelta]) -> "FileExistsWaitStrategy": |
670 | | - """Set how frequently to check if the container is ready.""" |
671 | | - if isinstance(interval, timedelta): |
672 | | - self._poll_interval = interval.total_seconds() |
673 | | - else: |
674 | | - self._poll_interval = interval |
675 | | - return self |
676 | | - |
677 | 596 | def wait_until_ready(self, container: WaitStrategyTarget) -> None: |
678 | 597 | """ |
679 | 598 | Wait until the specified file exists on the host filesystem. |
@@ -806,44 +725,6 @@ def __init__(self, *strategies: WaitStrategy) -> None: |
806 | 725 | super().__init__() |
807 | 726 | self._strategies = list(strategies) |
808 | 727 |
|
809 | | - def with_startup_timeout(self, timeout: Union[int, timedelta]) -> "CompositeWaitStrategy": |
810 | | - """ |
811 | | - Set the startup timeout for all contained strategies. |
812 | | -
|
813 | | - Args: |
814 | | - timeout: Maximum time to wait in seconds |
815 | | -
|
816 | | - Returns: |
817 | | - self for method chaining |
818 | | - """ |
819 | | - if isinstance(timeout, timedelta): |
820 | | - self._startup_timeout = int(timeout.total_seconds()) |
821 | | - else: |
822 | | - self._startup_timeout = timeout |
823 | | - |
824 | | - for strategy in self._strategies: |
825 | | - strategy.with_startup_timeout(timeout) |
826 | | - return self |
827 | | - |
828 | | - def with_poll_interval(self, interval: Union[float, timedelta]) -> "CompositeWaitStrategy": |
829 | | - """ |
830 | | - Set the poll interval for all contained strategies. |
831 | | -
|
832 | | - Args: |
833 | | - interval: How frequently to check in seconds |
834 | | -
|
835 | | - Returns: |
836 | | - self for method chaining |
837 | | - """ |
838 | | - if isinstance(interval, timedelta): |
839 | | - self._poll_interval = interval.total_seconds() |
840 | | - else: |
841 | | - self._poll_interval = interval |
842 | | - |
843 | | - for strategy in self._strategies: |
844 | | - strategy.with_poll_interval(interval) |
845 | | - return self |
846 | | - |
847 | 728 | def wait_until_ready(self, container: WaitStrategyTarget) -> None: |
848 | 729 | """ |
849 | 730 | Wait until all contained strategies are ready. |
|
0 commit comments