Skip to content

Commit

Permalink
add basic API test
Browse files Browse the repository at this point in the history
  • Loading branch information
zariiii9003 committed Oct 19, 2023
1 parent 9e8b71d commit 36cb1b1
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@ env:
PY_COLORS: "1"

jobs:
test:
runs-on: windows-latest
strategy:
matrix:
python-version: [
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install .
- name: Test
run: |
python -m pytest -v --assert=plain ./tests
mypy:
runs-on: windows-latest
steps:
Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ select = [
"I", # isort
"ISC", # flake8-implicit-str-concat
"PIE", # flake8-pie
"PL",
"PL", # pylint
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"S", # flake8-bandit
Expand All @@ -105,5 +105,12 @@ ignore = [
"RUF012", # mutable-class-default
]

[tool.ruff.per-file-ignores]
"tests/**/*.py" = [
"S101", # asserts allowed in tests...
"ARG", # Unused function args -> fixtures nevertheless are functionally relevant
"PLR2004", # Magic value used in comparison
]

[tool.ruff.isort]
known-first-party = ["pycanape"]
Empty file added tests/__init__.py
Empty file.
46 changes: 46 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import pycanape


def test_toplevel_attributes() -> None:
assert hasattr(pycanape, "__version__")
assert hasattr(pycanape, "cnp_api")
assert hasattr(pycanape, "calibration_object")
assert hasattr(pycanape, "canape")
assert hasattr(pycanape, "config")
assert hasattr(pycanape, "daq")
assert hasattr(pycanape, "ecu_task")
assert hasattr(pycanape, "get_canape_data_path")
assert hasattr(pycanape, "get_canape_dll_path")
assert hasattr(pycanape, "get_canape_path")
assert hasattr(pycanape, "get_canape_versions")
assert hasattr(pycanape, "module")
assert hasattr(pycanape, "recorder")
assert hasattr(pycanape, "script")
assert hasattr(pycanape, "utils")
assert hasattr(pycanape, "AsciiCalibrationObject")
assert hasattr(pycanape, "AxisCalibrationObject")
assert hasattr(pycanape, "CANapeDll")
assert hasattr(pycanape, "CANapeVersion")
assert hasattr(pycanape, "CurveCalibrationObject")
assert hasattr(pycanape, "MapCalibrationObject")
assert hasattr(pycanape, "ScalarCalibrationObject")
assert hasattr(pycanape, "ValueBlockCalibrationObject")
assert hasattr(pycanape, "AppVersion")
assert hasattr(pycanape, "CANape")
assert hasattr(pycanape, "Channels")
assert hasattr(pycanape, "DriverType")
assert hasattr(pycanape, "EventCode")
assert hasattr(pycanape, "MeasurementState")
assert hasattr(pycanape, "ObjectType")
assert hasattr(pycanape, "RecorderState")
assert hasattr(pycanape, "RecorderType")
assert hasattr(pycanape, "ValueType")
assert hasattr(pycanape, "RC")
assert hasattr(pycanape, "FifoReader")
assert hasattr(pycanape, "DatabaseInfo")
assert hasattr(pycanape, "EcuTask")
assert hasattr(pycanape, "MeasurementListEntry")
assert hasattr(pycanape, "Module")
assert hasattr(pycanape, "Recorder")
assert hasattr(pycanape, "Script")
assert hasattr(pycanape, "CANapeError")

0 comments on commit 36cb1b1

Please sign in to comment.