sendmock-testcontainers 0.1.0b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""SendMock in Docker for a test: SMTP, the HTTP API and UI, and the provider port that
|
|
2
|
+
answers provider SDKs at their real paths."""
|
|
3
|
+
|
|
4
|
+
from testcontainers.core.container import DockerContainer
|
|
5
|
+
from testcontainers.core.wait_strategies import HttpWaitStrategy
|
|
6
|
+
|
|
7
|
+
DEFAULT_IMAGE = "ghcr.io/shibbirweb/sendmock:0.1.0-beta.1"
|
|
8
|
+
SMTP_PORT = 1025
|
|
9
|
+
HTTP_PORT = 8025
|
|
10
|
+
PROVIDER_PORT = 8026
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SendMockContainer(DockerContainer):
|
|
14
|
+
def __init__(self, image: str = DEFAULT_IMAGE, **container_options) -> None:
|
|
15
|
+
super().__init__(image, **container_options)
|
|
16
|
+
self.with_exposed_ports(SMTP_PORT, HTTP_PORT, PROVIDER_PORT)
|
|
17
|
+
self.with_env("SENDMOCK_PROVIDER_ADDR", f"0.0.0.0:{PROVIDER_PORT}")
|
|
18
|
+
self.waiting_for(HttpWaitStrategy(HTTP_PORT, "/api/v1/health"))
|
|
19
|
+
|
|
20
|
+
def get_smtp_host(self) -> str:
|
|
21
|
+
"""The host the SMTP port is reached on."""
|
|
22
|
+
return self.get_container_host_ip()
|
|
23
|
+
|
|
24
|
+
def get_smtp_port(self) -> int:
|
|
25
|
+
"""The SMTP port on the host, for the app's mail settings."""
|
|
26
|
+
return int(self.get_exposed_port(SMTP_PORT))
|
|
27
|
+
|
|
28
|
+
def get_http_url(self) -> str:
|
|
29
|
+
"""The HTTP API and UI, e.g. `http://localhost:32768`."""
|
|
30
|
+
return f"http://{self.get_container_host_ip()}:{self.get_exposed_port(HTTP_PORT)}"
|
|
31
|
+
|
|
32
|
+
def get_provider_url(self) -> str:
|
|
33
|
+
"""The provider port, the base URL to give a provider SDK instead of the provider's own."""
|
|
34
|
+
return f"http://{self.get_container_host_ip()}:{self.get_exposed_port(PROVIDER_PORT)}"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
__all__ = ["DEFAULT_IMAGE", "SendMockContainer"]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sendmock-testcontainers
|
|
3
|
+
Version: 0.1.0b1
|
|
4
|
+
Summary: Starts SendMock in Docker from a test and gives its SMTP, HTTP and provider addresses.
|
|
5
|
+
License-Expression: MIT OR Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://shibbirweb.github.io/sendmock/
|
|
7
|
+
Project-URL: Source, https://github.com/shibbirweb/sendmock/tree/develop/testcontainers/python
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: testcontainers==4.15.0
|
|
10
|
+
Provides-Extra: test
|
|
11
|
+
Requires-Dist: pytest==8.4.2; extra == "test"
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
sendmock_testcontainers/__init__.py,sha256=fukG4Zek6O42jK27sjeaj6FYtSxzBgBoR1RXmRrHaVY,1540
|
|
2
|
+
sendmock_testcontainers-0.1.0b1.dist-info/METADATA,sha256=Zrik6zssl86UMuwvTzgcf92kYGyE7Dkj8IiXuSZzr3A,489
|
|
3
|
+
sendmock_testcontainers-0.1.0b1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
4
|
+
sendmock_testcontainers-0.1.0b1.dist-info/top_level.txt,sha256=wosmhRg2UOAoA1Ko0N8tZ6PXYn0vy52Avb2CUx_tzYY,24
|
|
5
|
+
sendmock_testcontainers-0.1.0b1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sendmock_testcontainers
|