Skip to content

Commit

Permalink
fix: update test module import (#623)
Browse files Browse the repository at this point in the history
Following #612, updated the test module import with a better name and
some minor fixes.
  • Loading branch information
Tranquility2 authored Jun 30, 2024
1 parent 0b866ff commit 16f6ca4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
2 changes: 2 additions & 0 deletions modules/test_module_import/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.. autoclass:: testcontainers.test_module_import.NewSubModuleContainer
.. title:: testcontainers.test_module_import.NewSubModuleContainer
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ class NewSubModuleContainer(ServerContainer):
>>> import httpx
>>> from testcontainers.core.image import DockerImage
>>> from testcontainers.testmoduleimport import NewSubModuleContainer
>>> from testcontainers.test_module_import import NewSubModuleContainer
>>> with DockerImage(path="./modules/generic/tests/samples/python_server", tag="test-mod:latest") as image:
... with NewSubModuleContainer(port=9000, image=image) as srv:
... url = srv._create_connection_url()
>>> with DockerImage(path="./modules/generic/tests/samples/python_server", tag="test-new-mod:latest") as image:
... with NewSubModuleContainer(port=9000, image=image) as new_mod:
... url = new_mod._create_connection_url()
... response = httpx.get(f"{url}", timeout=5)
... assert response.status_code == 200, "Response status code is not 200"
... assert srv.print_mock() == "NewSubModuleContainer"
... assert new_mod.additional_capability() == "NewSubModuleContainer"
"""

def __init__(self, port: int, image: str) -> None:
super().__init__(port, image)

def print_mock(self) -> str:
def additional_capability(self) -> str:
return "NewSubModuleContainer"
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

from testcontainers.core.waiting_utils import wait_for_logs
from testcontainers.core.image import DockerImage
from testcontainers.testmoduleimport import NewSubModuleContainer
from testcontainers.test_module_import import NewSubModuleContainer


def test_like_doctest():
with DockerImage(path="./modules/generic/tests/samples/python_server", tag="test-srv:latest") as image:
with NewSubModuleContainer(port=9000, image=image) as srv:
assert srv.print_mock() == "NewSubModuleContainer"
url = srv._create_connection_url()
with DockerImage(path="./modules/generic/tests/samples/python_server", tag="test-new-mod:latest") as image:
with NewSubModuleContainer(port=9000, image=image) as new_mod:
url = new_mod._create_connection_url()
response = httpx.get(f"{url}", timeout=5)
assert response.status_code == 200, "Response status code is not 200"
_ = wait_for_logs(srv, "GET / HTTP/1.1")
assert new_mod.additional_capability() == "NewSubModuleContainer"
2 changes: 0 additions & 2 deletions modules/testmoduleimport/README.rst

This file was deleted.

5 changes: 2 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ packages = [
{ include = "testcontainers", from = "modules/cosmosdb" },
{ include = "testcontainers", from = "modules/elasticsearch" },
{ include = "testcontainers", from = "modules/generic" },
{ include = "testcontainers", from = "modules/testmoduleimport"},
{ include = "testcontainers", from = "modules/test_module_import"},
{ include = "testcontainers", from = "modules/google" },
{ include = "testcontainers", from = "modules/influxdb" },
{ include = "testcontainers", from = "modules/k3s" },
Expand Down Expand Up @@ -120,7 +120,7 @@ cosmosdb = ["azure-cosmos"]
cockroachdb = []
elasticsearch = []
generic = ["httpx"]
testmoduleimport = ["httpx"]
test_module_import = ["httpx"]
google = ["google-cloud-pubsub", "google-cloud-datastore"]
influxdb = ["influxdb", "influxdb-client"]
k3s = ["kubernetes", "pyyaml"]
Expand Down

0 comments on commit 16f6ca4

Please sign in to comment.