
Security News
Research
Destructive npm Packages Disguised as Utilities Enable Remote System Wipe
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
tomodachi-testcontainers
Advanced tools
Collection of Testcontainers, pytest fixtures and test clients for end-to-end/integration testing for Python Tomodachi framework. A great starting point to learn more about Testcontainers and necessity of integration testing.
Tomodachi Testcontainers is a Python library built on top of testcontainers-python. It provides Testcontainers, pytest fixtures, and test clients for convenient use of Testcontainers with pytest and testing applications built with the Python Tomodachi framework.
This library was created to explore and learn Testcontainers. Although initially intended to be used with the Tomodachi framework, it works for testing applications built with any other Python framework like Flask, FastAPI, Django, etc.
Testcontainers is an open-source framework for providing throwaway, lightweight instances of databases, message brokers, web browsers, or just about anything that can run in a Docker container. It facilitates the use of Docker containers for functional, integration, and end-to-end testing. — https://testcontainers.com/
To learn more about what Testcontainers are and what problems they solve, take a look at the Getting Started guide in the official Testcontainers documentation - https://testcontainers.com/getting-started/
Find documentation at https://filipsnastins.github.io/tomodachi-testcontainers/
The official Testcontainers documentation is at https://testcontainers.com/
Install with pip:
pip install tomodachi-testcontainers
Install with Poetry:
poetry add --group dev tomodachi-testcontainers
Find a list of extras in the installation reference.
The hello, world
Tomodachi service:
# src/hello.py
import tomodachi
from aiohttp import web
class Service(tomodachi.Service):
@tomodachi.http("GET", r"/hello/?")
async def hello(self, request: web.Request) -> web.Response:
name = request.query.get("name", "world")
return web.json_response({"message": f"Hello, {name}!"})
testcontainer_image
fixture builds a Docker image with a Dockerfile from the current working directory.tomodachi_container
fixture starts a new Docker container running the hello
service on a randomly available port.test_hello_testcontainers
sends a GET /hello?name=Testcontainers
request to the running container and asserts the response.# tests/test_hello.py
from typing import Generator
import httpx
import pytest
from tomodachi_testcontainers import DockerContainer, TomodachiContainer
@pytest.fixture(scope="session")
def tomodachi_container(testcontainer_image: str) -> Generator[DockerContainer, None, None]:
with TomodachiContainer(testcontainer_image).with_command(
"tomodachi run readme/hello.py --production"
) as container:
yield container
@pytest.mark.asyncio(loop_scope="session")
async def test_hello_testcontainers(tomodachi_container: TomodachiContainer) -> None:
async with httpx.AsyncClient(base_url=tomodachi_container.get_external_url()) as client:
response = await client.get("/hello", params={"name": "Testcontainers"})
assert response.status_code == 200
assert response.json() == {"message": "Hello, Testcontainers!"}
FAQs
Collection of Testcontainers, pytest fixtures and test clients for end-to-end/integration testing for Python Tomodachi framework. A great starting point to learn more about Testcontainers and necessity of integration testing.
We found that tomodachi-testcontainers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.
Research
Security News
Socket uncovered four malicious npm packages that exfiltrate up to 85% of a victim’s Ethereum or BSC wallet using obfuscated JavaScript.