-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streamline and update to latest testing practices
- Loading branch information
1 parent
eb7c7ca
commit 72ea78e
Showing
8 changed files
with
59 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
# Python Configuration | ||
PYPROJECT_TOML := pyproject.toml | ||
PROJECT_VERSION := $(shell grep -oP '(?<=version = ")[^"]+' $(PYPROJECT_TOML) | head -n 1) | ||
|
||
.DEFAULT_GOAL := init | ||
|
||
.PHONY += init paths checks test clean | ||
|
||
init: # Do the initial configuration of the project | ||
@test -e .env || cp example.env .env | ||
@sed -i 's/^USER_ID=.*/USER_ID=$(shell id -u)/' .env | ||
@sed -i 's/^GROUP_ID=.*/GROUP_ID=$(shell id -g)/' .env | ||
@sed -i 's/^PROJECT_VERSION=.*/PROJECT_VERSION=$(PROJECT_VERSION)/' .env | ||
ifeq ($(shell uname),Darwin) | ||
@sed -i '' 's|^PROJECT_PATH=.*|PROJECT_PATH=$(shell pwd | sed 's/\//\\\//g')|' .env | ||
else | ||
@sed -i 's/^PROJECT_PATH=.*/PROJECT_PATH=$(shell pwd | sed 's/\//\\\//g')/' .env | ||
endif | ||
|
||
.env: init | ||
|
||
paths: .env # Create the necessary data directories | ||
@mkdir -p $(shell grep -E '^WEI_DATA_DIR=' .env | cut -d '=' -f 2) | ||
@mkdir -p $(shell grep -E '^REDIS_DIR=' .env | cut -d '=' -f 2) | ||
|
||
checks: # Runs all the pre-commit checks | ||
@pre-commit install | ||
@pre-commit run --all-files || { echo "Checking fixes\n" ; pre-commit run --all-files; } | ||
|
||
test: init .env paths # Runs all the tests | ||
@docker compose -f wei.compose.yaml --env-file .env up --build -d | ||
@docker compose -f wei.compose.yaml --env-file .env exec camera_module pytest -p no:cacheprovider camera_module | ||
@docker compose -f wei.compose.yaml --env-file .env down | ||
test: init .env # Runs all the tests | ||
@docker compose -f tests/wei.compose.yaml --env-file .env up --build -d | ||
@docker compose -f tests/wei.compose.yaml --env-file .env exec camera_module pytest -p no:cacheprovider camera_module | ||
@docker compose -f tests/wei.compose.yaml --env-file .env down | ||
|
||
clean: | ||
@rm .env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
# Note: all paths are relative to the docker compose file | ||
USER_ID= | ||
GROUP_ID= | ||
DEVICE=/dev/video0 | ||
# The PROJECT_PATH should be the absolute path to the root of the repo | ||
PROJECT_PATH= | ||
PROJECT_VERSION=1.2.0 | ||
WEI_DATA_DIR=~/.wei | ||
WORKCELL_FILENAME=test_workcell.yaml | ||
WORKCELLS_DIR=${PROJECT_PATH}/tests/workcell_defs | ||
IMAGE=ghcr.io/ad-sdl/camera_module | ||
REDIS_DIR=~/.wei/redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Base module tests.""" | ||
|
||
import unittest | ||
|
||
|
||
class TestModule_Base(unittest.TestCase): | ||
"""Base test class for this module.""" | ||
|
||
pass | ||
|
||
|
||
class TestImports(TestModule_Base): | ||
"""Test the imports of the module are working correctly""" | ||
|
||
def test_driver_import(self): | ||
"""Test the driver and rest node imports""" | ||
import camera_rest_node | ||
|
||
assert camera_rest_node | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters