Skip to content

Commit

Permalink
add container test env
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Dec 17, 2024
1 parent 2256987 commit 82c8796
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG PYTHON_VERSION=3.12

FROM python:${PYTHON_VERSION}-slim

WORKDIR /app

COPY . .

RUN python3 -m pip install poetry pytest-cov pytest-httpx
RUN poetry install --extras "chat" --extras "graph" --extras "sql" --extras "dev"

CMD ["python3", "-m", "poetry", "run", "pytest", "-vv", "-m", "not expensive", "--cov=mdmodels"]
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,36 @@ To get you started, have a look at the [examples](./examples) folder, featuring
- [Basic](./examples/sql/basic) - Create a SQL database and interact with it
- [Graph tools](./examples/graph)
- [Basic](./examples/graph/basic) - Create a graph database and interact with it

## Development

To run the tests for the package, use the following command:

```bash
# Execute all tests defined in the project
poetry run pytest
```

To run the tests and generate a detailed coverage report, which shows how much of your code is tested, use:

```bash
# Run tests with coverage analysis and generate an HTML report
poetry run pytest --cov=mdmodels --cov-report=html
```

If you want to run the tests within a Docker container, which can help ensure a consistent environment, use the following commands:

```bash
# Build the Docker image, specifying the Python version to use
docker build --build-arg PYTHON_VERSION=3.12 -t mdmodels .

# Run the Docker container, mounting the current directory to /app in the container
docker run -v $(pwd):/app mdmodels
```

To skip tests that are considered expensive and require additional services (like databases or external APIs), you can run:

```bash
# Execute tests while excluding those marked as expensive
poetry run pytest -m "not expensive"
```

0 comments on commit 82c8796

Please sign in to comment.