Skip to content

Commit

Permalink
Merge pull request makerplane#229 from e100/code_tests
Browse files Browse the repository at this point in the history
Code tests, update standards
  • Loading branch information
e100 authored Jun 15, 2024
2 parents 6da2345 + a836d6a commit 075a1b7
Show file tree
Hide file tree
Showing 200 changed files with 2,367 additions and 447 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Phil Birkelbach
Neil Domalik
Jean-Manuel Gagnon
Garrett Herschleb
Eric Blevins
37 changes: 31 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,48 @@ SHELL := /bin/bash


##################################### I N I T T A R G E T S #####################################
venv:
venv.marker:
python3 -m venv venv
source venv/bin/activate ; pip install --upgrade pip
source venv/bin/activate ; pip install black
source venv/bin/activate ; pip install pytest
source venv/bin/activate ; pip install pytest-qt
source venv/bin/activate ; pip install pytest-env
source venv/bin/activate ; pip install pytest-cov
touch venv.marker
echo -e "\nRun:\nsource venv/bin/activate"
venv: venv.marker
.PHONY: venv

init.marker: setup.py
pip install -e .[install]
init.marker: pyproject.toml
source venv/bin/activate ; pip install -e .[install]
touch init.marker
init: init.marker
init: venv.marker init.marker
.PHONY: init

#################################### W H E E L T A R G E T S ####################################
init-build.marker: init
pip install -e .[build]
source venv/bin/activate ; pip install -e .[build]
touch init-build.marker

init-build: init-build.marker
.PHONY: init-build

wheel: init-build
python -m build --wheel
source venv/bin/activate ; python -m build --wheel


test: init
source venv/bin/activate ; pytest

.PHONY: test

clean:
rm -rfI venv
rm -fI extras/extras/test_results/*.html
rm -fI extras/extras/test_results/*.png
rm -rfI extras/extras/test_results/htmlcov/
rm -f init-build.marker
rm -f init.marker
rm -f venv.marker
.PHONY: clean
19 changes: 19 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ This creates an index.bin file in CIFP directory
Update the config file [Screen.PFD] section dbpath and indexpath
with the path names of the FAACIFP18 and index.bin files respectively.

Testing
------------
To run all of the automated tests and code covreage.

::

$ make test


Distribution
------------

Expand Down Expand Up @@ -114,3 +123,13 @@ All CLI options work as defined.
--log-config LOG_CONFIG
Alternate logger configuration file


Cleanup
------------

To cleanup all of the test files, virtual environemnt and other changes made by the makefile. This is a destructive command, you may want to review what it does before running it.

::

$ make clean

99 changes: 99 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import pytest
# Patch pyavtools.fix so it can run in memory without a fix server
import sys
import tests.mock_db.client
import tests.mock_db.scheduler

sys.modules["pyavtools.fix.client"] = tests.mock_db.client
sys.modules["pyavtools.scheduler"] = tests.mock_db.scheduler



@pytest.fixture
def fix():
# import fix
import pyavtools.fix as fix

# Init database
fix.initialize({"main": {"FixServer": "localhost", "FixPort": "3490"}})

# TODO Add example setting aux values since needed on many tests
# Define some fix db items we can use in tests
# Define a key:
# key,desc, dtype(as a string), min, max, units, tol, aux
fix.db.define_item("TEST", "Testing key", "float", 0, 100, "", 50000, "")
# Set initial Value
fix.db.set_value("TEST", 50.19)
# Bad and fail are true by default to set them False
fix.db.get_item("TEST").bad = False
fix.db.get_item("TEST").fail = False


def create_numbers(key, value, old=False, bad=False, fail=False, annunciate=False):
fix.db.define_item(
key,
"Number",
"float",
0,
100,
"degC",
50000,
"Min,Max,highWarn,highAlarm,lowWarn,lowAlarm",
)
fix.db.set_value(key, value)
fix.db.get_item(key).old = old
fix.db.get_item(key).bad = bad
fix.db.get_item(key).fail = fail
fix.db.get_item(key).annunciate = annunciate
fix.db.get_item(key).set_aux_value("Min", 0)
fix.db.get_item(key).set_aux_value("lowAlarm", 10)
fix.db.get_item(key).set_aux_value("lowWarn", 20)
fix.db.get_item(key).set_aux_value("highWarn", 80)
fix.db.get_item(key).set_aux_value("highAlarm", 90)
fix.db.get_item(key).set_aux_value("Max", 100)


create_numbers("NUMOK", 50.91)
create_numbers("NUMOLD", 51.82, old=True)
create_numbers("NUMBAD", 48.73, bad=True)
create_numbers("NUMFAIL", 65.64, fail=True)
create_numbers("NUMANNUNCIATE", 62.55, annunciate=True)
create_numbers("NUMLOWWARN", 18.46)
create_numbers("NUMLOWALARM", 5.37)
create_numbers("NUMHIGHWARN", 81.28)
create_numbers("NUMHIGHALARM", 95.19)

# Number with no Aux
fix.db.define_item("NUM", "NUM", "float", 0.0, 100.0, "degC", 50000, "")

fix.db.define_item("GS", "GS", "float", 0.0, 2000.0, "knots", 50000, "")
fix.db.set_value("GS", 100)
fix.db.get_item("GS").bad = False
fix.db.get_item("GS").fail = False

fix.db.define_item("TAS", "TAS", "float", 0.0, 2000.0, "knots", 50000, "")
fix.db.set_value("TAS", 105)
fix.db.get_item("TAS").bad = False
fix.db.get_item("TAS").fail = False

fix.db.define_item(
"IAS",
"Number",
"float",
0,
2000.0,
"knots",
50000,
"Min,Max,V1,V2,Vne,Vfe,Vmc,Va,Vno,Vs,Vs0,Vx,Vy",
)
fix.db.set_value("IAS", "110")
fix.db.get_item("IAS").bad = False
fix.db.get_item("IAS").fail = False
fix.db.get_item("IAS").set_aux_value("Vs", 45.0)
fix.db.get_item("IAS").set_aux_value("Vs0", 40.0)
fix.db.get_item("IAS").set_aux_value("Vno", 125.0)
fix.db.get_item("IAS").set_aux_value("Vne", 140.0)
fix.db.get_item("IAS").set_aux_value("Vfe", 70.0)

return fix

File renamed without changes.
92 changes: 0 additions & 92 deletions pyefis/cfg.py

This file was deleted.

57 changes: 0 additions & 57 deletions pyefis/instruments/helpers/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions pyefis/version.py

This file was deleted.

Loading

0 comments on commit 075a1b7

Please sign in to comment.