Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update test module import #623

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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