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

App: Use testcontainers to check integration with OctoPrint #23

Merged
merged 1 commit into from
Jul 11, 2023
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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/

# Python
*.egg*
venv/

# Local files
.idea/
6 changes: 4 additions & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ jobs:
python-version: ${{ matrix.python-version }}
- run: pip install OctoPrint
- name: Install test dependencies
run: pip install mock
- name: Run tests
run: pip install mock testcontainers-compose
- name: Run unit tests
run: python -m unittest discover
- name: Run integration tests
run: python -m unittest discover -p "integration_*.py"
- name: Install module
run: pip install -e .
4 changes: 4 additions & 0 deletions Dockerfile.integration
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM octoprint/octoprint:latest
ENV PIP_USER false
ADD . /OctoPrint-RestoreLevelingAfterG28
RUN pip install --editable /OctoPrint-RestoreLevelingAfterG28
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '2.4'

services:
octoprint:
build:
context: .
dockerfile: Dockerfile.integration
ports:
- 80:80
17 changes: 17 additions & 0 deletions tests/integration_octoprint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import time
import unittest
from pathlib import Path

from testcontainers.compose import DockerCompose


class TestIntegration(unittest.TestCase):

def test_octoprint_boots_without_errors(self):
project_root = Path(__file__).parent.parent
with DockerCompose(str(project_root)) as compose:
time.sleep(6) # Give OctoPrint time to boot
stdout, stderr = compose.get_logs()
self.assertEqual(b"", stderr, msg="empty stderr")
print(stdout.decode())
self.assertTrue(b"| Restore Leveling After G28" in stdout, msg="plugin was registered")